A Pytorch implementation of Style Transfer with Adaptive Instance Normalization based on the paper Arbitrary Style Transfer in Real-time with Adaptive Instance Normalization .
- Argparse
- Numpy
- Pillow
- Python 3.7
- PyTorch
- TorchVision
- tqdm
Download the data to the ./data/ folder. The network is trained using MSCOCO and wikiart dataset. Download the weight of the vggnet to build the encoder. Run the script train.py
$ python train.py --trainset_dir $TRAINDIR --cuda
usage: train.py [-h] [--content_dir CONTENT_DIR] [--style_dir STYLE_DIR]
[--epochs EPOCHS] [--resume RESUME] [--cuda]
optional arguments:
-h, --help show this help message and exit
--content_dir CONTENT_DIR
content data set path
--style_dir STYLE_DIR
style data set path
--epochs EPOCHS training epoch number
--resume RESUME continues from epoch number
--cuda Using GPU to train
Download the decoder weight.
Run the script test_image.py
$ python test_image.py --input_image $IMG --style_image $STYLE --weight $WEIGHT --cuda
usage: test_style_transfer.py [-h] [--input_image INPUT_IMAGE]
[--style_image STYLE_IMAGE] [--weight WEIGHT]
[--alpha {Alpha Range}] [--cuda]
optional arguments:
-h, --help show this help message and exit
--input_image INPUT_IMAGE
test image
--style_image STYLE_IMAGE
style image
--weight WEIGHT decoder weight file
--alpha {Alpha Range}
Level of style transfer, value between 0 and 1
--cuda Using GPU to train
Make grid of images from the selected images in a directory
$ python make_grid.py --r $NUM_ROW --c $NUM_COL --dir $DIR
usage: make_grid.py [-h] [--dir DIR] [--r R] [--c C] [--size SIZE]
optional arguments:
-h, --help show this help message and exit
--dir DIR The directory for the images
--r R Numer of rows
--c C Numer of columns
--size SIZE Size per thumbnail