{"id":20988356,"url":"https://github.com/ikomia-dev/onnx-donut","last_synced_at":"2025-10-12T01:46:32.504Z","repository":{"id":208279093,"uuid":"716167802","full_name":"Ikomia-dev/onnx-donut","owner":"Ikomia-dev","description":"Export Donut model to onnx and run it with onnxruntime","archived":false,"fork":false,"pushed_at":"2023-11-21T10:26:13.000Z","size":29,"stargazers_count":23,"open_issues_count":1,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-14T18:52:32.086Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ikomia-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-11-08T15:22:06.000Z","updated_at":"2025-02-28T22:56:37.000Z","dependencies_parsed_at":"2023-11-20T18:03:37.928Z","dependency_job_id":null,"html_url":"https://github.com/Ikomia-dev/onnx-donut","commit_stats":null,"previous_names":["ikomia-dev/onnx-donut"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Ikomia-dev/onnx-donut","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ikomia-dev%2Fonnx-donut","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ikomia-dev%2Fonnx-donut/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ikomia-dev%2Fonnx-donut/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ikomia-dev%2Fonnx-donut/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ikomia-dev","download_url":"https://codeload.github.com/Ikomia-dev/onnx-donut/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ikomia-dev%2Fonnx-donut/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279009794,"owners_count":26084648,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-19T06:20:25.354Z","updated_at":"2025-10-12T01:46:32.481Z","avatar_url":"https://github.com/Ikomia-dev.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Onnx Donut\n\nPackage to export a [Donut](https://github.com/clovaai/donut) model from pytorch to ONNX, then run it with onnxruntime.\n\n## Installation\n\n```shell\npip install onnx-donut\n```\n\n## Export to onnx\n\n```python\nfrom onnx_donut.exporter import export_onnx\nfrom onnx_donut.quantizer import quantize\n\n# Hugging Face model card or folder\nmodel_path = \"naver-clova-ix/donut-base-finetuned-docvqa\"\n\n# Folder where the exported model will be stored\ndst_folder = \"converted_donut\"\n\n# Export from Pytorch to ONNX\nexport_onnx(model_path, dst_folder, opset_version=16)\n\n# Quantize your model to int8\nquantize(dst_folder, dst_folder + \"_quant\")\n\n```\n\n## Model inference with onnxruntime\n\n```python\nfrom onnx_donut.predictor import OnnxPredictor\nimport numpy as np\nfrom PIL import Image\n\n# Image path to run on\nimg_path = \"/path/to/your/image.png\"\n\n# Folder where the exported model will be stored\nonnx_folder = \"converted_donut\"\n\n# Read image\nimg = np.array(Image.open(img_path).convert('RGB'))\n\n# Instantiate ONNX predictor\npredictor = OnnxPredictor(model_folder=onnx_folder)\n\n# Write your prompt accordingly to the model you use\nprompt = f\"\u003cs_docvqa\u003e\u003cs_question\u003ewhat is the title?\u003c/s_question\u003e\u003cs_answer\u003e\"\n\n# Run prediction\nout = predictor.generate(img, prompt)\n\n# Display prediction\nprint(out)\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fikomia-dev%2Fonnx-donut","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fikomia-dev%2Fonnx-donut","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fikomia-dev%2Fonnx-donut/lists"}