walktree / libtorch-yolov3

A Libtorch implementation of the YOLO v3 object detection algorithm
450 stars 131 forks source link

terminate called after throwing an instance of 'c10::Error' #12

Closed zhengli233 closed 5 years ago

zhengli233 commented 5 years ago

This error showed when loading the weights file:

terminate called after throwing an instance of 'c10::Error' what(): !is_variable() INTERNAL ASSERT FAILED at /pytorch/c10/core/TensorImpl.h:927, please report a bug to PyTorch. (shallow_copy_and_detach at /pytorch/c10/core/TensorImpl.h:927) frame #0: std::function<std::string ()>::operator()() const + 0x11 (0x7f54a6c17961 in /home/zhengli/Pytorch/libtorch-shared-with-deps-latest/libtorch/lib/libc10.so) frame #1: c10::Error::Error(c10::SourceLocation, std::string const&) + 0x2a (0x7f54a6c1729a in /home/zhengli/Pytorch/libtorch-shared-with-deps-latest/libtorch/lib/libc10.so) frame #2: + 0x2f662b9 (0x7f549de102b9 in /home/zhengli/Pytorch/libtorch-shared-with-deps-latest/libtorch/lib/libcaffe2.so) frame #3: torch::autograd::Variable::Impl::set_data(at::Tensor const&) + 0x278 (0x7f549de0d5b8 in /home/zhengli/Pytorch/libtorch-shared-with-deps-latest/libtorch/lib/libcaffe2.so) frame #4: at::Tensor::set_data(at::Tensor) + 0x53 (0x558b6a423363 in ./yolo-app) frame #5: Darknet::load_weights(char const*) + 0x625 (0x558b6a416335 in ./yolo-app) frame #6: main + 0x206 (0x558b6a40ef06 in ./yolo-app) frame #7: __libc_start_main + 0xe7 (0x7f5499755b97 in /lib/x86_64-linux-gnu/libc.so.6) frame #8: _start + 0x2a (0x558b6a40ff7a in ./yolo-app)

Aborted (core dumped)

Does anyone have the same problem?

jlcai5 commented 5 years ago

yes l have sample problem in linux fow v1.1.0

zhengli233 commented 5 years ago

Solved. Replace every

torch::TensorFromBlob

to

at::from_blob

like

at::from_blob(weights_src, {length/4}).to(torch::kFloat32)

There will be 3 totally.

Crystal-Ann commented 5 years ago

thanks a lot!

soulslicer commented 5 years ago

How do I change this line

at::Tensor weights = torch::CPU(torch::kFloat32).tensorFromBlob(weights_src, {length/4});

to the

from blob api??