ivilson / Yolov7net

Yolo Detector for .Net 8
83 stars 25 forks source link

Application - (not responding) #22

Closed jaydubal closed 2 months ago

jaydubal commented 1 year ago

Hello! your library works nicely. However I am facing some issues when looping over images. Say 20 or more.

_yolov8 = new Yolov8("./yolov8n.onnx", false); _yolov8.SetupYoloDefaultLabels();

var imgFiles = info.GetFiles().OrderBy(p => p.CreationTime).ToArray();

foreach (var imgFile in imgFiles) { using var inputImage = Image.FromFile(imgFile.FullName); var items = _yolov8.Predict(inputImage).Where(i => i.Score >= 0.70).ToList();

 // more code goes here....

}

The application is a windows form, .net 6.0. It runs okay when in visual studio debugger. However when running the same compiled EXE alone, out of the visual studio environment.

The applications gets hung "not responding"

Are you aware of any such issues? or differentiation between visual studio debug mode run / and normal exe run?

Thanks!

pjsgsy commented 1 year ago

I don't know the solution to your issue, but I can confirm that I am looping over around 30 frames a second (from a webcam feed), and (after much fiddling, of course), it does work just fine, in and out of VS. I have tested on a separate machine at a remote location. Perfect. So, at least to let you know, with perseverance and good code, it should be possible!

jaydubal commented 1 year ago

Thanks, further checking this I found that Yolov7 is working without any issue, so this may have something to do with Yolov8?

_yolov7 = new Yolov7("./yolov7-tiny.onnx", false); _yolov7.SetupYoloDefaultLabels();

This works, no hanging or non responding issues any!

May be this will provide some feedback.

pjsgsy commented 1 year ago

Yolov8 is actually what I am using, though I did start with and test 7, too

I have this

            yolo8 = new Yolov8(@".\assets\yolov8n.onnx", bgpu); 
            yolo8.SetupYoloDefaultLabels(); 

I run in GPU mode on the desktop, and CPU mode remote on the laptop, so it's probably not related to that, either.

So far, this is the best library I found and I did test a few before I got this all working well with Yolov7

jaydubal commented 1 year ago

Yes the library is very nice, I agree. What is the image w x h, size you are using? in non-gpu mode? thanks.

jaydubal commented 1 year ago

Update: using BackgroundWorker fixed this problem. Thanks :)

jaydubal commented 1 year ago

Hi! can you please suggest which version of Nvidia CUDA library are you using? I keep getting error: (using Microsoft.ML.OnnxRuntime.Gpu 1.14.1 and CUDA v11.6 (PATH is also set as required)

LoadLibrary failed with error 126 "" when trying to load ](onnxruntime::ProviderLibrary::Get [ONNXRuntimeError] : 1 : FAIL : LoadLibrary failed with error 126 "" when trying to load "D:....path....\bin\Debug\net6.0-windows\runtimes\win-x64\native\onnxruntime_providers_cuda.dll")

jaydubal commented 1 year ago

Hi, I was able to get past that error by downloading "cudnn-windows-x86_64-8.5.0.96_cuda11" and adding path to this folder. Now the application runs but it is not able to any inference, and just quits without any exception. Tried with Yolo7, Yolo8 same results.

_inferenceSession.Run(inputs, _model.Outputs); // run inference

This never returns back.

jaydubal commented 1 year ago

What is the minimum GPU " CUDA Capability Major/Minor version number" required?

pjsgsy commented 1 year ago

For info, this is what I am using without issue

nvcc --version nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2021 NVIDIA Corporation Built on Mon_Oct_11_22:11:21_Pacific_Daylight_Time_2021 Cuda compilation tools, release 11.4, V11.4.152 Build cuda_11.4.r11.4/compiler.30521435_0

jaydubal commented 1 year ago

Thanks again!, my old GPU requires "cuda_10.2.89_441.22_win10.exe" and "cudnn-10.2-windows10-x64-v8.0.3.33.zip" capability of gpu is 3.5. And "Microsoft.ML.OnnxRuntime.Gpu" works till 1.6 from: https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html