Download libtorch
$ wget https://download.pytorch.org/libtorch/nightly/cpu/libtorch-shared-with-deps-latest.zip
$ unzip libtorch-shared-with-deps-latest.zip
Tracing model and save model.pt
- Modify to_cpp.py
- Generate model.pt
python to_cpp.py
Build
$ cd pytorch-cpp
$ mkdir build;cd build
$ cmake -DCMAKE_PREFIX_PATH=<path to libtorch> ..
$ make
$ ./example-app ../model.pt <img_path>