???? 版权: 本文由【墨理学AI】原创、各位大佬、一文读懂、敬请查阅
???? 声明: 作为全网 AI 领域 干货最多的博主之一,❤️ 不负光阴不负卿 ❤️
StyleMapGAN 基于 StyleGAN2 改进
论文题目
Exploiting Spatial Dimensions of Latent in GAN for Real-time Image Editing
所运行代码 + paper
本博文记录StyleMapGAN 预训练模型 在 celeba_hq 测试数据上的 生成效果
- 环境搭建参考上一篇博文即可
celeba_hq 测试数据 + 预训练模型准备
作者把相关下载链接和解压逻辑已经在 download.sh 中整理完毕,真的非常 Nice
直接傻瓜式操作,复制命令一路下载即可【看网速,差不多半小时的样子】
# Download raw images and create LMDB datasets using them
# Additional files are also downloaded for local editing
bash download.sh create-lmdb-dataset celeba_hq
# Download the pretrained network (256x256)
bash download.sh download-pretrained-network-256 celeba_hq
# Download the pretrained network (1024x1024 image / 16x16 stylemap / Light version of Generator)
bash download.sh download-pretrained-network-1024 ffhq_16x16
整个项目 + 以上命令下载解压的数据 ,总共就 占用 20G 存储
du -sh
20G .
项目数据部分目录结构
Generate images test of celeba_hq 数据集
Reconstruction
Reconstruction Results are saved to expr/reconstruction.
# CelebA-HQ
python generate.py --ckpt expr/checkpoints/celeba_hq_256_8x8.pt --mixing_type reconstruction --test_lmdb data/celeba_hq/LMDB_test
单卡 GPU 占用 11073MiB
interpolation
W interpolation Results are saved to expr/w_interpolation
# CelebA-HQ
python generate.py --ckpt expr/checkpoints/celeba_hq_256_8x8.pt --mixing_type w_interpolation --test_lmdb data/celeba_hq/LMDB_test
单卡 GPU 占用 8769MiB
Local editing
Local editing Results are saved to expr/local_editing. We pair images using a target semantic mask similarity. If you want to see details, please follow preprocessor/README.md.
# Using GroundTruth(GT) segmentation masks for CelebA-HQ dataset.
python generate.py --ckpt expr/checkpoints/celeba_hq_256_8x8.pt --mixing_type local_editing --test_lmdb data/celeba_hq/LMDB_test --local_editing_part nose
单卡 GPU 占用 8793MiB
重建得到的 nose
synthesized_image 生成的鼻子如下【也有少许失败样例】
Random Generation
Random Generation Results are saved to expr/random_generation. It shows random generation examples.
python generate.py --mixing_type random_generation --ckpt expr/checkpoints/celeba_hq_256_8x8.pt
Style Mixing
Style Mixing Results are saved to expr/stylemixing. It shows style mixing examples.
python generate.py --mixing_type stylemixing --ckpt expr/checkpoints/celeba_hq_256_8x8.pt --test_lmdb data/celeba_hq/LMDB_test
单卡 GPU 占用 8769MiB
- 粗修复结果: 135_coarse.png
- 细修复结果: 135_fine.png
Semantic Manipulation
Semantic Manipulation Results are saved to expr/semantic_manipulation. It shows local semantic manipulation examples.
# CelebA-HQ
python semantic_manipulation.py --ckpt expr/checkpoints/celeba_hq_256_8x8.pt --LMDB data/celeba_hq/LMDB --svm_train_iter 10000
单卡 GPU 占用 6455MiB生成【化妆】效果如下
运行输出如下【运行5分钟左右】
latent_code_shape (64, 8, 8)
positive_train: 5867, negative_train:3134, positive_val:651, negative_val:348
Training boundary. 2021-07-09 10:36:17.187714
/home/墨理/anaconda3/envs/torch15/lib/python3.7/site-packages/sklearn/svm/_base.py:258: ConvergenceWarning: Solver terminated early (max_iter=10000). Consider pre-processing your data with StandardScaler or MinMaxScaler.
% self.max_iter, ConvergenceWarning)
Finish training. 2021-07-09 10:37:23.516691
validate boundary.
Accuracy for validation set: 914 / 999 = 0.914915
classifier.coef_.shape (1, 4096)
boundary.shape (64, 8, 8)
30000 images, 30000 latent_codes
Heavy_Makeup 18
代码结构如下
大家参考博文,应该很容易就能够完成博文所示的测试效果
tree -L 5 ,此次博文对应源码、完整项目目录结构如下
tree -L 5
.
├── assets
│ ├── teaser.jpg
│ └── teaser_video.jpg
├── data
│ └── afhq
│ ├── LMDB_test
│ │ ├── data.mdb
│ │ └── lock.mdb
│ ├── LMDB_train
│ │ ├── data.mdb
│ │ └── lock.mdb
│ ├── LMDB_val
│ │ ├── data.mdb
│ │ └── lock.mdb
│ ├── local_editing
│ └── raw_images
│ ├── test
│ │ └── images
│ ├── train
│ │ └── images
│ └── val
│ └── images
├── demo
│ ├── static
│ │ └── components
│ │ ├── css
│ │ │ ├── image-picker.css
│ │ │ ├── main.css
│ │ │ └── main.scss
│ │ ├── img
│ │ │ ├── afhq
│ │ │ ├── celeba_hq
│ │ │ ├── eraser.png
│ │ │ └── lsun
│ │ └── js
│ │ ├── agh.sprintf.js
│ │ ├── image-picker.min.js
│ │ └── main.js
│ └── templates
│ ├── index.html
│ └── layout.html
├── demo.py
├── download.sh
├── expr
│ ├── checkpoints
│ │ ├── afhq_256_8x8.pt
│ │ ├── celeba_hq_256_8x8.pt
│ │ └── ffhq_1024_16x16.pt
│ ├── checkpoints_afhq
│ │ ├── afhq_256_8x8.pt
│ │ ├── ffhq_1024_16x16.pt
│ │ ├── small_ffhq_16x16_5M.pt
│ │ └── small_ffhq_32x32_2_5M.pt
│ ├── local_editing
│ │ └── celeba_hq
│ │ └── nose
│ │ ├── mask
│ │ ├── mask_ref
│ │ ├── mask_src
│ │ ├── reference_image
│ │ ├── reference_reconstruction
│ │ ├── source_image
│ │ ├── source_reconstruction
│ │ └── synthesized_image
│ ├── semantic_manipulation
│ │ ├── afhq_256_8x8_inverted.npy
│ │ └── Heavy_Makeup
│ │ └── afhq_256_8x8_Heavy_Makeup_boundary.npy
│ └── stylemixing
│ └── afhq
│ ├── 124_coarse.png
│ ├── 124_fine.png
│ ├── 135_coarse.png
│ ├── 135_fine.png
│ ├── 136_coarse.png
│ ├── 136_fine.png
│ ├── 162_coarse.png
│ ├── 162_fine.png
│ ├── 173_coarse.png
│ ├── 173_fine.png
│ ├── 7_coarse.png
│ └── 7_fine.png
├── generate.py
├── install.sh
├── LICENSE
├── metrics
│ ├── calc_inception.py
│ ├── fid.py
│ ├── inception.py
│ ├── __init__.py
│ ├── local_editing.py
│ ├── README.md
│ └── reconstruction.py
├── NOTICE
├── preprocessor
│ ├── pair_masks.py
│ ├── prepare_data.py
│ └── README.md
├── README.md
├── semantic_manipulation
│ ├── 0_neg_indices.npy
...
...
│ ├── 9_pos_indices.npy
│ └── list_attr_celeba_hq.txt
├── semantic_manipulation.py
├── training
│ ├── dataset_ddp.py
│ ├── dataset.py
│ ├── __init__.py
│ ├── lpips
│ │ ├── base_model.py
│ │ ├── dist_model.py
│ │ ├── __init__.py
│ │ ├── networks_basic.py
│ │ ├── pretrained_networks.py
│ │ └── weights
│ │ ├── v0.0
│ │ │ ├── alex.pth
│ │ │ ├── squeeze.pth
│ │ │ └── vgg.pth
│ │ └── v0.1
│ │ ├── alex.pth
│ │ ├── squeeze.pth
│ │ └── vgg.pth
│ ├── model.py
│ ├── op
│ │ ├── fused_act.py
│ │ ├── fused_bias_act.cpp
│ │ ├── fused_bias_act_kernel.cu
│ │ ├── __init__.py
│ │ ├── __pycache__
│ │ │ ├── fused_act.cpython-37.pyc
│ │ │ ├── __init__.cpython-37.pyc
│ │ │ └── upfirdn2d.cpython-37.pyc
│ │ ├── upfirdn2d.cpp
│ │ ├── upfirdn2d_kernel.cu
│ │ └── upfirdn2d.py
│ └── __pycache__
│ ├── dataset.cpython-37.pyc
│ ├── __init__.cpython-37.pyc
│ └── model.cpython-37.pyc
├── train.py
└── wget-log
53 directories, 167 files
???? 博主 AI 领域八大干货专栏、诚不我欺
- ???? 计算机视觉: Yolo专栏、一文读懂
- ???? 计算机视觉:图像风格转换--论文--代码测试
- ???? 计算机视觉:图像修复-代码环境搭建-知识总结
- ???? 计算机视觉:超分重建-代码环境搭建-知识总结
- ???? 深度学习:环境搭建,一文读懂
- ???? 深度学习:趣学深度学习
- ???? 落地部署应用:模型部署之转换-加速-封装
- ???? CV 和 语音数据集:数据集整理
???? 预祝各位 2022 前途似锦、可摘星辰
???? 作为全网 AI 领域 干货最多的博主之一,❤️ 不负光阴不负卿 ❤️
❤️ 如果文章对你有帮助、点赞、评论鼓励博主的每一分认真创作
❤️ 比寻找温暖更重要的是,让自己成为一盏灯火 ❤️
- 深度学习模型训练推理——基础环境搭建推荐博文查阅顺序【基础安装—认真帮大家整理了】——【1024专刊】
- ???? 最近更新:2022年1月20日
- ???? 点赞 ???? 收藏 ⭐留言 ???? 都是博主坚持写作、更新高质量博文的最大动力!