{"id":13642132,"url":"https://github.com/dme-compunet/YoloSharp","last_synced_at":"2025-04-20T16:30:29.939Z","repository":{"id":176722864,"uuid":"656243336","full_name":"dme-compunet/YoloSharp","owner":"dme-compunet","description":"Use YOLO11 in real-time for object detection tasks 🚀 with edge performance ⚡️ powered by ONNX-Runtime.","archived":false,"fork":false,"pushed_at":"2024-10-31T07:40:38.000Z","size":13509,"stargazers_count":263,"open_issues_count":2,"forks_count":52,"subscribers_count":11,"default_branch":"main","last_synced_at":"2024-10-31T08:25:50.934Z","etag":null,"topics":["csharp","dotnet","image-classification","imagesharp","instance-segmentation","obb","object-detection","onnx-runtime","oriented-object-detection","pose-estimation","ultralytics","yolo","yolo11","yolov10","yolov8"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/YoloSharp","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dme-compunet.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-20T14:41:26.000Z","updated_at":"2024-10-31T07:47:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"876631ef-7f9d-40d6-9b3f-d6aa9277af4e","html_url":"https://github.com/dme-compunet/YoloSharp","commit_stats":null,"previous_names":["dme-compunet/yolov8","dme-compunet/yolosharp"],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dme-compunet%2FYoloSharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dme-compunet%2FYoloSharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dme-compunet%2FYoloSharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dme-compunet%2FYoloSharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dme-compunet","download_url":"https://codeload.github.com/dme-compunet/YoloSharp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223832822,"owners_count":17210721,"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":["csharp","dotnet","image-classification","imagesharp","instance-segmentation","obb","object-detection","onnx-runtime","oriented-object-detection","pose-estimation","ultralytics","yolo","yolo11","yolov10","yolov8"],"created_at":"2024-08-02T01:01:27.904Z","updated_at":"2025-04-20T16:30:29.931Z","avatar_url":"https://github.com/dme-compunet.png","language":"C#","funding_links":[],"categories":["Other Versions of YOLO"],"sub_categories":[],"readme":"# YoloSharp\n\n🚀 Use [YOLO11](https://github.com/ultralytics/ultralytics) in real-time for object detection tasks, with edge performance ⚡️ powered by ONNX-Runtime.\n\n# Features\n\n- **YOLO Tasks** 🌟 Support for all YOLO vision tasks ([Detect](https://docs.ultralytics.com/tasks/detect) | [OBB](https://docs.ultralytics.com/tasks/obb) | [Pose](https://docs.ultralytics.com/tasks/pose) | [Segment](https://docs.ultralytics.com/tasks/segment) | [Classify](https://docs.ultralytics.com/tasks/classify))\n- **High Performance** 🚀 Various techniques and use of .NET features to maximize performance\n- **Reduced Memory Usage** 🧠 By reusing memory blocks and reducing the pressure on the GC\n- **Plotting Options** ✏️ Draw the predictions on the target image to preview the model results\n- **YOLO Versions** 🔧 Includes support for: [YOLOv8](https://docs.ultralytics.com/models/yolov8) [YOLOv10](https://docs.ultralytics.com/models/yolov10) [YOLO11](https://docs.ultralytics.com/models/yolo11)\n\n# Installation\n\nThis project provides two NuGet packages:\n\n- For CPU inference, use the package: [YoloSharp](https://www.nuget.org/packages/YoloSharp) (includes the [Microsoft.ML.OnnxRuntime](https://www.nuget.org/packages/Microsoft.ML.OnnxRuntime) package)\n- For GPU inference, use the package: [YoloSharp.Gpu](https://www.nuget.org/packages/YoloSharp.Gpu) (includes the [Microsoft.ML.OnnxRuntime.Gpu](https://www.nuget.org/packages/Microsoft.ML.OnnxRuntime.Gpu) package)\n\n# Usage\n\n### 1. Export model to ONNX format:\n\nFor convert the pre-trained PyTorch model to ONNX format, run the following Python code:\n\n```python\nfrom ultralytics import YOLO\n\n# Load a model\nmodel = YOLO('path/to/best.pt')\n\n# Export the model to ONNX format\nmodel.export(format='onnx')\n```\n\n### 2. Load the ONNX model with C#:\n\nAdd the `YoloSharp` (or `YoloSharp.Gpu`) package to your project:\n\n```shell\ndotnet add package YoloSharp\n```\n\nUse the following C# code to load the model and run basic prediction:\n\n```csharp\nusing Compunet.YoloSharp;\n\n// Load the YOLO predictor\nusing var predictor = new YoloPredictor(\"path/to/model.onnx\");\n\n// Run model\nvar result = predictor.Detect(\"path/to/image.jpg\");\n// or\nvar result = await predictor.DetectAsync(\"path/to/image.jpg\");\n\n// Write result summary to terminal\nConsole.WriteLine(result);\n```\n\n# Plotting\n\nYou can to plot the target image for preview the model results, this code demonstrates how to run a inference, plot the results on image and save to file:\n\n```csharp\nusing Compunet.YoloSharp;\nusing Compunet.YoloSharp.Plotting;\nusing SixLabors.ImageSharp;\n\n// Load the YOLO predictor\nusing var predictor = new YoloPredictor(\"path/to/model.onnx\");\n\n// Load the target image\nusing var image = Image.Load(\"path/to/image\");\n\n// Run model\nvar result = await predictor.PoseAsync(image);\n\n// Create plotted image from model results\nusing var plotted = await result.PlotImageAsync(image);\n\n// Write the plotted image to file\nplotted.Save(\"./pose_demo.jpg\");\n```\n\nYou can also predict and save to file in one operation:\n\n```csharp\nusing Compunet.YoloSharp;\nusing Compunet.YoloSharp.Plotting;\nusing SixLabors.ImageSharp;\n\n// Load the YOLO predictor\nusing var predictor = new YoloPredictor(\"path/to/model.onnx\");\n\n// Run model, plot predictions and write to file\npredictor.PredictAndSaveAsync(\"path/to/image\");\n```\n\n## Example Images:\n\n#### Detection:\n\n![detect-demo!](https://raw.githubusercontent.com/dme-compunet/YoloSharp/main/Assets/detect-demo.jpg)\n\n#### Pose:\n\n![pose-demo!](https://raw.githubusercontent.com/dme-compunet/YoloSharp/main/Assets/pose-demo.jpg)\n\n#### Segmentation:\n\n![seg-demo!](https://raw.githubusercontent.com/dme-compunet/YoloSharp/main/Assets/seg-demo.jpg)\n\n# Not Supported:\n\nThe following features are not currently supported, they may be added later\n\n- **Batch Processing:** You have to predict them one by one\n- **Dynamic Size:** The image resized according to `imgsz`\n\n# License\n\nAGPL-3.0 License\n\n**Important Note:** This project depends on ImageSharp, you should check the license details [here](https://github.com/SixLabors/ImageSharp/blob/main/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdme-compunet%2FYoloSharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdme-compunet%2FYoloSharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdme-compunet%2FYoloSharp/lists"}