This repository cotains implementation of Neural Art using PyTorch. Neural Art is also famous with the name of Neural Style Transfer. In this repository , I have used VGG16 pretrained model for extracting features. You can read the paper here
For using this project you need to follow some steps:
-
First clone this repository in your system and then navigate to repository folder
git clone https://github.com/adityak2920/NeuralArt-in-pytorch.git cd NeuralArt-in-pytorch/cpp
-
Create a folder build
mkdir build && cd build
-
Before procedding further we need to download latest distribution of libtorch to build our application which you can download from here. After downloading, unzip the folder and your libtorch directory should looks like this:
libtorch/ bin/ include/ lib/ share/ build-hash build-version
-
Now run these commands to build the application
cmake -DCMAKE_PREFIX_PATH=/path/to/libtorch .. cmake --build . --config Release
-
To run our app, we will need vgg19 to torchscript form:
import torchvision import torch model = torchvision.models.vgg19(pretrained=True) x = torch.rand(1, 3, 448, 448) traced_cell = torch.jit.trace(model, x) traced_cell.save('model.pt')
Now use the path of saved model in neural.cpp .
-
Now you can run your app with(you can specify name of app in cmake file)
./your_app
-
From next time you can recompile and run your app using
make ./your_app
Here, are some of the results after training for some time using Tesla K80 GPU on Google Collab:
Here are some other images generated using same content image but with different style images and the results are pretty good.