ivilson / Yolov7net

Yolo Detector for .Net 8
90 stars 27 forks source link

[bug] Yolov8 prediction labels missing #11

Closed ev-dev closed 1 year ago

ev-dev commented 1 year ago

Hey great work adding some initial support for the yolov8 series!

I started messing around with your latest nuget release and noticed that the prediction labels are null unless I specified true for the NumSharp parameter.

But setting param to true does produce a different problem which is that it only ever returns 1 prediction/label (the first one, the same 1st prediction that would show without the NumSharp option)

I can provide more details if it helps, but here's what I'm seeing when I mess around in powershell:

Add-Type -AssemblyName "$DEPS_ROOT\Microsoft.ML.OnnxRuntime.Managed.1.14.0\lib\net6.0\Microsoft.ML.OnnxRuntime.dll"
Add-Type -AssemblyName "$DEPS_ROOT\NumSharp.0.30.0\lib\netstandard2.0\NumSharp.dll"
Add-Type -AssemblyName "$DEPS_ROOT\IVilson.AI.Yolov7net.1.0.3\lib\net6.0\IVilson.AI.Yolov7net.dll"

$y8client = [IVilson.AI.Yolov7net.Yolov8]::new($MODEL_PATH)
$y8client.SetupYoloDefaultLabels()

$img = [System.Drawing.Image]::FromFile($IMG_PATH)

$y8client.Predict($img) 

<# Returns with null Label property ->

Label Rectangle                                                 Score
----- ---------                                                 -----
      {X=726.8968,Y=1456.7361,Width=953.0971,Height=2573.4204}   0.93
      {X=1223.8837,Y=1089.3862,Width=884.0172,Height=2938.6584}  0.91
#>

$y8client.Predict($img, 0, 0, $true)

<# When NumSharp param is true, returns with only first prediction ->

Label               Rectangle                                               Score
-----               ---------                                               -----
Yolov7net.YoloLabel {X=923.1725,Y=1456.7361,Width=714.823,Height=2573.4204}  0.93
#>

I'll try poking around at the new updates in the source code to see when I can figure out but just wanted to see if you might know what's happening here, thanks again!

Kayzwer commented 1 year ago

the label attribute is not assign into the YoloPrediction class when initializing, simply modify the Yolov8.cs file to solve it

yiyueming commented 1 year ago

How to modify the Yolov8.cs file?

iwaitu commented 1 year ago

this bug was fixed. https://github.com/ivilson/Yolov7net/commit/73c4c0ca3df225d84c745bb5f0befa8c39fb23f2

pjsgsy commented 1 year ago

For info, This bug still seems to be in the nuget version. Perhaps this latest code was not released via nuget?

pjsgsy commented 1 year ago

I compiled the latest version from source. All I can say, is, WOW! The bug is fixed, but, also, performance is significantly better!

If anyone else is reading this - Get the source and compile it yourself. It is easy. Do not use the older nuget package until it is updated.

Author : Great job!