Nebula4869 / YOLOv5-LibTorch

Real time object detection with deployment of YOLOv5 through LibTorch C++ API
MIT License
170 stars 53 forks source link

The torchscript weight from YoLoV5 is not workable #2

Open Jelly123456 opened 4 years ago

Jelly123456 commented 4 years ago

Thanks very much for creating this repo.

Now I am facing one problem that the converted torchscript weight from YoLoV5 is not working with the code you provided.

The conversion is followed on this: https://github.com/ultralytics/yolov5/issues/251

The image size is set to [640, 640] and I also modified your code to be 640.

When loading your existing torchscript weight, it works perfectly.

Do you know which could be the reasons?

Thanks.

Jelly123456 commented 4 years ago

I solved this by changing some codes in the export.py from YoLoV5 repo.

Nebula4869 commented 4 years ago

It may be that the author of YOLOv5 updated the repo so that some operators in the network are not supported. Perhaps you can solve this problem by cloning the previous version of the YOLOv5 repo and use "export.py" to get the torchscript file.

------------------ 原始邮件 ------------------ 发件人: "Nebula4869/YOLOv5-LibTorch" <notifications@github.com>; 发送时间: 2020年10月6日(星期二) 凌晨0:01 收件人: "Nebula4869/YOLOv5-LibTorch"<YOLOv5-LibTorch@noreply.github.com>; 抄送: "Subscribed"<subscribed@noreply.github.com>; 主题: [Nebula4869/YOLOv5-LibTorch] The torchscript weight from YoLoV5 is not workable (#2)

Thanks very much for creating this repo.

Now I am facing one problem that the converted torchscript weight from YoLoV5 is not working with the code you provided.

The conversion is followed on this: ultralytics/yolov5#251

The image size is set to [640, 640] and I also modified your code to be 640.

When loading your existing torchscript weight, it works perfectly.

Do you know which could be the reasons?

Thanks.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

Jelly123456 commented 4 years ago

Thanks very much for your reply. Now I could not run with the torchscript model exported in GPU mode. Do you know how to solve it?

FantasyJXF commented 3 years ago

Export the torchscript with map_location=torch.device('cuda') will do

yy2lyx commented 3 years ago

I solved this by changing some codes in the export.py from YoLoV5 repo.

could you tell me the code where to change?PLZ

1chimaruGin commented 3 years ago

I solved this by changing some codes in the export.py from YoLoV5 repo.

could you tell me the code where to change?PLZ

https://github.com/ultralytics/yolov5/blob/69be8e738f45e7908c1270eedd350f98c0c7bfa4/models/export.py#L33

Jelly123456 commented 3 years ago

@1chimaruGin @yy2lyx You can follow the instructions in this repo. I tried successfully with GPU + Linux environment.

https://github.com/yasenh/libtorch-yolov5