YOLOv5-LibTorch icon indicating copy to clipboard operation
YOLOv5-LibTorch copied to clipboard

The torchscript weight from YoLoV5 is not workable

Open Jelly123456 opened this issue 4 years ago • 7 comments

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 avatar Oct 05 '20 16:10 Jelly123456

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

Jelly123456 avatar Oct 05 '20 16:10 Jelly123456

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" <[email protected]>; 发送时间: 2020年10月6日(星期二) 凌晨0:01 收件人: "Nebula4869/YOLOv5-LibTorch"<[email protected]>; 抄送: "Subscribed"<[email protected]>; 主题: [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.

Nebula4869 avatar Oct 06 '20 06:10 Nebula4869

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?

Jelly123456 avatar Oct 06 '20 11:10 Jelly123456

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

FantasyJXF avatar Nov 12 '20 02:11 FantasyJXF

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

could you tell me the code where to change?PLZ

yy2lyx avatar Dec 17 '20 03:12 yy2lyx

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

1chimaruGin avatar Jan 05 '21 08:01 1chimaruGin

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

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

Jelly123456 avatar Jan 05 '21 08:01 Jelly123456