ultralytics / yolov3

YOLOv3 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
10.22k stars 3.45k forks source link

accuracy difference between pytorch and opencv #1129

Closed taylan24 closed 4 years ago

taylan24 commented 4 years ago

Hello, Firstly, thank you very much for your work. I trained yolov3-tiny for one class with my own data and image size is 640 in training time, and the results are pretty good when I use detect.py with an image size of 640. I used the recent repository by the way. However, if I use OpenCV's dnn library, the accuracy is decreased by about 3 %. the image sizes, confidence thresholds and nms thresholds are the same. in opencv: blob = cv2.dnn.blobFromImage(img, 1.0/255.0, (640,448), (0,0,0), True, crop=False,ddepth=cv2.CV_32F) so the depth is float 32, and in detect.py the depth is torch.float32. I also used (640,640) for blob size above, nothing changed. I do not know how to solve this, and I did not find the difference in inference.

Thank you in advance.

glenn-jocher commented 4 years ago

@taylan24 I don't understand your question.

We do not support external functionality as you mentioned, if you have a question regarding cv2 you should raise it on the cv2 repo.

github-actions[bot] commented 4 years ago

This issue is stale because it has been open 30 days with no activity. Remove Stale label or comment or this will be closed in 5 days.

sky-fly97 commented 4 years ago

你好, 首先,非常感谢你的工作。 我训练了yolov 3--用我自己的数据和图像大小来训练一个类,在训练时间里,图像大小是640,当我使用像大小为640的探测时,结果是很好的。顺便说一下,我使用了最近的存储库。 然而,如果我使用OpenCV的系统库,准确率会下降约3%。 图像大小、置信度阈值和nms阈值是相同的。 在OpenCV中: BLOB=cv2.dnn.bobFromImage(IMG,1.0/255.0,(640,448),(0,0,0),真,作物=假,d纵深=cv2.CV_32F) 所以深度是浮动32,在探测中,深度是torch.Float 32。 我还使用了(640,640)以上的BLOB大小,没有什么变化。 我不知道如何解决这个问题,我也没有发现推论上的区别。

提前谢谢。

Hello, I want to know how you can use dnn to read and infer, because I have an error when using dnn to read yolov3-spp.onnx, can I have a look at your opencv inference code? thank you very much!

XiaoLaoDi commented 4 years ago

@taylan24 would you mind to share the opencv inference code ?