ultralytics / yolov5

YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
50.65k stars 16.32k forks source link

yolov5s——onnx——caffe ,model transfer problem #1457

Closed dadaligoudan closed 3 years ago

dadaligoudan commented 3 years ago

❔Question

Hi, I trained a model based on yolov5s.yaml and transfered it to caffe model.The bounding boxes do not match the object, seems it has been scaled. I also have the same problem with models trained using yolov4.cfg. After transfering to caffe model, the model i trained using the yolov4.cfg doesn't perform the way it should be. The bounding boxes do not match the object, seems it has been scaled. But the yolov3.cfg performed well. I have checked your official code, i still cann't find the reason. I want to know what the difference between yolov3.cfg and v4 as well as v5 about the yolo layer? How do you use this parameters in the yolo layer?Could you please help me with this, thanks.

Additional context

YOLOv4 yolov

2767_detected

github-actions[bot] commented 3 years ago

Hello @dadaligoudan, thank you for your interest in 🚀 YOLOv5! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

If this is a 🐛 Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.

For business inquiries or professional support requests please visit https://www.ultralytics.com or email Glenn Jocher at glenn.jocher@ultralytics.com.

Requirements

Python 3.8 or later with all requirements.txt dependencies installed, including torch>=1.7. To install run:

$ pip install -r requirements.txt

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

CI CPU testing

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

mengban commented 3 years ago

Have u fix your problem yet?

TW0521 commented 3 years ago

how to transfer the yolov5s.pt to caffe model?

dadaligoudan commented 3 years ago

Have u fix your problem yet?

Yes, i have fixed this problem and got the right result. The forward function in the Detect class is different from yolov3 and it should be modified as described in the following picture. I think the bounding box regression part in yolov5 is quiet dofferent from that in yolov3 and yolov4. yolo

dadaligoudan commented 3 years ago

how to transfer the yolov5s.pt to caffe model? I am not really familiar with caffe and i do not know how to transfer FOCUS part , so i used a conv layer which stride=2 to replace it. I used export.py to transfer yolov5s.pt to onnx model. After that, I used onnx simplify tool to simplify onnx model. Last, I transferd onnx-simplified model to caffe model.

Nioolek commented 3 years ago

how to transfer the yolov5s.pt to caffe model? I am not really familiar with caffe and i do not know how to transfer FOCUS part , so i used a conv layer which stride=2 to replace it. I used export.py to transfer yolov5s.pt to onnx model. After that, I used onnx simplify tool to simplify onnx model. Last, I transferd onnx-simplified model to caffe model.

请问你在从onnx-simplified转到caffe时候用的是什么代码?还有export.py里,onnx的opset_version=11吗?

Nioolek commented 3 years ago

Can caffe support the Hardswish layer?

bot66 commented 3 years ago

大佬能说一下怎么转caffe的吗?有没有博客之类的:)

Hwijune commented 3 years ago

@dadaligoudan How did you convert it? torch -> onnx -> caffe

I want to use yolo5 or csp-p7 with leaky relu model in the caffe

ShihuaiXu commented 3 years ago

大佬能说一下怎么转caffe的吗?有没有博客之类的:)

github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.