SamSamhuns / yolov5_export_cpu

Exporting YOLOv5 for CPU inference with ONNX and OpenVINO
MIT License
35 stars 9 forks source link

yolov5版本 #1

Open miaochenGuo opened 3 years ago

miaochenGuo commented 3 years ago

请问这里使用的yolov5版本是多少呢?

SamSamhuns commented 3 years ago

The export is version agnostic working with any yolov5 version. Although using anything larger than yolov5s, the FPS would be very low (< 5).

tino926 commented 3 years ago

@SamSamhuns In my testing, with both yolov5-4.0 and yolov5-5.0 release version, I got wrong results. For example, with the .onnx model, I go such result: image

With the openvino model, I got no bounding box on the result image, although some detected objects are shown in the terminal

bbox: [5. 0. 2. 0.] conf: 6.8569436 class: person   
bbox: [0. 0. 0. 0.] conf: 6.55484 class: person                                               
bbox: [3. 0. 4. 0.] conf: 6.3061295 class: person                                                                             
bbox: [0. 0. 0. 0.] conf: 5.994316 class: person                    
bbox: [1. 0. 6. 0.] conf: 5.759716 class: person     
bbox: [0. 0. 0. 0.] conf: 5.430946 class: person                                                                                 
bbox: [0. 0. 0. 0.] conf: 5.044397 class: sports ball             
bbox: [0. 0. 0. 0.] conf: 4.5600634 class: sports ball                                                                          
bbox: [0. 0. 0. 0.] conf: 4.388424 class: sports ball          
bbox: [ 5.  0. 10.  0.] conf: 3.1240857 class: sports ball           
bbox: [7. 0. 9. 0.] conf: 2.7049701 class: sports ball        
bbox: [9. 0. 7. 0.] conf: 2.6434095 class: sports ball    

Your method works perfect with the latest commit (https://github.com/ultralytics/yolov5/tree/3e7c59ad3bf5414d4b2a26e018f397e27a51c6f1)

Do you know what is the cause of the problem? Does the export.py from earlier versions have some bugs?

SamSamhuns commented 3 years ago

@tino926, hmm I think the issue is that there are many changes in the main yolov5 repo which might have unforeseen consequences for the exports and other format inference.

This repo was working with the commit you mentioned then some later changes are causing the issue. A possible cause might be this function def non_max_suppression(...) in utils/detector_utils.py. I think the function needs to be updated according to the latest commits in the yolov5 repo.

I will work on this when i have time and add a yolov5 release info so that people know which version it was tested for.

SamSamhuns commented 3 years ago

From the latest v5.0 release, results seem to be fine frame_onnx_00001

tino926 commented 3 years ago

@SamSamhuns, It is different from my experiment. I want to check it again in case of any misunderstanding.., when you say "latest v5.0 release", do you mean this version: https://github.com/ultralytics/yolov5/releases/tag/v5.0 or the latest commit (git clone from https://github.com/ultralytics/yolov5.git)

SamSamhuns commented 3 years ago

It works with the latest commit on the GitHub repo as of August 16 and it works with the pt files exported with the "latest v5.0 release" (As the release does not include the export.py files) You can also try the Google Colab https://colab.research.google.com/drive/1K8gnZEka47Gbcp1eJbBaSe3GxngJdvio?usp=sharing and run the section 1 and 3b to just test the onnx inference

tino926 commented 3 years ago

@SamSamhuns, Thanks for your work. This is my test, just for reference:

yolov5 5.0 release and 4.0 release both have export.py, they are located at "./models/export.py".

  1. model from 5.0 release, using 5.0 release's "./models/export.py", incorrect result
  2. model from 4.0 release, using 4.0 release's "./models/export.py", incorrect result.
  3. model from 5.0 release, using latest commit's "export.py", perfect result.
  4. model form 4.0 release, using latest commit's "export.py", perfect result.
SamSamhuns commented 3 years ago

Yeah, it seems there might have been some issues with the previous versions