An Android app built with an artistic style transfer neural network
Artistic style transfer help you creat exciting image with sytle you like. It need two input images: one representing the artistic style and one representing the content.
This project implement style transfer on Android platfrom. It contains two parts including training style model on computer using python and deploy the model to the moblie phone with Android Studio.
The app can be download via BaiduCloud or GoogleDriver
Unzip the train2014.zip and put the folder train2014
and imagenet-vgg-verydeep-19.mat
to the data
folder
The training code refers to @GuidoPaul
python style-transfer.py --style images/styles/wave.jpg --test images/test/test.jpg
It takes about 3 to 4 hours to train on TITAN XP.
The trained model is saved in checkpoint folder and the converted pb model file is saved in model file.
You can download the pretrained model trained by images/styled/wave.jpg via BaiduCloud
python test_pb_file.py --model_name model/style_graph_frozen.pb --test_image images/test/test2.jpg
Run to see the input and output node and tensor size of trained model which are important for the setting on Andoird.
After traning style model using python, we need deploy the trained model on android.
To run this project, you need put the pre-trained pb modol file to Part2_Android_Project\Style_Transfer\app\src\main\assets
download via BaiduCloud
To add your trained model, you need to follow these steps:
- Add the style image to the folder
Part2_Android_Project\Style_Transfer\app\src\main\res\drawable
- Create style object to the function
initStyles()
at line 653 in MainActivity.java
- Add the style model to the folder
Part2_Android_Project\Style_Transfer\app\src\main\assets
- Add this model to
pu_list
at Line 73 in MainActivity.java
If you like it, welcome to fork and star ^_^