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 。