{"id":15695875,"url":"https://github.com/pinto0309/snd4onnx","last_synced_at":"2025-05-08T22:30:15.234Z","repository":{"id":57468869,"uuid":"476671483","full_name":"PINTO0309/snd4onnx","owner":"PINTO0309","description":"Simple node deletion tool for onnx.","archived":false,"fork":false,"pushed_at":"2022-09-08T10:48:29.000Z","size":66,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-20T09:39:44.615Z","etag":null,"topics":["cli","model-converter","models","onnx","onnxruntime","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PINTO0309.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}},"created_at":"2022-04-01T10:16:29.000Z","updated_at":"2024-05-08T10:45:25.000Z","dependencies_parsed_at":"2022-09-19T10:10:17.342Z","dependency_job_id":null,"html_url":"https://github.com/PINTO0309/snd4onnx","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PINTO0309%2Fsnd4onnx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PINTO0309%2Fsnd4onnx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PINTO0309%2Fsnd4onnx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PINTO0309%2Fsnd4onnx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PINTO0309","download_url":"https://codeload.github.com/PINTO0309/snd4onnx/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253157466,"owners_count":21863127,"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":["cli","model-converter","models","onnx","onnxruntime","python"],"created_at":"2024-10-03T19:05:16.088Z","updated_at":"2025-05-08T22:30:15.200Z","avatar_url":"https://github.com/PINTO0309.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# snd4onnx\nSimple node deletion tool for onnx. I only test very miscellaneous and limited patterns as a hobby. There are probably a large number of bugs. Pull requests are welcome.\n\nhttps://github.com/PINTO0309/simple-onnx-processing-tools\n\n[![Downloads](https://static.pepy.tech/personalized-badge/snd4onnx?period=total\u0026units=none\u0026left_color=grey\u0026right_color=brightgreen\u0026left_text=Downloads)](https://pepy.tech/project/snd4onnx) ![GitHub](https://img.shields.io/github/license/PINTO0309/snd4onnx?color=2BAF2B) [![PyPI](https://img.shields.io/pypi/v/snd4onnx?color=2BAF2B)](https://pypi.org/project/snd4onnx/) [![CodeQL](https://github.com/PINTO0309/snd4onnx/workflows/CodeQL/badge.svg)](https://github.com/PINTO0309/snd4onnx/actions?query=workflow%3ACodeQL)\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://user-images.githubusercontent.com/33194443/170154412-e5827c3d-88dd-443f-9428-a2e6dfa22c43.png\" /\u003e\n\u003c/p\u003e\n\n## 1. Setup\n\n### 1-1. HostPC\n```bash\n### option\n$ echo export PATH=\"~/.local/bin:$PATH\" \u003e\u003e ~/.bashrc \\\n\u0026\u0026 source ~/.bashrc\n\n### run\n$ pip install -U onnx \\\n\u0026\u0026 python3 -m pip install -U onnx_graphsurgeon --index-url https://pypi.ngc.nvidia.com \\\n\u0026\u0026 pip install -U snd4onnx\n```\n### 1-2. Docker\nhttps://github.com/PINTO0309/simple-onnx-processing-tools#docker\n\n## 2. CLI Usage\n```\n$ snd4onnx -h\n\nusage:\n    snd4onnx [-h]\n    -rn REMOVE_NODE_NAMES [REMOVE_NODE_NAMES ...]\n    -if INPUT_ONNX_FILE_PATH\n    -of OUTPUT_ONNX_FILE_PATH\n    [-n]\n\noptional arguments:\n  -h, --help\n        show this help message and exit.\n\n  -rn REMOVE_NODE_NAMES [REMOVE_NODE_NAMES ...], --remove_node_names REMOVE_NODE_NAMES [REMOVE_NODE_NAMES ...]\n        ONNX node name to be deleted.\n\n  -if INPUT_ONNX_FILE_PATH, --input_onnx_file_path INPUT_ONNX_FILE_PATH\n        Input onnx file path.\n\n  -of OUTPUT_ONNX_FILE_PATH, --output_onnx_file_path OUTPUT_ONNX_FILE_PATH\n        Output onnx file path.\n\n  -n, --non_verbose\n        Do not show all information logs. Only error logs are displayed.\n```\n\n## 3. In-script Usage\n```python\n\u003e\u003e\u003e from snd4onnx import remove\n\u003e\u003e\u003e help(remove)\n\nHelp on function remove in module snd4onnx.onnx_remove_node:\n\nremove(\n    remove_node_names: List[str],\n    input_onnx_file_path: Union[str, NoneType] = '',\n    output_onnx_file_path: Union[str, NoneType] = '',\n    onnx_graph: Union[onnx.onnx_ml_pb2.ModelProto, NoneType] = None,\n    non_verbose: Union[bool, NoneType] = False\n) -\u003e onnx.onnx_ml_pb2.ModelProto\n\n    Parameters\n    ----------\n    remove_node_names: List[str]\n        List of OP names to be deleted.\n        e.g. remove_node_names = ['op_name1', 'op_name2', 'op_name3', ...]\n\n    input_onnx_file_path: Optional[str]\n        Input onnx file path.\n        Either input_onnx_file_path or onnx_graph must be specified.\n\n    output_onnx_file_path: Optional[str]\n        Output onnx file path.\n        If output_onnx_file_path is not specified, no .onnx file is output.\n\n    onnx_graph: Optional[onnx.ModelProto]\n        onnx.ModelProto.\n        Either input_onnx_file_path or onnx_graph must be specified.\n        onnx_graph If specified, ignore input_onnx_file_path and process onnx_graph.\n\n    non_verbose: Optional[bool]\n        Do not show all information logs. Only error logs are displayed.\n        Default: False\n\n    Returns\n    -------\n    removed_graph: onnx.ModelProto\n        OP removed onnx ModelProto.\n```\n\n## 4. CLI Execution\n```bash\n$ snd4onnx \\\n--remove_node_names node_name_a node_name_b \\\n--input_onnx_file_path input.onnx \\\n--output_onnx_file_path output.onnx\n```\n\n## 5. In-script Execution\n```python\nfrom snd4onnx import remove\n\nonnx_graph = remove(\n    remove_node_names=['node_name_a', 'node_name_b'],\n    input_onnx_file_path='input.onnx',\n)\n\n# or\n\nonnx_graph = remove(\n    remove_node_names=['node_name_a', 'node_name_b'],\n    onnx_graph=graph,\n)\n```\n\n## 6. Sample\n### 6-1. sample.1\n|Before|After|\n|:-:|:-:|\n|![test1 onnx](https://user-images.githubusercontent.com/33194443/161254346-cdcf861f-adf6-447e-8a8b-3abe619bf5ee.png)|![test1_removed onnx](https://user-images.githubusercontent.com/33194443/161254523-7f9d2f76-51ea-440d-a06b-7cda475a059d.png)|\n### 6-2. sample.2\n|Before|After|\n|:-:|:-:|\n|![test3 onnx](https://user-images.githubusercontent.com/33194443/161255204-6412469d-68f9-4e92-8cdd-2d6c1ca16b39.png)|![test3_removed onnx](https://user-images.githubusercontent.com/33194443/161255237-24e48064-795f-4ed3-bd31-9ba50b58de93.png)|\n### 6-3. sample.3\n|Before|After|\n|:-:|:-:|\n|![test5 onnx](https://user-images.githubusercontent.com/33194443/161255498-148ab730-bdcc-4140-97fc-010aff0550ef.png)|![test5_removed onnx](https://user-images.githubusercontent.com/33194443/161255532-13d2bfbb-7051-4c46-8025-1e2b6e2c61c5.png)|\n### 6-4. sample.4\n|Before|After|\n|:-:|:-:|\n|![test7 onnx](https://user-images.githubusercontent.com/33194443/161255804-c088a069-c049-4b4b-9e01-1827df9746c5.png)|![test7_removed onnx](https://user-images.githubusercontent.com/33194443/161255996-155eb870-52d7-4694-b2b9-d524d996a671.png)|\n### 6-5. sample.5\n|Before|After|\n|:-:|:-:|\n|![test8 onnx](https://user-images.githubusercontent.com/33194443/161256392-d557322d-b358-4949-bd66-f5e678d131dc.png)|![test8_removed onnx](https://user-images.githubusercontent.com/33194443/161256404-8e20596f-c7c2-4da3-a6b4-9685eda32ff8.png)|\n\n## 7. Reference\n1. https://docs.nvidia.com/deeplearning/tensorrt/onnx-graphsurgeon/docs/index.html\n2. https://github.com/NVIDIA/TensorRT/tree/main/tools/onnx-graphsurgeon\n3. https://github.com/PINTO0309/scs4onnx\n4. https://github.com/PINTO0309/sne4onnx\n5. https://github.com/PINTO0309/snc4onnx\n6. https://github.com/PINTO0309/sog4onnx\n7. https://github.com/PINTO0309/PINTO_model_zoo\n\n## 8. Issues\nhttps://github.com/PINTO0309/simple-onnx-processing-tools/issues\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpinto0309%2Fsnd4onnx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpinto0309%2Fsnd4onnx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpinto0309%2Fsnd4onnx/lists"}