IntptrMax.YoloSharp
1.1.1
dotnet add package IntptrMax.YoloSharp --version 1.1.1
NuGet\Install-Package IntptrMax.YoloSharp -Version 1.1.1
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.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add IntptrMax.YoloSharp --version 1.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: IntptrMax.YoloSharp, 1.1.1"
#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.
// Install IntptrMax.YoloSharp as a Cake Addin #addin nuget:?package=IntptrMax.YoloSharp&version=1.1.1 // Install IntptrMax.YoloSharp as a Cake Tool #tool nuget:?package=IntptrMax.YoloSharp&version=1.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
YoloSharp
Train Yolo model in C# with TorchSharp. </br> With the help of this project you won't have to transform .pt model to onnx, and can train your own model in C#.
Feature
- Written in C# only.
- Train and predict your own model.
- Support Yolov5, Yolov5u, Yolov8 and Yolov11 now.
- Support Predict and Segment now.
- Support n/s/m/l/x size.
- Support LetterBox and Mosaic4 method for preprocessing images.
- Support NMS with GPU.
- Support Load PreTrained models from ultralytics/yolov5/yolov8 and yolo11 (converted).
Models
You can download yolov5/yolov8 pre-trained models here.
model | n | s | m | l | x |
---|---|---|---|---|---|
yolov5 | yolov5n | yolov5s | yolov5m | yolov5l | yolov5x |
yolov5 | yolov5nu | yolov5su | yolov5mu | yolov5lu | yolov5xu |
yolov8 | yolov8n | yolov8s | yolov8m | yolov8l | yolov8x |
yolov11 | yolov11n | yolov11s | yolov11m | yolov11l | yolov11x |
How to use
You can download the code or add it from nuget.
dotnet add package IntptrMax.YoloSharp --version 1.1.0
In your code you can use it as below.
Predict
You can use it with the code below:
Bitmap inputBitmap = new Bitmap(predictImagePath);
// Create predictor
Predictor predictor = new Predictor(sortCount, yoloType: yoloType, deviceType: deviceType, yoloSize: yoloSize, dtype: dtype);
// Train model
predictor.LoadModel(preTraindModelPath);
predictor.Train(trainDataPath, valDataPath, outputPath: outputPath, batchSize: batchSize, epochs: epochs);
// Predict image
predictor.LoadModel(Path.Combine(outputPath, "best.bin"));
var results = predictor.ImagePredict(inputBitmap, predictThreshold, iouThreshold);
Segment
You can use it with the code below:
// Create segmenter
Segmenter segmenter = new Segmenter(sortCount, yoloType: yoloType, deviceType: deviceType, yoloSize: yoloSize, dtype: dtype);
// Train model
segmenter.LoadModel(preTraindModelPath);
segmenter.Train(trainDataPath, valDataPath, outputPath: outputPath, batchSize: batchSize, epochs: epochs, useMosaic: false);
// Segment image
segmenter.LoadModel("output/best.bin");
Bitmap testBitmap = new Bitmap(predictImagePath);
var (predictResult, bitmap) = segmenter.ImagePredict(testBitmap, predictThreshold, iouThreshold);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Newtonsoft.Json (>= 13.0.3)
- System.Drawing.Common (>= 9.0.0)
- TorchSharp (>= 0.105.0)
- TorchVision (>= 0.105.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.