libtorch_cpp_mobilenetv2_5classes
libtorch_cpp_mobilenetv2_5classes copied to clipboard
I use mobilenetv2 to export a model with 5 classes, then use libtorch to load and run it.
requirments
download libtorch (https://download.pytorch.org/libtorch/cu102/libtorch-cxx11-abi-shared-with-deps-1.7.1.zip)
unzip libtorch, then put them under c++ dir
install cuda10.2
install cudnn7
if you use 'Pre-cxx11 ABI', do the actions below:
opencv build with -D_GLIBCXX_USE_CXX11_ABI=0 (important)
How to use
mkdir build
cd build
cmake ..
make
run
./example-app ../mv2.pt test1.jpg test2.jpg
we will see the result
inputs:1
start...
id:0 conf:0.96528
id:4 conf:0.996588