{"id":24503949,"url":"https://github.com/stefanolusardi/resnet-onnx","last_synced_at":"2025-03-15T08:24:17.406Z","repository":{"id":273603924,"uuid":"920163832","full_name":"StefanoLusardi/ResNet-ONNX","owner":"StefanoLusardi","description":"ResNet \u0026 SqueezeNet inference built using ONNX Runtime C++, without OpenCV","archived":false,"fork":false,"pushed_at":"2025-01-21T22:18:10.000Z","size":1904,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-21T22:28:35.810Z","etag":null,"topics":["cmake","computer-vision","cpp","onnx","onnxruntime","resnet","squeezenet"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/StefanoLusardi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2025-01-21T17:12:05.000Z","updated_at":"2025-01-21T22:18:14.000Z","dependencies_parsed_at":"2025-01-21T22:39:06.191Z","dependency_job_id":null,"html_url":"https://github.com/StefanoLusardi/ResNet-ONNX","commit_stats":null,"previous_names":["stefanolusardi/resnet-onnx"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefanoLusardi%2FResNet-ONNX","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefanoLusardi%2FResNet-ONNX/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefanoLusardi%2FResNet-ONNX/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefanoLusardi%2FResNet-ONNX/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StefanoLusardi","download_url":"https://codeload.github.com/StefanoLusardi/ResNet-ONNX/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243704230,"owners_count":20334118,"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":["cmake","computer-vision","cpp","onnx","onnxruntime","resnet","squeezenet"],"created_at":"2025-01-21T23:19:14.068Z","updated_at":"2025-03-15T08:24:17.400Z","avatar_url":"https://github.com/StefanoLusardi.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ResNet-ONNX\nWelcome to ResNet-ONNX!\n\nThis is a project to show how to perform inference on a ResNet or SqueezeNet models using C++.\n\nIn order to simplify dependencies management as well as to improve performance, OpenCV is not required.\n\nThe algorithms contained in [pre_processing.hpp](./src/pre_processing.hpp/) and [post_processing.hpp](./src/post_processing.hpp/) are written in plain C++.\n\nThe only dependency is [stb_image.h](https://github.com/nothings/stb/blob/master/stb_image.h) which is used to load images from disk.\n\n## Getting Started\n\nThis project uses git submodules so it is required to clone it using the *--recurse-submodules* flag in order to retrive the required submodules.\n\n```bash\n# Clone the repo\ngit clone https://github.com/StefanoLusardi/ResNet-ONNX --recurse-submodules\n```\n\nIn order to kickstart this project it is required to configure a local development environment using the provided [scripts](./scripts/).\n\nThe only pre-requisite is to have a recent (i.e. \u003e= 3.8) Python installed on your machine.\n\nThe development environment uses python-virtualenv to create a local environment in which all the project dependencies are installed (exactly as virtual environment is supposed to work for any ordinary Python projects). The virtual environment will be created in the *.venv* folder in the root of the repo.\n\nThird party C++ dependencies will be installed using Conan Package Manager in a local cache folder. The conan cache will be created in the *.conan* folder in the root of the repo.\n\nThese preliminary steps must be done only the first time the project is bootstrapped: afterwards it is only required to activate the virtual environment in order to work with the project itself.\n\n## Create development environment\nIn order to setup a development environment it is sufficient to run the script *scripts/env/setup.\u003cbat|sh\u003e* depending on your operating system.\n\n```bash\n# Linux/MacOS\nchmod +x scripts/env/setup.sh\nscripts/env/setup.sh\n\n# Windows\nscripts\\env\\setup.bat\n```\n\n## Install Python packages\nRun this command into the previously created python virtual environment in order to install the required packages to download, export and validate the Yolo model.\n\n```bash\npip install -r models/requirements.txt\n```\n\n## Download ResNet and SqueezeNet models\nRun these commands to download a pre-trained ResNet and SqueezeNet models from the ONNX Model Zoo repository.\n\n```bash\npython models/download_models.py\n```\n\nAfter these commands you should have *resnet18-v2-7.onnx* and *squeezenet1.1-7.onnx* binaries into the root of your repository. In case you want to retrieve other versions of the binaries it is enough to replace the url into the *models/download_models.py* script.\n\n## Start development environment\nIn order to start the development environment it is sufficient to activate the Python Virtual Environment just created the step above.\n\n```bash\n# Linux/MacOS\nsource .venv/bin/activate\n\n# Windows\n.venv\\Scripts\\activate.bat\n```\n\n## Setup Build Environment (Windows Only)\nWhen building from command line on Windows it is necessary to activate the Visual Studio Developer Command Prompt.\nDepending on the version of Visual Studio compiler and on its install location it is required to run *vcvars64.bat* script the set the development environment properly.\n*Note*: using Visual Studio IDE or the CMake extension for VSCode this step is already managed in the background, so no action is required.\nExamples:\n\n```bash\n# Visual Studio 2022 - Build Tools\n\"C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Auxiliary\\Build\\vcvars64.bat\"\n\n# Visual Studio 2019 - Enterprise\n\"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Auxiliary\\Build\\vcvars64.bat\"\n```\n\n## Setup Dependencies\nInstall the project dependencies as specified in the conanfile.txt.\n```bash\npython scripts/conan/setup.py \u003cDebug|Release\u003e \u003cCOMPILER_NAME\u003e \u003cCOMPILER_VERSION\u003e\n\n# examples:\npython scripts/conan/setup.py Release clang 15\npython scripts/conan/setup.py Debug visual_studio 17\n\n# Visual Studio versions:\n# VS 2019: 16\n# VS 2022: 17\n```\n\n## Build\nRun the following script to configure, build and install the project.\n```bash\npython scripts/cmake.py \u003cDebug|Release\u003e \u003cCOMPILER_NAME\u003e \u003cCOMPILER_VERSION\u003e\n\n# examples:\npython scripts/cmake.py Release clang 15\npython scripts/cmake.py Debug visual_studio 17\n```\n\n## Run\nOnce the project has been installed you can run it using the following command.\n```bash\ninstall/resnet\n```\n\nThis is an example of the expected output using SqueezeNet:\n```bash\nModel: squeezenet1.1-7.onnx\nImage: \"images/dog.jpeg\"\n\nInput: 0\n - name: data\n - shape: 1x3x224x224\n - element type: 1\n\nOutput: 0\n - name: squeezenet0_flatten0_reshape0\n - shape: 1x1000\n - element type: 1\n\nPrediction results:\nID: 232\nLabel: Border collie\nConfidence: 0.886919\n```\n\nThis is an example of the expected output using ResNet:\n```bash\nModel: resnet18-v2-7.onnx\nImage: \"images/dog.jpeg\"\n\nInput: 0\n - name: data\n - shape: 1x3x224x224\n - element type: 1\n\nOutput: 0\n - name: resnetv22_dense0_fwd\n - shape: 1x1000\n - element type: 1\n\nPrediction results:\nID: 232\nLabel: Border collie\nConfidence: 0.871716\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanolusardi%2Fresnet-onnx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstefanolusardi%2Fresnet-onnx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanolusardi%2Fresnet-onnx/lists"}