IntptrMax.YoloSharp 1.1.22

dotnet add package IntptrMax.YoloSharp --version 1.1.22
                    
NuGet\Install-Package IntptrMax.YoloSharp -Version 1.1.22
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="IntptrMax.YoloSharp" Version="1.1.22" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="IntptrMax.YoloSharp" Version="1.1.22" />
                    
Directory.Packages.props
<PackageReference Include="IntptrMax.YoloSharp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add IntptrMax.YoloSharp --version 1.1.22
                    
#r "nuget: IntptrMax.YoloSharp, 1.1.22"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package IntptrMax.YoloSharp@1.1.22
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=IntptrMax.YoloSharp&version=1.1.22
                    
Install as a Cake Addin
#tool nuget:?package=IntptrMax.YoloSharp&version=1.1.22
                    
Install as a Cake Tool

YoloSharp

Train and run YOLO models in pure C# with TorchSharp.
No Python required — from training to inference, everything stays inside .NET.

✨ Features

  • 100% C# implementation – No Python environment, no extra dependencies.
  • Full pipeline support – Train, validate, and predict with your own custom models.
  • Multiple YOLO versions – Supports YOLOv5, YOLOv5u, YOLOv8, YOLOv11, and YOLOv12.
  • All task types – Object detection, segmentation, oriented bounding boxes (OBB), pose estimation (keypoints), and classification.
  • Model sizes – n/s/m/l/x variants available for every architecture.
  • Advanced preprocessing – Built-in LetterBox and Mosaic4 data augmentation.
  • GPU‑accelerated NMS – Non‑maximum suppression runs directly on GPU.
  • Pretrained models – Load models from Ultralytics YOLO (v5/v8/v11) and converted YOLOv12 checkpoints.
  • Cross‑platform – Works with .NET 6 and later.

🤔 Why YoloSharp?

  • No Python environment – Say goodbye to Conda, pip, dependency hell, and version conflicts. Everything runs inside your existing .NET ecosystem.
  • Seamless integration – Directly use C# data structures, LibTorch bindings (TorchSharp),OpenCV bindings (OpenCvSharp), and your .NET logging/tracing infrastructure.
  • Simplified deployment – Package your trained model and inference logic into a single .NET application or container. No separate Python microservice needed.
  • Performance – Harness GPU acceleration via LibTorch and TorchSharp with full control over memory and execution.
  • Productivity – Train and validate models using the same language you use for the rest of your backend, desktop, or game logic. One language, one toolchain.
  • Cost‑effective – Reduce operational overhead by eliminating Python runtimes in production.

Whether you're building a desktop application, a cloud service, or an edge device solution, YoloSharp keeps your stack consistent and maintainable.

🔥 Recent Updates

🚀 Added warm‑up scheduling for stable training start.
🚀 Added rectangle‑resize transform for validation (preserves aspect ratio).
🚀 Added option to disable mosaic augmentation during training.
🚀 Added bias initialization for detection head to improve convergence.
🚀 Replaced CosineAnnealingLR with LambdaLR for more flexible learning rate scheduling.
🐛 Fixed HSV transform implementation.

2026/05/07
🚀 Added data augmentation: horizontal flip, vertical flip, RandomPerspective.
🐛 Fixed Mosaic4 implementation.

2026/03/26
🚀 Added training metrics curves.

2026/03/06
🚀 Configurable training & prediction.
🚀 More metrics for validation.

2026/02/03
🚀 Early stopping.
🚀 HSV transform.
🚀 Training logs.

2026/01/20
🚀 Mixed precision trainer (simple AMP).
🚀 Tqdm support.
🚀 BF16 precision.

📦 Download Pretrained Models

Get the official YOLO checkpoints below.

Prediction Checkpoints

model n s m l x
yolov5 yolov5n yolov5s yolov5m yolov5l yolov5x
yolov5u yolov5nu yolov5su yolov5mu yolov5lu yolov5xu
yolov8 yolov8n yolov8s yolov8m yolov8l yolov8x
yolov11 yolov11n yolov11s yolov11m yolov11l yolov11x

Segmentation Checkpoints

model n s m l x
yolov8 yolov8n-seg yolov8s-seg yolov8m-seg yolov8l-seg yolov8x-seg
yolov11 yolov11n-seg yolov11s-seg yolov11m-seg yolov11l-seg yolov11x-seg

🚀 Getting Started

Install from NuGet

dotnet add package IntptrMax.YoloSharp

You also need to add one of the LibTorch packages (version 2.5.1.0) and OpenCvSharp4.runtime:

  • libtorch-cpu
  • libtorch-cuda-12.1
  • libtorch-cuda-12.1-win-x64
  • libtorch-cuda-12.1-linux-x64

Basic Usage

string preTrainedModelPath = @"..\..\..\Assets\PreTrainedModels\yolov8n-obb.bin"; // Pretrained model path.
string predictImagePath = @"..\..\..\Assets\TestImage\trucks.jpg";
string dataRootPath = @"..\..\..\Assets\datasets\dotav1";

string trainDataPath = @"train.txt";
string valDataPath = @"val.txt";

Mat predictImage = Cv2.ImRead(predictImagePath);

// Create a Yolo config
Config config = new Config
{
    DeviceType = DeviceType.CUDA,
    ScalarType = ScalarType.BFloat16,
    RootPath = dataRootPath,
    TrainDataPath = trainDataPath,
    ValDataPath = valDataPath,
    YoloType = YoloType.Yolov8,
    YoloSize = YoloSize.n,
    TaskType = TaskType.Obb,
    ImageProcessType = ImageProcessType.Mosiac,
    ImageSize = 640,
    BatchSize = 16,
    NumberClass = 15,
    PredictThreshold = 0.3f,
    IouThreshold = 0.7f,
    Workers = 4,
    Epochs = 100,
    LearningRate = 1e-4f,
    Patience = 50,
    KeyPoint_Num = 21,
    KeyPoint_Dim = 3,
};

// Create a yolo task.
YoloTask yoloTask = new YoloTask(config);

// Load pre-trained model. If you don't want to use pre-trained model, skip the step.
yoloTask.LoadModel(preTrainedModelPath, skipNcNotEqualLayers: true);

// Train model
yoloTask.Train();

// Predict image, if the model is not trained or loaded, it will use random weight to predict.
List<YoloResult> predictResult = yoloTask.ImagePredict(predictImage);

📸 Sample Results

Model Output
YOLOv8n (detection) zidane
YOLOv8n‑seg bus
YOLOv8n‑obb trucks
YOLOv8n‑pose tennis

Enjoy YOLO entirely in .NET – no Python needed!
Contributions and feedback are welcome!

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.22 87 5/18/2026
1.1.19 147 3/6/2026
1.1.18 119 2/3/2026
1.1.15 309 11/3/2025
1.1.13 230 10/14/2025
1.1.12 231 10/13/2025
1.1.11 327 5/30/2025
1.1.10 259 5/20/2025