Git Product home page Git Product logo

dme-compunet / yolov8 Goto Github PK

View Code? Open in Web Editor NEW
186.0 9.0 32.0 133.44 MB

Use YOLOv8 in real-time, for object detection, instance segmentation, pose estimation and image classification, via ONNX Runtime.

Home Page: https://www.nuget.org/packages/YoloV8

License: MIT License

C# 100.00%
csharp dotnet image-classification object-detection onnx onnx-runtime pose-estimation ultralytics yolov8 imagesharp

yolov8's People

Contributors

binary-number avatar bnemetchek2 avatar dme-compunet avatar funjoo avatar itbencn avatar kiwibryn avatar penspanic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yolov8's Issues

Multithreaded execution error.

Good afternoon. Multithreaded handling of DetectAsync and Detect in GPU mode causes an error and detection no longer works.

2023-09-24 20:39:41.0146901 [E:onnxruntime:CSharpOnnxRuntime, cuda_call.cc:116 onnxruntime::CudaCall] CUDA failure 700: an illegal memory access was encountered ; GPU=0 ; hostname=DESKTOP-39DKFBQ ; file=D:\a\_work\1\s\onnxruntime\core\providers\cuda\gpu_data_transfer.cc ; line=63 ; expr=cudaMemcpyAsync(dst_data, src_data, bytes, cudaMemcpyHostToDevice, static_cast<cudaStream_t>(stream.GetHandle())); 2023-09-24 20:39:41.0256717 [E:onnxruntime:CSharpOnnxRuntime, cuda_call.cc:116 onnxruntime::CudaCall] CUDA failure 700: an illegal memory access was encountered ; GPU=0 ; hostname=DESKTOP-39DKFBQ ; file=D:\a\_work\1\s\onnxruntime\core\providers\cuda\cuda_execution_provider.cc ; line=409 ; expr=cudaStreamSynchronize(static_cast<cudaStream_t>(stream_)); 2023-09-24 20:39:41.0299946 [E:onnxruntime:CSharpOnnxRuntime, cuda_call.cc:116 onnxruntime::CudaCall] CUDA failure 700: an illegal memory access was encountered ; GPU=0 ; hostname=DESKTOP-39DKFBQ ; file=D:\a\_work\1\s\onnxruntime\core\providers\cuda\gpu_data_tError: Microsoft.ML.OnnxRuntime.OnnxRuntimeException: [ErrorCode:Fail] CUDA failure 700: an illegal memory access was encountered ; GPU=0 ; hostname=DESKTOP-39DKFBQ ; file=D:\a\_work\1\s\onnxruntime\core\providers\cuda\gpu_data_transfer.cc ; line=63 ; exprransfer.cc ; line=63 ; expr=c=cudaMemcpyAsync(dst_data, src_data, bytes, cudaMemcpyHostToDevice, static_cast<cudaStream_t>(stream.GetHandle())); at Microsoft.ML.OnnxRuntime.NativeApiStatus.VerifySuccess(IntPtr nativeStatus) at Microsoft.ML.OnnxRuntime.InferenceSession.RunImpluda(RunOptions options, IntPtr[] inputNames, IntPtr[] inputValues, IntPtr[] outputNames, DisposableList1 cleanupList)
at Microsoft.ML.OnnxRuntime.InferenceSession.Run(IReadOnlyCollection1 inputs, IReadOnlyCollection1 outputNames, RunOptions options)
at Microsoft.ML.OnnxRuntime.InferenceSession.Run(IReadOnlyCollection1 inputs, IReadOnlyCollection1 outputNames)
at Microsoft.ML.OnnxRuntime.InferenceSession.Run(IReadOnlyCollection1 inputs) at Compunet.YoloV8.YoloV8.Run[TResult](ImageSelector selector, PostprocessContext1 postprocess)
at Compunet.YoloV8.YoloV8Extensions.Detect(YoloV8 predictor, ImageSelector selector)
at Compunet.YoloV8.YoloV8Extensions.<>c__DisplayClass5_0.b__0()
at System.Threading.Tasks.Task1.InnerMemcpyAsync(dst_data, src_data, bytes, Invoke() at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.EcudaMemcpyHostToDevice, static_cast<cudaStreaxecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of stack trace from previous location --- at Compunet.YoloV8.YoloV8Extensions.DetectAsync(YoloV8 predictor, ImageSelector selector) at StressTest.DetectService.DetectAsync(String base64Img) in D:\Shared\sharpprogects\VisionSystems\StressTest\DetectService.cs:line 50 at StressTest.Program.<>c__DisplayClass1_0.<<RunTest>b__3>d.MoveNext() in D:\Shared\sharpprogects\VisionSystems\StressTest\Program.cs:line 91 m_t>(stream.GetHandle())); 2023-09-24 20:39:41.0649941 [E:onnxruntime:CSharpOnnxRuntime, cuda_call.cc:116 onnxruntime::CudaCall] CUDA failure 700: an illegal memory access was encountered ; GPU=0 ; hostname=DESKTOP-39DKFBQ ; file=D:\a\_work\1\s\onnxruntime\core\providers\cuda\cuda_execution_provider.cc ; line=409 ; expr=cudaStreamSynchronize(static_cast<cudaStream_t>(stream_));

Error Sequence contains no elements on image plotting

Hello, I'm currently working on my API project using this library.

I use this standard code and it works perfectly fine on my computer.

using Compunet.YoloV8;
using Compunet.YoloV8.Plotting;
using SixLabors.ImageSharp;

var imagePath = "path/to/image";

using var predictor = YoloV8Predictor.Create("path/to/model");

var result = await predictor.DetectAsync(imagePath);

using var image = Image.Load(imagePath);
using var ploted = await result.PlotImageAsync(image);

ploted.Save("./pose_demo.jpg")

but when I deploy it on Cloud Run (Google Cloud Platform) it throws an error:

 System.TypeInitializationException: The type initializer for 'Compunet.YoloV8.Plotting.DetectionPlottingOptions' threw an exception.
 ---> System.InvalidOperationException: Sequence contains no elements
 at System.Linq.ThrowHelper.ThrowNoElementsException()
 at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
 at Compunet.YoloV8.Plotting.PlottingOptions.GetDefaultFontFamily()
 at Compunet.YoloV8.Plotting.PlottingOptions..ctor()
 at Compunet.YoloV8.Plotting.DetectionPlottingOptions..ctor()
 at Compunet.YoloV8.Plotting.DetectionPlottingOptions..cctor()
 --- End of inner exception stack trace ---
 at Compunet.YoloV8.Plotting.DetectionPlottingOptions.get_Default()
 at Compunet.YoloV8.Plotting.PlottingExtensions.PlotImage(DetectionResult result, ImageSelector`1 originImage)
 at Compunet.YoloV8.Plotting.PlottingAsyncOperationExtensions.<>c__DisplayClass2_0.<PlotImageAsync>b__0()
 at System.Threading.Tasks.Task`1.InnerInvoke()
 at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
 --- End of stack trace from previous location ---
 at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
 at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
 --- End of stack trace from previous location ---
 at Compunet.YoloV8.Plotting.PlottingAsyncOperationExtensions.PlotImageAsync(DetectionResult result, Image originImage)
 at Dietary.Controllers.FoodController.Predict(IFormFile imgFile) in /src/Controllers/FoodController.cs:line 65

I know it has something to do with image plotting because without the plot, the predict works perfectly fine.
Or does it have something to do with my docker?

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 8080

ENV ASPNETCORE_URLS=http://+:8080

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["Dietary.csproj", "./"]
RUN dotnet restore "Dietary.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "Dietary.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Dietary.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Dietary.dll"]

Is there a best example of multithreading or WebApi?

Is YoloV8 object thread safe?
As is well known, it is very time-consuming to load the model for the first time. How to efficiently use YoloV8 when making concurrent calls in the form of multithreading or WebApi?
Can you provide some relevant examples or solutions?
For example, is it feasible to use lock or singleton patterns

Getting lower confidence values

I am getting a lower confidence value, Typically lower with the one from python. The model is not OBB.
Even with the image resized to 640x640 or 640 with the same aspect ratio.

Ultralytics YOLOv8.1.20 🚀 Python-3.10.11 torch-2.2.1+cu118 CPU (AMD Ryzen 9 7950X 16-Core Processor)

yolo predict model="...\best.onnx" source="...\cavity.jpg" save_txt=True save_conf=True device=cpu

cavity
resized

.Net 8.0 SDK
YoloV8.GPU 3.1.1

using Compunet.YoloV8;
using Compunet.YoloV8.Plotting;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing;

var image = @"...\cavity.jpg";
var model = @"...\best.onnx";

using var predictor = new YoloV8(model);

using var origin = Image.Load(image);
using var resizedImage = origin.Clone(ctx => ctx.Resize(new ResizeOptions
{
    Size = new Size(640, 640),
    Mode = ResizeMode.Max
}));

var result = await predictor.DetectAsync(origin);
using var plotted = await result.PlotImageAsync(origin);
plotted.Save(Path.Combine("output", Path.GetFileName(image)));

cavity
cavity

So you can test the model yourself
weights.zip

Understanding Yolov8 Task Input and Output Formats in OnnxRuntime

Hello, author. Recently, while using your library for image processing, I've been exploring methods to improve performance. By reviewing code from others on GitHub, I found that using floating-point images and the Threshold method instead of iterating through pixels can indeed enhance speed. For example, OpenCVSharp supports this functionality. The Halcon library, which I use at work, also supports this feature.

So, I convert the image to Tensor<float> using Halcon, and after obtaining the result from OnnxRuntime, I use Halcon again to transform the Tensor<float> result back into a floating-point image for further processing. Following your source code, I successfully replaced ImageSharp with Halcon in the Detection task and achieved a significant performance improvement. However, I encountered several challenges when converting the Segmentation code.

Therefore, I would like to seek your advice on where I can learn about the Yolov8 task's input and output formats in OnnxRuntime. I aim to complete the replacement for the remaining tasks such as segmentation, pose estimation, and classification.

Once again, thank you for your open-source code.

What to do if you can't find a font by its name.

SystemFonts.CreateFont(fontname,fontsize) method cannot be used to find fonts in an environment like Maui Android.
Therefore, the PlottingExtensions.PlotImage method raises a SixLabors.Fonts.FontFamilyNotFoundException.

We believe this can be addressed by allowing Fonts.Font or Stream to specify the font in PlottingOptions. However, we currently cannot resolve this issue without a change to the code.

I thought about sending a pull request for the change, but did not for fear of compromising compatibility.

I would like to know what I need to do and how to address this issue.

Thank you in advance for your help.

Result serialization and deserialization

I need to serialize the prediction results as json and then deserialize them later.

Both newtonsoft and Text.Json don't allow to deserialize IDetectionResult (and ISegmentationResult, etc.) because obviously they don't know the concrete type. The usual solution is to use a converter to "map" the interface to the concrete type, but the problem is that all concrete types are internal.

The easiest solution would be to set those classes as public, but I don't know if there is another mechanism for (de)serialization in the library.

Postprocess takes up too much time

First of all, thank you so much for open-sourcing this repository. I've been looking for an ML.NET implementation of YOLOv8 for a long time and even spent some time trying to understand ML.OnnxRuntime (but I still couldn't grasp it).

I've reviewed your source code, and compared to other open-source repositories, it's much easier for me to understand. However, I did notice an issue: the OutputParser.Parse() method seems to take up too much time. I wonder if there's a way to resolve this.

These are some tests:
CPU - i7-10750H
GPU - RTX2060 Laptop

- Detect - CPU
Image origin size: 2448x2048
imgsz: 640x640
Preprocess: 0.07468 s
Inference: 0.24290 s
Postprocess: 0.54611 s

- Detect - GPU
Image origin size: 2448x2048
imgsz: 640x640
Preprocess: 0.0879 s
Inference: 0.06722 s
Postprocess: 0.34554 s

- Segment - CPU
Image origin size: 3840x2748
imgsz: 800x800
Preprocess: 0.10734 s
Inference: 0.58066 s
Postprocess: 3.99814 s

- Segment - GPU
Image origin size: 3840x2748
imgsz: 800x800
Preprocess: 0.11179 s
Inference: 0.36416 s
Postprocess: 4.10433 s

Inconsistent model results

    static async Task DetectDemo(string image, string outputDirectory, YoloV8 predictor)
    {
        Console.WriteLine();
        Console.WriteLine("================ DETECTION DEMO ================");
        Console.WriteLine();

        Console.WriteLine($"Processing image: {image}");


        Console.WriteLine("Working...");
        using var origin = Image.Load(image);
        using var resizedImage = origin.Clone(ctx => ctx.Resize(new ResizeOptions
        {
            Size = new Size(1280, 1280),
            Mode = ResizeMode.Max
        }));

        Console.WriteLine("Working...");
        var result = await predictor.DetectAsync(resizedImage);

        Console.WriteLine();
        Console.WriteLine($"Result: {result}");
        Console.WriteLine($"Speed: {result.Speed}");
        Console.WriteLine();

        Console.WriteLine("Plotting and saving...");
        // using var origin = Image.Load(image);
        using var plotted = await result.PlotImageAsync(resizedImage);

        var pathToSave = Path.Combine(outputDirectory, Path.GetFileName(image));
        plotted.Save(pathToSave);
    }

Inconsistent model results

Python inference
C # Inference

Two different results
C # is missing

The same goes for scaling images
What should I do ?

Where can I change the iou and conference of the model from the beginning?

Sorry to bother again.
Here is my code:
var predictor = new YoLoV8(modelpath);
predictor.Parameter.IoU = 0.15f;
predictor.Parameter.Confidence = 0.4f.

It works. But can i change the value of iou and conf from the first line: var predictor = new YoLoV8(modelpath, ......)
Can u help me with that, thanks a lot.

Произошла ошибка в обработке клиента onnxruntime_providers_cuda.dll мой проект пробовал на GPU с библиотекой YoloV8.Gpu v4.0.0

Проверил
Checking CUDA availability...
CUDA is available!
NVIDIA GeForce GTX 1080 Ti
но проблема с библиотекой onnxruntime_providers_cuda.dll

Произошла ошибка в обработке клиента: [ErrorCode:RuntimeException] D:\a_work\1\s\onnxruntime\core\session\provider_bridge_ort.cc:1193 onnxruntime::ProviderLibrary::Get [ONNXRuntimeError] : 1 : FAIL : LoadLibrary failed with error 126 "" when trying to load "C:\Users\my\source\repos\test\smg\bin\Debug\net8.0\runtimes\win-x64\native\onnxruntime_providers_cuda.dll

На прошлой версии YoloV8 - 2.0.1 все работало как часы, но так как вышла новая версия YoloV8 - 4.0.0 переписана на .NET 8 я решил обновиться. На CPU работает отлично, а с GPU не хочет. Со своей стороны я уже все что знал перепробовал, не заводится. Может ошибка не у меня, а в самой библиотеке YoloV8.Gpu? Проверьте пожалуйста, очень жду.

Application hangs on Detect() with GPU

Hello, i have a problem trying inference in WPF application

I initializing model like this

SessionOptions options = new SessionOptions();
options.AppendExecutionProvider_CUDA();
model = new YoloV8(yoloOnnxPath, options);

And then launching separated thread to read images

processTask = Task.Run(() => ProcessQueue(cts.Token));
private void ProcessQueue(CancellationToken token)
{
    while (!token.IsCancellationRequested)
    {
        if (queue.TryDequeue(out Mat image))
        {
            Image<Bgr, byte> afterImage = image.ToImage<Bgr, byte>();

            byte[] afterbytes = afterImage.ToJpegData();              
            var result = model?.Detect(afterbytes);
            if (result != null)
            {
                detectionAccumulator.UpdateResult(result);
            }
        }
        else
        {
            Thread.Sleep(10);
        }
    }
}

But on Detect() application hangs with no error.
And system log shows error in cudnn64_8.dll.

I'am using cuda 11.6 and cudnn 8.5.0.96. CPU version works without a problem.

Failed to load model because protobuf parsing failed.

Hi there, just downloaded v1.4.0 of Yolov8 and getting the exception "[ErrorCode:InvalidProtobuf] Failed to load model because protobuf parsing failed." when trying to do classification. Using yolov8x-cls.pt model for .Net6 project. Any help is greatly appreciated.

public IClassificationResult ClassifyObjects(string filePath) { try { using var predictor = new YoloV8(_modelPath); return predictor.Classify(filePath); } catch (Exception ex) { return null; } }

Difference between Python and DotNet

Hi guys !

I notice today I have a different results with my onnx model in python and C#.
Result of my model in python for .pt file and .onnx file
image

Result here in C# with .onnx file
image

As you can see here, i firstly thinking it was the yolov8 export from pt to onnx file, but it's not, because I have the same result in python.

So I ask to myself (and to you ^^) if the yolov8 package can causing this "interference' to the model ?

Thanks for replying ;)

How to use CUDA ?

Hi,

how to use cuda in Yolov8 ? I found it only installed Microsoft.ML.OnnxRuntime by Nuget tool. when I used SessionOptions add cuda, throw a error "Unable to find an entry point named 'OrtSessionOptionsAppendExecutionProvider_CUDA' in DLL 'onnxruntime'."

Results different between python and .net

Hi,

I have a strange issue (like him : #10).

When I test my .onnx model in python, it work's pretty good, but when I try in .net (in the same image), the result is different and false.

Here you can see my result with the model in .pt and the model in .onnx (same result)
image

and when I go in .net, I have this result
image

If anyone has a solution, pls help me ^^

Logic for resizing images to fit the size of the model input data.

Add or change in parameter
Mode = originalAspectRatio ? ResizeMode.Max : ResizeMode.Stretch
method for resizing an image, originalAspectRatio suggests leaving the original size, but in a fluid situation, if the size is 480 x 60, for example, with a model size of 480 x 480, it will stretch the smallest side to fit the size of the model.
Instead of ResizeMode.Max, I think it’s better to change it to ResizeMode.BoxPad or display these settings in the configuration.

Load Image

Cannot use Image or Bitmap, it necessary need to be a path.

It's not really using the GPU

I am using the Yolov8.Gpu package. I was trying to create a webcam stream with object detection in WinForms C#. I got it running and all, but I noticed that in my task manager, it is utilizing the CPU instead of the GPU, which is what I suspect is causing the delay.
image

Model not supported

Hello author, hope you are doing well.

I am currently trying to use the NuGet Package but I am getting some troubles.
I am starting with programming so I´m a bigginer, I used your code reference but I get this: System.InvalidOperationException: 'The loaded model does not support this task' and I do not why, I´ve searched for some solutions but I´m still stuck.
Can you help me out? I´d highly apreciate.
image

Solving problems with multithreading when working with GPU

Good day, to address the issue of model failure in multi-threaded code without losing performance, I suggest wrapping the code segment where
using var outputs = _inference.Run(inputs);
is called in a SemaphoreSlim. In the constructor, accept an optional parameter that initializes SemaphoreSlim when working with GPU. No errors have been observed when working with CPU, and the model does not crash. This method would help increase the performance of the library. At the moment, on GPU in single-threaded mode, it processes 30 images per second. I believe that performance can be increased to even higher values.

Inference with Camera

Hi !

I Actualy trying to do inference with yolo in a Video Stream.
I convert my image in SixLabor.Drawing.Image, and the package doesn't accept it ...
image

According to the README, I only can do inference with an existing file ?
Or I don't convert correctly my source image ?

thank's !

How to enable GPU

微信截图_20240104103827

nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Wed_Sep_21_10:41:10_Pacific_Daylight_Time_2022
Cuda compilation tools, release 11.8, V11.8.89
Build cuda_11.8.r11.8/compiler.31833905_0

I am a beginner in C #
I don't know how to enable GPU

To improve efficiency, it is recommended to consider modifying the Preprocess function.

Here are the main modifications:
Change the input array from 4 columns to 1 column for indices.
Change the loop to a parallel loop.

private Tensor Preprocess(Image image)
{
var modelSize = _metadata.ImageSize;

  var xPadding = 0;
  var yPadding = 0;

  int targetWidth;
  int targetHeight;

  if (_parameters.ProcessWithOriginalAspectRatio)
  {
      var xRatio = (float)modelSize.Width / image.Width;
      var yRatio = (float)modelSize.Height / image.Height;

      var ratio = Math.Min(xRatio, yRatio);

      targetWidth = (int)(image.Width * ratio);
      targetHeight = (int)(image.Height * ratio);

      xPadding = (modelSize.Width - targetWidth) / 2;
      yPadding = (modelSize.Height - targetHeight) / 2;
  }
  else
  {
      targetWidth = modelSize.Width;
      targetHeight = modelSize.Height;
  }

  image.Mutate(x => x.Resize(targetWidth, targetHeight));

  float[] inputArray = new float[image.Width * image.Height * 3];
  var TotalPixel = image.Width * image.Height;
  Parallel.For(0, image.Height, y =>
  {
      image.ProcessPixelRows(row =>
      {
          var pixelSpan = row.GetRowSpan(y);
          int rowOffset = y * image.Width * 3;

          for (int x = 0; x < image.Width; x++)
          {
              var R_offset = y * image.Width + x;
              var G_offset = TotalPixel + y * image.Height + x;
              var B_offset = TotalPixel * 2 + y * image.Width + x;

              inputArray[R_offset] = pixelSpan[x].R / 255f;
              inputArray[G_offset] = pixelSpan[x].G / 255f;
              inputArray[B_offset] = pixelSpan[x].B / 255f;

          }
      });
  });

  var dimensions = new int[] { 1, 3, image.Height, image.Width };
  var input = new DenseTensor<float>(inputArray, dimensions);



  //var dimensions = new int[] { 1, 3, modelSize.Height, modelSize.Width };
  //var input = new DenseTensor<float>(dimensions);

  //image.ForEachPixel((point, pixel) =>
  //{
  //    var x = point.X + xPadding;
  //    var y = point.Y + yPadding;

  //    var r = pixel.R / 255f;
  //    var g = pixel.G / 255f;
  //    var b = pixel.B / 255f;

  //    input[0, 0, y, x] = r;
  //    input[0, 1, y, x] = g;
  //    input[0, 2, y, x] = b;
  //});



  return input;

}

some pictures does not show transparent boxes

This is the image I'm running the model against

Original Image
image

I use this code

using var platesPredictor = YoloV8Predictor.Create(platesModelPath);
var plateResults = platesPredictor.Detect(new ImageSelector(pictureBox3.ToImageSharpImage()));
using SixLabors.ImageSharp.Image detectedPlateImage = pictureBox3.ToImageSharpImage();
pictureBox6.Image = new Bitmap(new MemoryStream(plateResults.PlotImage(detectedPlateImage).ToArray()));

and this is the plotted image

Image after plotting
image

it looks like the boxes are not transparent

I tried to solve it by doing this

using var platesPredictor = YoloV8Predictor.Create(platesModelPath);
var plateResults = platesPredictor.Detect(new ImageSelector(pictureBox3.ToImageSharpImage()));
using SixLabors.ImageSharp.Image detectedPlateImage = pictureBox3.ToImageSharpImage();

var detectionOptions = new DetectionPlottingOptions();
detectionOptions.ColorPalette = new Compunet.YoloV8.Plotting.ColorPalette("ff000010");
detectionOptions.BoxBorderThickness = 1;

pictureBox6.Image = new Bitmap(new MemoryStream(plateResults.PlotImage(detectedPlateImage, detectionOptions).ToArray()));

it plotes this image, but there are no borders nor labels and confidence
image


but the same code(the one without the detectionOptions object) works fine with other pictures
like this one
image

yet the boxes on some other pictures are not transparent

How to get the boxes or mask from the results?

Sorry to bother.
Actually i just know the Python, but recently we are trying to deploy the model to other machine based on C#.
Here is the code:
using var model = new YoloV8(model)
var results = model.Detect(img)
or var results = model.Segment(img)

How can I get the boxes or the mask from the results with the conf and the classfied group ? It is the same like Python code: box = results.Boxes ?
Can you help me with that?
Thanks a lot!

inferred

Hello author, can the model be batch inferred?

There are false positives occurring in the detection task

I have a project about "Identifying Vessels in Ultrasound Imaging", but when using the code from this repository, I encountered false positives. It mistakenly identifies the topmost and bottommost parts of the image as vessels.
001

However, when I predict using the python YOLOv8 or other YOLOv8-C#Onnx repositories, there are no false positives.
002

I can provide test images and the .onnx model ( 331 .jpg images, 1 .onnx file, 170MB). Can you help analyze where the issue might be? I will continue to look into this over the next few days, as I need to push forward with this project.

The image below is from my training dataset. The aforementioned false positives are where the topmost and bottommost parts of the image are identified as this type:
003

Classification

Hi, thanks for your work. Is it possible to support classification?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.