ResNet model with C++/Python language.
Download libtorch (PyTorch library for C++), extract.
- Without CUDA (CPU)
wget https://download.pytorch.org/libtorch/nightly/cpu/libtorch-shared-with-deps-latest.zip
unzip libtorch-shared-with-deps-latest.zip- With CUDA (CPU+GPU)
wget https://download.pytorch.org/libtorch/cu102/libtorch-shared-with-deps-1.5.1.zip
unzip libtorch-shared-with-deps-1.5.1.zipBuild ResNet with cmake.
cd cpp
mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH=/path/to/libtorch ..
cmake --build . --config ReleaseDownload MNIST dataset from website and locate to mnist directory.
Run ResNet model to train.
./train -m saved_modelTrained model will be saved to saved_model directory.
Using trained model, predict a class where the sample image (digit.png) belongs.
./predict -i ../../data/digit.png -m saved_modelInstall pytorch package.
pip install pytorchRun ResNet model to train.
MNIST data will be downloaded to mnist directory within the Python program.
cd python
python train.py -m saved_modelTrained model will be saved to saved_model directory.
Using trained model, predict a class where the sample image (digit.png) belongs.
python predict.py -i ../data/digit.png -m saved_model