libtorch-yolov3 v1.1.0版本的

编译

cmake -DCMAKE_PREFIX_PATH="/home/amax/download/libtorch" -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ ..

libtorch-yolov3/Darknet.cpp

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

 570      bn_running_var = bn_running_var.view_as(bn_imp->running_var);

            bn_imp->running_var.set_data(bn_running_var);

main.cpp:60:51

   // auto img_tensor = torch::CPU(torch::kFloat32).tensorFromBlob(img_float.data, {1, input_image_size, input_image_size, 3});
 
  auto img_tensor = torch::from_blob(img_float.data, {1, input_image_size, input_image_size, 3}).permute({0, 3, 1, 2}).to(torch::kCUDA);
    img_tensor = img_tensor.permute({0,3,1,2});
   auto img_var = torch::autograd::make_variable(img_tensor, false).to(device);

 

以上的错误 地方做了一些修改,最后发现还是会有问题,

自己做了个修正,放在github上,改成了usb摄像头的版本,欢迎拍砖

https://github.com/chengcaoc/libtorch-yolov3.git

你可能感兴趣的:(libtorch)