ariG23498 HF Staff commited on
Commit
ed43068
·
verified ·
1 Parent(s): 7f5b62a

Upload PaddlePaddle_PaddleOCR-VL_0.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. PaddlePaddle_PaddleOCR-VL_0.py +35 -0
PaddlePaddle_PaddleOCR-VL_0.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # /// script
2
+ # requires-python = ">=3.12"
3
+ # dependencies = [
4
+ # "torch",
5
+ # "torchvision",
6
+ # "transformers",
7
+ # "accelerate",
8
+ # "peft",
9
+ # ]
10
+ # ///
11
+
12
+ try:
13
+ # See https://www.paddleocr.ai/latest/version3.x/pipeline_usage/PaddleOCR-VL.html to installation
14
+
15
+ from paddleocr import PaddleOCRVL
16
+ pipeline = PaddleOCRVL()
17
+ output = pipeline.predict("path/to/document_image.png")
18
+ for res in output:
19
+ res.print()
20
+ res.save_to_json(save_path="output")
21
+ res.save_to_markdown(save_path="output")
22
+ with open('PaddlePaddle_PaddleOCR-VL_0.txt', 'w', encoding='utf-8') as f:
23
+ f.write('Everything was good in PaddlePaddle_PaddleOCR-VL_0.txt')
24
+ except Exception as e:
25
+ with open('PaddlePaddle_PaddleOCR-VL_0.txt', 'w', encoding='utf-8') as f:
26
+ import traceback
27
+ traceback.print_exc(file=f)
28
+ finally:
29
+ from huggingface_hub import upload_file
30
+ upload_file(
31
+ path_or_fileobj='PaddlePaddle_PaddleOCR-VL_0.txt',
32
+ repo_id='model-metadata/code_execution_files',
33
+ path_in_repo='PaddlePaddle_PaddleOCR-VL_0.txt',
34
+ repo_type='dataset',
35
+ )