{"id":23864522,"url":"https://github.com/ibebbs/huggingfacetoonnx","last_synced_at":"2025-06-27T00:36:17.292Z","repository":{"id":148899573,"uuid":"364047040","full_name":"ibebbs/HuggingFaceToOnnx","owner":"ibebbs","description":"A docker image built to facilitate the export of Hugging Face Transformer Models to ONNX.","archived":false,"fork":false,"pushed_at":"2021-05-04T08:10:50.000Z","size":3,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-07T20:43:45.034Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ibebbs.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-03T20:04:03.000Z","updated_at":"2023-12-19T17:59:33.000Z","dependencies_parsed_at":"2023-07-17T00:15:15.060Z","dependency_job_id":null,"html_url":"https://github.com/ibebbs/HuggingFaceToOnnx","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ibebbs/HuggingFaceToOnnx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibebbs%2FHuggingFaceToOnnx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibebbs%2FHuggingFaceToOnnx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibebbs%2FHuggingFaceToOnnx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibebbs%2FHuggingFaceToOnnx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ibebbs","download_url":"https://codeload.github.com/ibebbs/HuggingFaceToOnnx/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibebbs%2FHuggingFaceToOnnx/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262166180,"owners_count":23268995,"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","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":"2025-01-03T08:26:34.014Z","updated_at":"2025-06-27T00:36:17.271Z","avatar_url":"https://github.com/ibebbs.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HuggingFaceToONNX\n\nA docker image built to facilitate the export of [Hugging Face Transformer Models](https://huggingface.co/models) to ONNX.\n\nUses the `convert_graph_to_onnx.py` tool provided by Hugging Face with parameters passed as part of the docker command line.\n\n## Usage\n\nRun with:\n\n```\ndocker run --rm -v [LocalOutputDirectory]:/Output ibebbs/huggingfacetoonnx:latest --framework [framework] --opset 12 --pipeline [pipeline] --model [model] /Output/[name]\n```\n\nWhere:\n\n* LocalOutputDirectory - The local directory to write the ONNX model to\n* Framework - `pt` or `tf` for PyTorch or Tensorflow respectively\n* Pipeline - The pipeline the model has been trained for; one of: `feature-extraction`, `ner`, `sentiment-analysis`, `fill-mask`, `question-answering`, `text-generation`, `translation_en_to_fr`, `translation_en_to_de`, `translation_en_to_ro`\n* Model - The name of the Hugging Face model to convert to ONNX\n* Name - The name of the output ONNX file\n\nFor example:\n\n```\ndocker run --rm -v ${PWD}/Output:/Output huggingfacetoonnx:latest --framework pt --opset 12 --pipeline ner --model elastic/distilbert-base-cased-finetuned-conll03-english /Output/distilbert-base-cased-finetuned-conll03-english.onnx\n```\n\nWhich will produce the following output:\n\n```\n2021-05-03 16:18:18.295546: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory\n2021-05-03 16:18:18.295629: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.       distilbert-base-cased-finetuned-conll03-english /Output/elastic/distilbert-base-cased-finetuned-conll03-english.onnx\nDownloading: 100%|██████████| 954/954 [00:00\u003c00:00, 697kB/s]                                                                                                        o.11.0: cannot open shared object file: No such file or directory\nDownloading: 100%|██████████| 213k/213k [00:00\u003c00:00, 674kB/s]\nDownloading: 100%|██████████| 112/112 [00:00\u003c00:00, 51.3kB/s]\nDownloading: 100%|██████████| 257/257 [00:00\u003c00:00, 154kB/s]\nDownloading: 100%|██████████| 261M/261M [01:39\u003c00:00, 2.61MB/s]\n/usr/local/lib/python3.9/site-packages/transformers/modeling_utils.py:1789: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!                                                                                                                                                        rect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!\n  assert all(\n\n====== Converting model to ONNX ======\nONNX opset version set to: 12\nLoading pipeline (model: elastic/distilbert-base-cased-finetuned-conll03-english, tokenizer: elastic/distilbert-base-cased-finetuned-conll03-english)\nCreating folder /Output/elastic\nUsing framework PyTorch: 1.8.1+cu102\nFound input input_ids with shape: {0: 'batch', 1: 'sequence'}\nFound input attention_mask with shape: {0: 'batch', 1: 'sequence'}\nFound output output_0 with shape: {0: 'batch', 1: 'sequence'}\nEnsuring inputs are in correct order\nhead_mask is not present in the generated input list.\nGenerated inputs order: ['input_ids', 'attention_mask']\n```\n\n## Hints\n\n1. PyTorch models (`--framework pt`) tend to convert into better ONNX models than Tensorflow (`--framework tf`).\n2. The output directory needs to be empty, the `convert_graph_to_onnx.py` tool will fail.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fibebbs%2Fhuggingfacetoonnx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fibebbs%2Fhuggingfacetoonnx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fibebbs%2Fhuggingfacetoonnx/lists"}