Unofficial Pytorch Implementation "Arbitrary Style Transfer in Real-time with Adaptive Instance Normalization"
Reference: Arbitrary Style Transfer in Real-time with Adaptive Instance Normalization, ICCV 2017
- torch (version: 1.2.0)
- torchvision (version: 0.4.0)
- Pillow (version: 6.1.0)
- matplotlib (version: 3.1.1)
- The trained model can be downloaded through the Google drive
- Content dataset: MSCOCO train2014 is needed to train the network.
- Style dataset: Painter by numbers is needed to trian the network.
--train
: Train flag to learn the style transfer network--content-dir
: Content dataset path for learn the style transfer network--style-dir
: Style dataset path for learn the style transfer network--imsize
: Size to resize the shorter side of the image (maintaining the aspect ratio)--cropsize
: Size to crop the image--cencrop
: Flag for crop the center region of the image (default: randomly crop)--style-weight
: Style loss weight (If you want to enhance the style, increase this value to train the network)--gpu-no
: Device no (-1: cpu, 0~N: gpu)--content
: Source contenet image--style
: Target style image--mask
: Mask to generate masked stylized image--style-strength
: Trade off factor between content and style (1.0: style, 0.0: content)--interpolation-weights
: Interpolation weights of multiple styles--load-path
: Model load path--layers
: Layer Indices to extract content and style features--preserve-color
: Flag for color preserved stylization
python main.py --train --imsize 512 --cropsize 256 --content-dir ./coco2014/ --style-dir ./painter_by_numbers/
- Training loss
python main.py --imsize 512 --content ./imgs/content/lena.jpg --style ./imgs/style/abstraction.jpg --load-path ./check_point.pth --style-strength 1.0
python main.py --imsize 512 --content ./imgs/content/chicago.jpg --style ./imgs/style/abstraction.jpg ./imgs/style/starry_night.jpg --load-path ./check_point.pth --style-strength 1.0 --interpolation-weights 0.5 0.5
python main.py --imsize 512 --content ./imgs/content/blonde_girl.jpg --style ./imgs/style/mondrian.jpg ./imgs/style/starry_night.jpg --mask ./imgs/mask/blonde_girl_mask1.jpg ./imgs/mask/blonde_girl_mask2.jpg --load-path ./check_point.pth --style-strength 1.0 --interpolation-weights 1.0 1.0
python main.py --imsize 512 --content ./imgs/content/blonde_girl.jpg --style ./imgs/style/mondrian.jpg --load-path ./check_point.pth --preserve-color