{"id":21900357,"url":"https://github.com/kuroko1t/nne","last_synced_at":"2025-04-15T19:53:53.548Z","repository":{"id":40296946,"uuid":"249374818","full_name":"kuroko1t/nne","owner":"kuroko1t","description":"convert a pytorch model to a model for edge device","archived":false,"fork":false,"pushed_at":"2023-03-15T01:15:35.000Z","size":118,"stargazers_count":21,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-29T00:33:35.792Z","etag":null,"topics":["onnx","pytorch","tensorflow","tensorrt","torchscript"],"latest_commit_sha":null,"homepage":"","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/kuroko1t.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"kuroko1t"}},"created_at":"2020-03-23T08:29:21.000Z","updated_at":"2025-01-24T10:31:06.000Z","dependencies_parsed_at":"2022-08-09T16:44:45.882Z","dependency_job_id":null,"html_url":"https://github.com/kuroko1t/nne","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuroko1t%2Fnne","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuroko1t%2Fnne/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuroko1t%2Fnne/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuroko1t%2Fnne/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kuroko1t","download_url":"https://codeload.github.com/kuroko1t/nne/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249145295,"owners_count":21219966,"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":["onnx","pytorch","tensorflow","tensorrt","torchscript"],"created_at":"2024-11-28T15:07:42.172Z","updated_at":"2025-04-15T19:53:53.511Z","avatar_url":"https://github.com/kuroko1t.png","language":"Python","funding_links":["https://github.com/sponsors/kuroko1t"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg width=\"40%\" src=\"docs/logo.png\" /\u003e\u003c/p\u003e\n\nconvert pytorch model for Edge Device\n\n# nne\ncontents\n\n- [Install](#install)\n- [Example](#Example)\n  - [onnx](#onnx)\n  - [tflite](#tflite)\n  - [tflite(edgetpu)](#tflite-edgetpu)\n  - [TensorRT](#tensorrt)\n- [Script](#Script)\n- [Support Format](#Support-Format)\n- [License](#License)\n\n## Install\n\n```bash\npython -m pip install -e .\n```\n\n* edgetpu\n\nIf you want to compile pytorch model for edgetpu, [install edgetpu_compiler](https://coral.ai/docs/edgetpu/compiler/)\n\n## Example\n\nexample compile pytorch model for edge device. See [example](https://github.com/kuroko1t/nne/tree/master/examples) for details\n\n### onnx\n\ncomvert to onnx model\n\n```python3\nimport nne\nimport torchvision\nimport torch\nimport numpy as np\n\ninput_shape = (1, 3, 64, 64)\nonnx_file = 'resnet.onnx'\nmodel = torchvision.models.resnet34(pretrained=True).cuda()\n\nnne.cv2onnx(model, input_shape, onnx_file)\n```\n\n### tflite\n\ncomvert to tflite model\n\n```python3\nimport torchvision\nimport torch\nimport numpy as np\nimport nne\n\ninput_shape = (10, 3, 224, 224)\nmodel = torchvision.models.mobilenet_v2(pretrained=True).cuda()\n\ntflite_file = 'mobilenet.tflite'\n\nnne.cv2tflite(model, input_shape, tflite_file)\n```\n\n### tflite(edgetpu)\n\ncomvert to tflite model(edge tpu)\n\n```python3\nimport torchvision\nimport torch\nimport numpy as np\nimport nne\n\ninput_shape = (10, 3, 112, 112)\nmodel = torchvision.models.mobilenet_v2(pretrained=True)\n\ntflite_file = 'mobilenet.tflite'\n\nnne.cv2tflite(model, input_shape, tflite_file, edgetpu=True)\n```\n\n### TensorRT\n\nconvert to TensorRT model\n\n```python3\nimport nne\nimport torchvision\nimport torch\nimport numpy as np\n\ninput_shape = (1, 3, 224, 224)\ntrt_file = 'alexnet_trt.pth'\nmodel = torchvision.models.alexnet(pretrained=True).cuda()\nnne.cv2trt(model, input_shape, trt_file)\n```\n\n## Script\n\n* show summary model info\n* dump detailed model information(node name, attrs) to json file.\n* convert onnx model to tflite, simplifier\n\n```bash\n$nne -h\nusage: nne [-h] [-a ANALYZE_PATH] [-s SIMPLYFY_PATH] [-t TFLITE_PATH] model_path\n\nNeural Network Graph Analyzer\n\npositional arguments:\n  model_path            model path for analyzing\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -a ANALYZE_PATH, --analyze_path ANALYZE_PATH\n                        Specify the path to output the Node information of the model in json format.\n  -s SIMPLYFY_PATH, --simplyfy_path SIMPLYFY_PATH\n                        onnx model to simplyfier\n  -t TFLITE_PATH, --tflite_path TFLITE_PATH\n                        onnx model to tflite\n```\n\n## Support Format\n\n|format  | support  |\n|---|---|\n| tflite  | :white_check_mark: |\n| edge tpu  | trial  |\n| onnx| :white_check_mark: |\n| tensorRT| :white_check_mark: |\n\n## License\nApache 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkuroko1t%2Fnne","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkuroko1t%2Fnne","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkuroko1t%2Fnne/lists"}