0
点赞
收藏
分享

微信扫一扫

StyleMapGAN之celeba_hq 风格迁移 - 图像编辑、实验测评【二】

  • ???? 版权: 本文由【墨理学AI】原创、各位大佬、一文读懂、敬请查阅
  • ???? 声明: 作为全网 AI 领域 干货最多的博主之一,❤️ 不负光阴不负卿 ❤️

StyleMapGAN 创作如下

​​StyleMapGAN、有趣的风格迁移——评测【一】 ​​

StyleMapGAN 基于 StyleGAN2 改进

论文题目

Exploiting Spatial Dimensions of Latent in GAN for Real-time Image Editing

所运行代码 + paper

  • ​​github.com/naver-ai/St…​​
  • ​​arxiv.org/pdf/2104.14…​​

本博文记录StyleMapGAN 预训练模型 在 celeba_hq 测试数据上的 生成效果

  • 环境搭建参考上一篇博文即可

celeba_hq 测试数据 + 预训练模型准备

# 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

StyleMapGAN之celeba_hq 风格迁移 - 图像编辑、实验测评【二】_sed

StyleMapGAN之celeba_hq 风格迁移 - 图像编辑、实验测评【二】_2d_02

整个项目 + 以上命令下载解压的数据 ,总共就 占用 20G 存储

du -sh

20G .

项目数据部分目录结构

StyleMapGAN之celeba_hq 风格迁移 - 图像编辑、实验测评【二】_sed_03

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

StyleMapGAN之celeba_hq 风格迁移 - 图像编辑、实验测评【二】_2d_04

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

StyleMapGAN之celeba_hq 风格迁移 - 图像编辑、实验测评【二】_python_05

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

StyleMapGAN之celeba_hq 风格迁移 - 图像编辑、实验测评【二】_2d_06

单卡 GPU 占用 8793MiB

StyleMapGAN之celeba_hq 风格迁移 - 图像编辑、实验测评【二】_sed_07

重建得到的 nose

StyleMapGAN之celeba_hq 风格迁移 - 图像编辑、实验测评【二】_sed_08

synthesized_image 生成的鼻子如下【也有少许失败样例】

StyleMapGAN之celeba_hq 风格迁移 - 图像编辑、实验测评【二】_人工智能_09

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

StyleMapGAN之celeba_hq 风格迁移 - 图像编辑、实验测评【二】_计算机视觉_10

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

StyleMapGAN之celeba_hq 风格迁移 - 图像编辑、实验测评【二】_计算机视觉_11

  • 细修复结果: 135_fine.png

StyleMapGAN之celeba_hq 风格迁移 - 图像编辑、实验测评【二】_人工智能_12

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

生成【化妆】效果如下

StyleMapGAN之celeba_hq 风格迁移 - 图像编辑、实验测评【二】_人工智能_13

运行输出如下【运行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 领域 干货最多的博主之一,❤️ 不负光阴不负卿 ❤️
  • ❤️ 如果文章对你有帮助、点赞、评论鼓励博主的每一分认真创作
  • ???? 目标检测、超分重建、图像修复、数据集整理 四大专栏持续更新、敬请关注

StyleMapGAN之celeba_hq 风格迁移 - 图像编辑、实验测评【二】_2d_14

举报

相关推荐

0 条评论