nebula4869 / yolov5-libtorch Goto Github PK
View Code? Open in Web Editor NEWReal time object detection with deployment of YOLOv5 through LibTorch C++ API
License: MIT License
Real time object detection with deployment of YOLOv5 through LibTorch C++ API
License: MIT License
//I use the way of torch.jit.trace to convert original pt file to torchscript pt file , but it generates many bugs.....
I find it !! There is a export.py file converting original pt file to torchscript pt file in the YOLOv5 project .
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.
jittrace总是报错 请问怎么回事
Hi, I've tried your code on your provided weights its working fine, but when I tried my custom weight exported using ultralytics repo, even using older tags is not working. can you please help me with it
When i run make, it returns a linking error.
/usr/bin/ld: CMakeFiles/YOLOv5LibTorch.dir/src/YOLOv5LibTorch.cpp.o: in function main': YOLOv5LibTorch.cpp:(.text.startup+0xed7): undefined reference to
cv::putText(cv::InputOutputArray const&, std::string const&, cv::Point, int, double, cv::Scalar_, int, int, bool)'
/usr/bin/ld: YOLOv5LibTorch.cpp:(.text.startup+0xf5a): undefined reference to cv::imshow(std::string const&, cv::_InputArray const&)' /usr/bin/ld: YOLOv5LibTorch.cpp:(.text.startup+0x1621): undefined reference to
cv::format(char const*, ...)'
/usr/bin/ld: YOLOv5LibTorch.cpp:(.text.startup+0x16f6): undefined reference to `cv::putText(cv::InputOutputArray const&, std::string const&, cv::Point, int, double, cv::Scalar_, int, int, bool)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/YOLOv5LibTorch.dir/build.make:160: ../bin/YOLOv5LibTorch] Error 1
make[1]: *** [CMakeFiles/Makefile2:95: CMakeFiles/YOLOv5LibTorch.dir/all] Error 2
make: *** [Makefile:103: all] Error 2
Hi,
I want inference my .torchscript.pt
which is trained by this command and switch:
python train.py --img 128 128 --rect ...
but, by change resize function in this repo to (128,128), i got error:
RuntimeError: The size of tensor a (32) must match the size of tensor b (80) at non-singleton dimension 3
but, i don't know where should i change to work for me.
please help me.
I am pursuing a similar path, and have been able to loop multiple inference calls to module::forward() when using CPU version of libtorch and PT file. CUDA version not so much - the inference call makes it through the first time, but subsequent call results in an exception. Have you tried this, and what are your results? FYI I am using CUDA 10.1.
I also logged an issue on this with pytorch group:
pytorch/pytorch#47590
Thanks,
Rob
First of all , thanks for you share.
I'd like to know how to extract the raw results after the forward step?
because i need to debug for the middle result before using the nmx
Thanks!
Only Run on CPU.......
How to run on GPU?
[ 50%] Building CXX object CMakeFiles/YOLOv5LibTorch.dir/src/YOLOv5LibTorch.cpp.o
[100%] Linking CXX executable ../bin/YOLOv5LibTorch
CMakeFiles/YOLOv5LibTorch.dir/src/YOLOv5LibTorch.cpp.o:在函数‘main’中:
YOLOv5LibTorch.cpp:(.text.startup+0x14b4):对‘cv::format(char const*, ...)’未定义的引用
YOLOv5LibTorch.cpp:(.text.startup+0x1587):对‘cv::putText(cv::InputOutputArray const&, std::string const&, cv::Point, int, double, cv::Scalar_, int, int, bool)’未定义的引用
YOLOv5LibTorch.cpp:(.text.startup+0x19c3):对‘cv::putText(cv::InputOutputArray const&, std::string const&, cv::Point, int, double, cv::Scalar_, int, int, bool)’未定义的引用
YOLOv5LibTorch.cpp:(.text.startup+0x1a3f):对‘cv::imshow(std::string const&, cv::_InputArray const&)’未定义的引用
collect2: error: ld returned 1 exit status
CMakeFiles/YOLOv5LibTorch.dir/build.make:132: recipe for target '../bin/YOLOv5LibTorch' failed
make[2]: *** [../bin/YOLOv5LibTorch] Error 1
CMakeFiles/Makefile2:94: recipe for target 'CMakeFiles/YOLOv5LibTorch.dir/all' failed
make[1]: *** [CMakeFiles/YOLOv5LibTorch.dir/all] Error 2
Makefile:102: recipe for target 'all' failed
make: *** [all] Error 2
Hi, i get a problem when i use my model to inffer. I converted the official yolov5s.pt to yolov5s.torchscript.pt by export.py , but it cannot work in your code, and also my own model can not work too, do you know how can i sovle it ? thank you so much!
Im new to libtorch. How to change bounded box & text color?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.