yasenh / libtorch-yolov5

A LibTorch inference implementation of the yolov5
MIT License
372 stars 114 forks source link

./libtorch-yolov5 error #4

Closed name333 closed 3 years ago

name333 commented 3 years ago

hi Thank you for your work, when I run "./libtorch-yolov5 /data_1/train_project/OBJ_Detection/yolov5-forward/module/torchscript.pt /data_1/train_project/OBJ_Detection/yolov5-forward/img/000240_01046820200606110918_0035_670_3cls.jpg -gpu". The following error occurred

terminate called after throwing an instance of 'c10::Error' what(): isTuple() INTERNAL ASSERT FAILED at /data_1/train_project/OBJ_Detection/yolov5-forward/libtorch/include/ATen/core/ivalue_inl.h:723, please report a bug to PyTorch. Expected Tuple but got GenericList (toTuple at /data_1/train_project/OBJ_Detection/yolov5-forward/libtorch/include/ATen/core/ivalue_inl.h:723) frame #0: c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) + 0x6a (0x7f7d00dfaaaa in /data_1/train_project/OBJ_Detection/yolov5-forward/libtorch/lib/libc10.so) frame #1: c10::IValue::toTuple() const & + 0x121 (0x559bed24f2b3 in ./libtorch-yolov5) frame #2: + 0xef9c (0x559bed245f9c in ./libtorch-yolov5) frame #3: + 0x4176b (0x559bed27876b in ./libtorch-yolov5) frame #4: __libc_start_main + 0xe7 (0x7f7cabd8eb97 in /lib/x86_64-linux-gnu/libc.so.6) frame #5: + 0xcc6a (0x559bed243c6a in ./libtorch-yolov5)

how to solve this problem

yasenh commented 3 years ago

Hi @name333 , did you follow the instruction here https://github.com/yasenh/libtorch-yolov5#torchscript-model-export? I can duplicate your error msg if I use the original "export.py" from yolov5 repo.

yasenh commented 3 years ago

line 28

model.model[-1].export = False
The modification above is required for both cpu & gpu, and the other 2 lines of gpu map location update is optional.

I will revise the instructions little bit later on.

MHGL commented 3 years ago

首先非常感谢ultralytics大神,我们团队把yolov5模型重构了,并且复现了和原仓库同样的水平,优势是可以端到端转换移动端模型,如果你有时间有需要,请移步yolov5,期待各位的驾临。