pytorch AdaIN
v0.0.0
这是一个非正式的Pytorch实施,即具有自适应实例归一化[Huang+,ICCV2017]的纸,任意样式转移。我真的很感谢作者在火炬中的原始实现,这非常有用。

请按pip install -r requirements.txt安装要求
(可选,用于培训)
从发行版中下载dododer.pth / vgg_normalized.pth,并将它们放在models/下。
使用--content和--style为内容和样式图像提供相应的路径。
CUDA_VISIBLE_DEVICES=<gpu_id> python test.py --content input/content/cornell.jpg --style input/style/woman_with_hat_matisse.jpg
您还可以使用--content_dir和--style_dir在内容和样式图像的目录上运行代码。它将将内容和样式的所有可能组合保存到输出目录中。
CUDA_VISIBLE_DEVICES=<gpu_id> python test.py --content_dir input/content --style_dir input/style
这是通过指定--style和--style_interpolation_weights选项来混合四种样式的示例。
CUDA_VISIBLE_DEVICES=<gpu_id> python test.py --content input/content/avril.jpg --style input/style/picasso_self_portrait.jpg,input/style/impronte_d_artista.jpg,input/style/trial.jpg,input/style/antimonocromatismo.jpg --style_interpolation_weights 1,1,1,1 --content_size 512 --style_size 512 --crop
其他一些选项:
--content_size :内容图像的新(最小)大小。如果设置为0,请保持原始尺寸。--style_size :内容图像的新(最小)大小。如果设置为0,请保持原始尺寸。--alpha :调整样式的程度。它应该是0.0和1.0之间的值(默认值)。--preserve_color :保留内容图像的颜色。使用--content_dir和--style_dir可为内容和样式图像提供相应的目录。
CUDA_VISIBLE_DEVICES=<gpu_id> python train.py --content_dir <content_dir> --style_dir <style_dir>
有关更多详细信息和参数,请参阅-help选项。
我将该代码训练的模型分享为iter_1000000.pth 。