Tensorflow 2 implementation of Fast Style Transfer which merges the style of one picture with the content of another.
The algorithm is based on Perceptual Losses for Real-Time Style Transfer and Super-Resolution with the addition of Instance Normalization.
Create a Python 3.7 virtual environment and activate it:
virtualenv -p python3.7 venv
source ./venv/bin/activate
Next, install the required dependencies:
pip install -r requirements.txt
To style an image using a pre-trained model specify the input and output image paths and the log directory containing model checkpoints.
python style.py \
--image-path images/content/amber.jpg \
--log-dir models/mosaic/lr=0.001_bs=16_sw=10.0_cw=10.0/ \
--output-path images/output/output-image.png
python train.py \
--log-dir models/mosaic/ \
--style-image images/style/mosaic.jpg \
--test-image images/content/amber.jpg
Training, which uses the COCO 2014 train dataset, takes about 1-2 hours on a Tesla P100 GPU.
To track metrics, start Tensorboard
tensorboard --logdir models/
and navigate to localhost:6006.