{"id":15293037,"url":"https://github.com/yalue/onnxruntime_go_examples","last_synced_at":"2025-05-07T02:44:29.134Z","repository":{"id":191956898,"uuid":"685752963","full_name":"yalue/onnxruntime_go_examples","owner":"yalue","description":"Example applications using the onnxruntime_go library.","archived":false,"fork":false,"pushed_at":"2024-11-14T13:59:26.000Z","size":123406,"stargazers_count":22,"open_issues_count":1,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-31T05:33:18.706Z","etag":null,"topics":["examples","examples-go","golang","mnist","neural-networks","onnxruntime","onnxruntime-go","pytorch"],"latest_commit_sha":null,"homepage":"","language":"Go","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/yalue.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":"2023-08-31T23:48:11.000Z","updated_at":"2025-03-28T17:09:16.000Z","dependencies_parsed_at":"2023-09-01T18:49:32.519Z","dependency_job_id":"dd1d4373-835c-4695-9ac2-1a6eb64fb565","html_url":"https://github.com/yalue/onnxruntime_go_examples","commit_stats":null,"previous_names":["yalue/onnxruntime_go_examples"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yalue%2Fonnxruntime_go_examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yalue%2Fonnxruntime_go_examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yalue%2Fonnxruntime_go_examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yalue%2Fonnxruntime_go_examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yalue","download_url":"https://codeload.github.com/yalue/onnxruntime_go_examples/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252802695,"owners_count":21806556,"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":["examples","examples-go","golang","mnist","neural-networks","onnxruntime","onnxruntime-go","pytorch"],"created_at":"2024-09-30T16:37:52.312Z","updated_at":"2025-05-07T02:44:29.108Z","avatar_url":"https://github.com/yalue.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"Example Applications for the `onnxruntime_go` Library\n=====================================================\n\nThis repository contains a collection of (mostly) simple standalone examples\nusing the [`onnxruntime_go`](https://github.com/yalue/onnxruntime_go) library\nto run neural-network applications.\n\n\nPrerequisites\n-------------\n\nYou will need to be using a version of Go with cgo enabled---meaning that on\nWindows you'll need to have `gcc` available on your PATH.\n\nIf you wish to use hardware acceleration such as CUDA, you'll need to have a\ncompatible version of the `onnxruntime` library compiled with support for your\nplatform of choice. CoreML should almost always be available on Apple hardware,\nbut other supported acceleration frameworks (e.g., TensorRT or CUDA) may have\nadditional prerequisites, which are documented in\n[the official onnxruntime documentation](https://onnxruntime.ai/docs/execution-providers/).\nNote that not all execution providers supported by `onnxruntime` itself are\nsupported by `onnxruntime_go`.\n\nThe `onnxruntime` shared libraries for some common platforms are included\nunder the `third_party/` directory in this repository.\n\n\nUsage\n-----\n\nNavigate to any one of the subdirectories, and run `go build` to produce an\nexecutable on your system.  Many executables will provide a mechanism for\nspecifying a path to an `onnxruntime` shared library file.  For example:\n\n```bash\ncd sum_and_difference\ngo build\n\n# You can specify any version of the onnxruntime library here, but this would\n# be the correct library version on 64-bit AMD or Intel Linux systems.\n./sum_and_difference --onnxruntime_lib ../third_party/onnxruntime.so\n```\n\nBe aware that different examples may use different mechanisms for locating the\ncorrect shared library version.\n\n\nList of Examples\n----------------\n\n - `sum_and_difference`: This is the simplest example, copied from a unit test\n   in the `onnxruntime_go` library.  It uses a basic neural network (trained\n   using a pytorch script contained in the directory) on a tiny amount of\n   hardcoded data.  The source code is very heavily commented for reference.\n\n - `mnist`: This example runs a CNN trained to identify handwritten digits from\n   the MNIST dataset. It processes a single input image, and outputs the digit\n   it is most likely to contain.\n\n - `mnist_float16`: This example is identical to the plain `mnist` example,\n   except it uses a 16-bit network, including 16-bit inputs and outputs. It is\n   intended to illustrate how to use a float16 `CustomDataTensor`.\n\n - `onnx_list_inputs_and_outputs`: This example prints the inputs and outputs\n   of a user-specified .onnx file to stdout. It is intended to illustrate the\n   usage of the `onnxruntime_go.GetInputOutputInfo` function.\n\n - `image_object_detect`: This example uses the YOLOv8 network to detect a list\n   of objects in an input image. It also attempts to use CoreML if the\n   `USE_COREML` environment variable is set to `true`.\n\n - `non_tensor_outputs`: This example runs a network produced by the `sklearn`\n   python library, which is notable for outputting ONNX `Map` and `Sequence`\n   types. This example is meant to serve as a reference for how users may\n   access `Map` and `Sequence` contents.\n\nContributing and Opening New Issues\n-----------------------------------\n\nPRs with new examples to this repository are welcome.  Each example should be\nin its own subdirectory with its own go.mod file, and include only minimal\ndependencies (i.e., do not include several hundred megabytes of .onnx files or\ndata). Each example should include a README, be formatted using `gofmt`, and\ncontain ample comments to serve as a useful example to other users.\n\nPlease limit open issues in this repository to bugs with existing examples.\nIssues are _not_ a place to request help with `onnxruntime` in general. Such\nissues will be ignored going forward.  If you have not run your `.onnx` network\nusing the `onnxruntime` library in python, this is not the place to get help\nwith it.  Learning to use `onnxruntime` in python is easier than in Go, and\nwill give a point of reference that you understand the network you are trying to\nrun, and that your inputs and outputs are correct.\n\nIn short, this repository is intended to provide examples for using the\n`onnxruntime_go` wrapper in specific.  Users are expected to already understand\n`.onnx` files and how to use `onnxruntime` in general.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyalue%2Fonnxruntime_go_examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyalue%2Fonnxruntime_go_examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyalue%2Fonnxruntime_go_examples/lists"}