Project for SJTU-AU332 (AI3603).
Implementing transferring a real photo containing natural scenery into Chinese painting style using CycleGAN and Neural Style Transfer.
CycleGAN/
: source code of CycleGANNeuralStyleTransfer/
: source code of Neural Style Transfermain.py
: main script to run neural style transferLossFunction.py
: loss function scriptdata/
: style images and content imagesresults/
: some sample results
-
To run training script, first, change directory to where the script locates, and put trainA and trainB into directory
dataroot
. Then use commandpython train.py --dataroot dataroot
in terminal. Use commandpython train.py --help
for more instructions.To run testing script, first, change directory to where the script locates, put test data into directory
dataroot
and put pretrained model into directory./checkpoints/xxx
wherexxx
is thename
you defined in terminal. Then use commandpython test.py --dataroot dataroot --name name
in terminal. Use commandpython test.py --help
for more instructions.Our pretrained Model:
Baidu NetDisk (key: eplt)
-
First, change directory to where the
main.py
script locates, put content images into directorycontent_img_dir
, and put style images into pathstyle_img_path
. Then use commandpython main.py --content_img_dir content_img_dir --style_img_path style_img_path
in terminal. Use commandpython main.py --help
for more instructions.
The code requires only common Python environments for machine learning; Basically, it was tested with
- Python 3 (Anaconda 3.6.3 specifically)
- PyTorch==0.3.1
- numpy==1.18.5
- tqdm
- pillow
- matplotlib
- argparse
Higher (or lower) versions should also work (perhaps with minor modifications).
download:
Baidu NetDisk (key: 1t61)
Adapted from :
Traditional Chinese Landscape Painting Dataset
This repo borrows a lot from junyanz/pytorch-CycleGAN-and-pix2pix and pytorch tutorials.