model-metadata/code_python_files
014k
1# /// script2# requires-python = ">=3.12"3# dependencies = [4# "numpy",5# "einops",6# "pandas",7# "matplotlib",8# "protobuf",9# "torch",10# "sentencepiece",11# "torchvision",12# "transformers",13# "timm",14# "diffusers",15# "sentence-transformers",16# "accelerate",17# "peft",18# "slack-sdk",19# ]20# ///21 22try:23 # See https://www.paddleocr.ai/latest/version3.x/pipeline_usage/PaddleOCR-VL.html to installation24 25 from paddleocr import PaddleOCRVL26 pipeline = PaddleOCRVL(pipeline_version="v1.5")27 output = pipeline.predict("path/to/document_image.png")28 for res in output:29 res.print()30 res.save_to_json(save_path="output")31 res.save_to_markdown(save_path="output")32 with open('PaddlePaddle_PaddleOCR-VL-1.5_0.txt', 'w', encoding='utf-8') as f:33 f.write('Everything was good in PaddlePaddle_PaddleOCR-VL-1.5_0.txt')34except Exception as e:35 import os36 from slack_sdk import WebClient37 client = WebClient(token=os.environ['SLACK_TOKEN'])38 client.chat_postMessage(39 channel='#hub-model-metadata-snippets-sprint',40 text='Problem in <https://huggingface.co/datasets/model-metadata/code_execution_files/blob/main/PaddlePaddle_PaddleOCR-VL-1.5_0.txt|PaddlePaddle_PaddleOCR-VL-1.5_0.txt>',41 )42 43 with open('PaddlePaddle_PaddleOCR-VL-1.5_0.txt', 'a', encoding='utf-8') as f:44 import traceback45 f.write('''```CODE: 46# See https://www.paddleocr.ai/latest/version3.x/pipeline_usage/PaddleOCR-VL.html to installation47 48from paddleocr import PaddleOCRVL49pipeline = PaddleOCRVL(pipeline_version="v1.5")50output = pipeline.predict("path/to/document_image.png")51for res in output:52 res.print()53 res.save_to_json(save_path="output")54 res.save_to_markdown(save_path="output")55```56 57ERROR: 58''')59 traceback.print_exc(file=f)60 61finally:62 from huggingface_hub import upload_file63 upload_file(64 path_or_fileobj='PaddlePaddle_PaddleOCR-VL-1.5_0.txt',65 repo_id='model-metadata/code_execution_files',66 path_in_repo='PaddlePaddle_PaddleOCR-VL-1.5_0.txt',67 repo_type='dataset',68 )69 