# cpp-pytorch **Repository Path**: lebranium/cpp-pytorch ## Basic Information - **Project Name**: cpp-pytorch - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-08 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## cpp-pytorch PyTroch 1.0 preview - LOADING A PYTORCH MODEL IN C++ Details refer to: https://shiftlab.github.io/pytorch_tutorials/advanced/cpp_export.html Main requires: PyTroch 1.0, opencv, cmake ### STEP 1 CONVERTING YOUR PYTORCH MODEL TO TORCH SCRIPT and SERIALIZING YOUR SCRIPT MODULE TO A FILE - run `python tracing.py` and get `model.pt` ### STEP 2 LOADING YOUR SCRIPT MODULE IN C++ and EXECUTING 1. Download LibTorch [here](https://pytorch.org/) and unzip 2. Cmake ``` mkdir build cd build cmake -DCMAKE_PREFIX_PATH=/Users/hankai/code/cpp-pytorch/libtorch .. make ``` 3. Run demo ``` ./example-app ../model.pt ../dog.png ../synset_words.txt ``` Input image and predicted label: `n02108422 bull mastiff`, bingo! ![](dog.png)