{"id":31363837,"url":"https://github.com/mrnhtyzgld/onnx_cpp_inference","last_synced_at":"2026-05-19T10:01:18.753Z","repository":{"id":315594985,"uuid":"1060136254","full_name":"mrnhtyzgld/onnx_cpp_inference","owner":"mrnhtyzgld","description":"C++ demo that loads a model, reads an image and a mask, runs inference, and saves the result as a PNG with a timestamped filename. Works with single-image input and supports either 1-channel or 3-channel outputs.","archived":false,"fork":false,"pushed_at":"2025-09-19T13:32:12.000Z","size":904,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-19T14:56:53.262Z","etag":null,"topics":["cpp","inference","onnx"],"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/mrnhtyzgld.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-19T12:44:40.000Z","updated_at":"2025-09-19T13:32:16.000Z","dependencies_parsed_at":"2025-09-19T15:06:59.958Z","dependency_job_id":null,"html_url":"https://github.com/mrnhtyzgld/onnx_cpp_inference","commit_stats":null,"previous_names":["mrnhtyzgld/onnx_cpp_inference"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/mrnhtyzgld/onnx_cpp_inference","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrnhtyzgld%2Fonnx_cpp_inference","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrnhtyzgld%2Fonnx_cpp_inference/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrnhtyzgld%2Fonnx_cpp_inference/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrnhtyzgld%2Fonnx_cpp_inference/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrnhtyzgld","download_url":"https://codeload.github.com/mrnhtyzgld/onnx_cpp_inference/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrnhtyzgld%2Fonnx_cpp_inference/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277184144,"owners_count":25775286,"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-09-27T02:00:08.978Z","response_time":73,"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":["cpp","inference","onnx"],"created_at":"2025-09-27T05:23:13.635Z","updated_at":"2025-09-27T05:23:14.473Z","avatar_url":"https://github.com/mrnhtyzgld.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ONNX Runtime + OpenCV Inference (LaMa) — C++ Mini Demo\n\nSmall C++ example that loads a model, reads an image and a mask, runs inference, and saves the result as a timestamped PNG. Works with single-image input and supports either 1-channel or 3-channel outputs.\n\n## Prerequisites\n- C++\n- OpenCV (core, imgcodecs, dnn)\n- ONNX Runtime (C++ API)\n\n## Features\n\n- Minimal single-file C++ demo\n- Image + mask preprocessing with OpenCV `blobFromImage`\n- Zero-copy tensor wrapping for inputs\n- ONNX Runtime inference with graph optimizations\n- Output handling for `C=1` (grayscale) and `C=3` (color)\n- Safe float→8-bit scaling and PNG export (timestamped)\n- Basic input/output shape logging and validation\n- Error handling with detailed ORT exception messages\n\n## Build\nEnsure CMake can locate both OpenCV and ONNX Runtime. If ONNX Runtime isn’t globally discoverable, pass `-Donnxruntime_DIR=/path/to/onnxruntime/cmake` (directory containing `onnxruntime-config.cmake`). For OpenCV, pass `-DOpenCV_DIR=/path/to/opencv`.\n\n```bash\nmkdir -p build \u0026\u0026 cd build\ncmake -DCMAKE_BUILD_TYPE=Release \\\n      -Donnxruntime_DIR=/path/to/onnxruntime/cmake \\\n      -DOpenCV_DIR=/path/to/opencv ..\ncmake --build . --config Release\n```\n\n\n## Run\n\nPlace files here:\n\n```\n./models/lama_fp32.onnx\n\n./images/input_image.jpg\n\n./images/dilated_mask.png\n```\nThen run:\n```\n./onnx_inference\n```\n\nConsole will print input/output shapes and save PNG(s) under \"./outputs/\" with names like:\n```\noutput_HHMMSS_0.png\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrnhtyzgld%2Fonnx_cpp_inference","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrnhtyzgld%2Fonnx_cpp_inference","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrnhtyzgld%2Fonnx_cpp_inference/lists"}