devMobile's blog

Random wanderings through Microsoft Azure esp. PaaS plumbing, the IoT bits, AI on Micro controllers, AI on Edge Devices, .NET nanoFramework, .NET Core on *nix and ML.NET+ONNX

Menu

Skip to content
  • Home
  • About
  • Things that make me happy

Tag Archives: Yolo V11

YoloDotNet NuGet on a diet – Part 1

Posted on October 30, 2024 by devmobilenz

Several of my projects use the NickSwardh/YoloDotNet NuGet which supports NVIDIA CUDA but not TensorRT. The first step before “putting the NuGet on a diet” was to fix up my test application because some of the method signatures had changed in the latest release.

// load the app settings into configuration
var configuration = new ConfigurationBuilder()
   .AddJsonFile("appsettings.json", false, true)
   .Build();

_applicationSettings = configuration.GetSection("ApplicationSettings").Get<Model.ApplicationSettings>();

Console.WriteLine($" {DateTime.UtcNow:yy-MM-dd HH:mm:ss.fff} YoloV8 Model load start : {_applicationSettings.ModelPath}");

//using (var predictor = new Yolo(_applicationSettings.ModelPath, false))
using var yolo = new Yolo(new YoloOptions()
{
   OnnxModel = _applicationSettings.ModelPath,
   Cuda = false,
   PrimeGpu = false,
   ModelType = ModelType.ObjectDetection,
});
{
   Console.WriteLine($" {DateTime.UtcNow:yy-MM-dd HH:mm:ss.fff} YoloV8 Model load done");
   Console.WriteLine();

   //using (var image = await SixLabors.ImageSharp.Image.LoadAsync<Rgba32>(_applicationSettings.ImageInputPath))
   using (var image = SKImage.FromEncodedData(_applicationSettings.ImageInputPath))
   {
      Console.WriteLine($" {DateTime.UtcNow:yy-MM-dd HH:mm:ss.fff} YoloV8 Model detect start");

      var predictions = yolo.RunObjectDetection(image);

      Console.WriteLine($" {DateTime.UtcNow:yy-MM-dd HH:mm:ss.fff} YoloV8 Model detect done");
      Console.WriteLine();

      foreach (var predicition in predictions)
      {
         Console.WriteLine($"  Class {predicition.Label.Name} {(predicition.Confidence * 100.0):f1}% X:{predicition.BoundingBox.Location.X} Y:{predicition.BoundingBox.Location.Y} Width:{predicition.BoundingBox.Width} Height:{predicition.BoundingBox.Height}");
      }
      Console.WriteLine();

      Console.WriteLine($" {DateTime.UtcNow:yy-MM-dd HH:mm:ss.fff} Plot and save : {_applicationSettings.ImageOutputPath}");

      using (SKImage skImage = image.Draw(predictions))
      {
         //await image.SaveAsJpegAsync(_applicationSettings.ImageOutputPath);
         skImage.Save(_applicationSettings.ImageOutputPath, SKEncodedImageFormat.Jpeg);
      }
   }
}

While testing I found the application worked with the sample Ultralytics YoloV8 ONNX models but failed with my Ultralytics Hub trained models.

The YoloDotNet code was looking for specific text in the model description which wasn’t present in the description of my Ultralytics Hub trained models.

I downloaded the YoloDotNet source and included the core project in my solution so I could temporarily modify the GetModelVersion method in OnnxPropertiesExtension.cs.

 /// <summary>
 /// Get ONNX model version
 /// </summary>
 private static ModelVersion GetModelVersion(string modelDescription) => modelDescription.ToLower() switch
 {
     var version when version.Contains("yolo") is false => ModelVersion.V8,
    var version when version.Contains("yoloV8") is false => ModelVersion.V8, // <========
    var version when version.StartsWith("ultralytics yolov8") => ModelVersion.V8,
     var version when version.StartsWith("ultralytics yolov9") => ModelVersion.V9,
     var version when version.StartsWith("ultralytics yolov10") => ModelVersion.V10,
     var version when version.StartsWith("ultralytics yolo11") => ModelVersion.V11, // Note the missing v in Yolo11
     var version when version.Contains("worldv2") => ModelVersion.V11,
     _ => throw new NotSupportedException("Onnx model not supported!")
 };

After getting the test application running in the Visual Studio 2022 debugger it looked like the CustomMetadata Version info would be a better choice.

To check my assumption, I inspected some of the sample ONNX Model properties with Netron.

YoloV8s model 8.1.1
YoloV10s Model – 8.2.5.1

It looks like the CustomMetadata Version info increments but doesn’t nicely map to the Ultralytics Yolo version.

Posted in .Net Core, .Net Standard 2.0 | Tagged .Net, .Net Core, C#, CustomMetadata, Netron, NuGet, SixLabors, SkiaSharp, ultralytics, Yolo V10, Yolo V11, Yolo V8, Yolo V9, YoloV10, YoloV11, YoloV8, YoloV9 | Leave a comment

Recent Posts

  • Arduino RS485 500cm Ultrasonic Level Sensor
  • Azure Event Grid esp-mqtt-arduino Client – Success
  • Azure Event Grid esp-mqtt-arduino Client – Finding fail
  • Azure Event Grid esp-mqtt-arduino Client – Hours of fail
  • Arduino MQTT V5 Side quest – Discovery withWolfMQTT

Archives

  • December 2025
  • November 2025
  • June 2025
  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • July 2024
  • June 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • July 2019
  • June 2019
  • May 2019
  • April 2019
  • March 2019
  • February 2019
  • January 2019
  • December 2018
  • November 2018
  • September 2018
  • August 2018
  • July 2018
  • June 2018
  • May 2018
  • April 2018
  • March 2018
  • February 2018
  • January 2018
  • December 2017
  • September 2017
  • August 2017
  • July 2017
  • February 2017
  • September 2016
  • August 2016
  • July 2016
  • June 2016
  • May 2016
  • April 2016
  • March 2016
  • February 2016
  • January 2016
  • December 2015
  • November 2015
  • October 2015
  • September 2015
  • August 2015
  • July 2015
  • June 2015
  • May 2015
  • April 2015
  • March 2015
  • February 2015
  • January 2015
  • December 2014
  • November 2014
  • October 2014
  • September 2014
  • August 2014
  • July 2014
  • June 2014
  • May 2014
  • April 2014
  • March 2014
  • February 2014
  • January 2014
  • December 2013
  • November 2013
  • October 2013
  • September 2013
  • August 2013
  • July 2013
  • June 2013
  • May 2013
  • April 2013
  • March 2013
  • February 2013
  • January 2013
  • December 2012
  • November 2012
  • October 2012
  • September 2012

Categories

  • .Net
  • .Net Core
  • .NET MF
  • .NET NF
  • .Net Standard 2.0
  • Adafruit
  • Adafruit.IO
  • AllThingsTalk
  • AMQP
  • AMQPNetLite
  • App Service
  • Application Insights
  • Arduino
  • Armtronix
  • AskSensors
  • ASP Net Core
  • ASP.NET
  • ASP.NET Core Identity
  • Azure
  • Azure Device Provisioning Service
  • Azure Digital Twins
  • Azure Event Grid
  • Azure Event Hub
  • Azure Functions
  • Azure IoT Central
  • Azure IoT Hub
  • Azure Machine Learning
  • Azure Percept
  • Azure Service Bus
  • Azure Storage
  • AzureMeetup
  • AzureMeetup2018May
  • AzureSBLite
  • Boros
  • BoschIoTSuite
  • Bumblebee hive
  • ceech
  • CodeCamp
  • CodeClub
  • Cognitive Services
  • Copilot
  • CORS
  • Crazyflie
  • Crypto
  • Dapper
  • devDuino
  • DFRobot
  • Diagnostics
  • Diagnostics
  • Downlink
  • Dragino
  • easysensors
  • ECAN
  • Education
  • elecfreaks
  • elecrow
  • Electric Longboard
  • electronictricks
  • Enterprise Library
  • EVCamp
  • Event Grid
  • Event Hub
  • Events
  • evolocity
  • FEZ Cobra III
  • FEZ Lemur
  • FEZ Panada III
  • FEZ Spider
  • FieldGateway
  • Functions
  • Gadgeteer
  • GET
  • GHI Electronics
  • GIS
  • GitHub
  • GPRS
  • GPS
  • GPSTracker
  • HEAD
  • HTTP
  • ingenuitymicro
  • Internet of Things
  • IoT
  • IoT Central
  • IoT HUb
  • IoTMCU
  • iteadstudio
  • KeyVault
  • Linux
  • LoRa
  • LoRaWAN
  • Losant
  • LowPowerLab
  • M2M
  • Machine Learning
  • Magician robot
  • MakerFabs
  • Mapping
  • Mashup
  • Mashup 2014
  • Microsoft
  • MikroBus.Net
  • ML.Net
  • mqtt
  • MSIgnite
  • MSIgnite2015
  • MSIgnite2017AU
  • myriota
  • NanoFramework
  • Netduino
  • Netduino3wifi
  • NetMF
  • NetMF Toolbox
  • Networking
  • nrf24l01
  • ONNX
  • onvif
  • OpenAPI
  • OPTIONS
  • Payload Formatters
  • Percept
  • Performance
  • pollution
  • POST
  • Qorvo
  • Quadcopter
  • quail
  • QuakeZure
  • QuakeZure backoffice
  • QuakeZure client
  • QuakeZure sensors
  • RAKWireless
  • RaspberryPI
  • RFM69HCW
  • Robotics
  • Security
  • SeeedStudio
  • SeegelSysteme
  • SensingCity
  • Sensors
  • Service Bus
  • ServiceBus
  • SmartWorks
  • Sparkfun
  • Spatial
  • SQL Azure
  • SQL Server
  • STMicroelectronics
  • Storage
  • Swagger
  • Swarm Space
  • TechEd
  • TechEd2012
  • TechEd2014
  • TechEd2015
  • The Things Industries
  • The Things Network
  • The Things Stack
  • ThingsBoards
  • ThingSpeak
  • Tindie
  • TinyCLR
  • ubidots
  • Uncategorized
  • Uplink
  • uputronics
  • Vision
  • Web services
  • Webjobs
  • WildernessLabs
  • Windows10IoTCore
  • Wireless
  • Wisen
  • wolkabout
  • xively
Blog at WordPress.com.
  • Subscribe Subscribed
    • devMobile's blog
    • Join 78 other subscribers
    • Already have a WordPress.com account? Log in now.
    • devMobile's blog
    • Subscribe Subscribed
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar
 

Loading Comments...