emla2805 / fast-style-transfer

Fast Style Transfer using Tensorflow 2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fast Style Transfer

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.

Requirements

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

Usage

To style an image using a pre-trained model specify the input and output image paths and the log directory containing model checkpoints.

Style image

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

Train model

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.

Example models


About

Fast Style Transfer using Tensorflow 2


Languages

Language:Python 100.0%