This is tensorflow implementation of 'Perceptual Losses for Real-Time Style Transfer and Super-Resolution'.
$ git clone https://github.com/fullfanta/real_time_style_transfer.git
$ cd real_time_style_transfer
$ sh get_coco.sh
$ sh get_vgg16.sh
$ python train.py
If you have multiple GPU cards, use CUDA_VISIBLE_DEVICES to specify GPU card. Trained model is in summary. To adjust weights of content loss and style loss, you can set the parameter alpha. loss equation is alpha * content loss + (1 - alpha) * style loss. Default is 0.1 During training, you can see generated images through tensorboard.
$ tensorboard --logdir=summary
$ sh freeze.sh 40000
It generates pb file which contains weights as contant. First arugment means the iteration number of saved check point file.
$ python stylize.py --model=models/starry_night.pb --input_image=test_images/Aaron_Eckhart_0001.jpg
$ python stylize.py --model=models/starry_night.pb --input_image=test_images/jolie.jpg --resize_ratio=2
$ python stylize.py --model=models/starry_night.pb --input_image=test_images/dinosour.png --resize_ratio=2
$ python stylize.py --model=models/starry_night.pb --input_image=test_images/ryan.png --resize_ratio=3
$ python stylize.py --model=models/starry_night.pb --input_image=test_images/herb.png --resize_ratio=2
$ python stylize.py --model=models/starry_night.pb --input_image=test_images/cheez.png --resize_ratio=4
It generates stylized images and save them to 'test_images'.
Input | Output | |
---|---|---|
Aaron Echart | ||
Angelina Jolie | ||
Dinosour | ||
Ryan | ||
Herb | ||
Cheez |