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

简介: 风格迁移、一文读懂
🥇 版权: 本文由【墨理学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

1-2

1-3

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

du -sh

20G     .

项目数据部分目录结构

1-5

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

2-1

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

2-2

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


2-3-0

单卡 GPU 占用 8793MiB

2-3

重建得到的 nose

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

2-4

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

2-5

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

2-6-2

  • 细修复结果: 135_fine.png

2-6-3

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

生成【化妆】效果如下

2-7

运行输出如下【运行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 领域八大干货专栏、诚不我欺


📙 预祝各位 2022 前途似锦、可摘星辰

🎉 作为全网 AI 领域 干货最多的博主之一,❤️ 不负光阴不负卿 ❤️
❤️ 如果文章对你有帮助、 点赞、评论鼓励博主的每一分认真创作
❤️ 比寻找温暖更重要的是,让自己成为一盏灯火 ❤️

9.png

目录
相关文章
|
3月前
|
并行计算 Linux 计算机视觉
还在手工标注数据集?快来试一试自动化多模型标注大模型-gui交互式标注(部署运行教程-高效生产力)
还在手工标注数据集?快来试一试自动化多模型标注大模型-gui交互式标注(部署运行教程-高效生产力)
93 0
|
6月前
|
人工智能 自然语言处理 安全
【网安AIGC专题10.19】论文3代码生成:ChatGPT+自协作代码生成+角色扮演(分析员、程序员、测试员)+消融实验、用于MBPP+HumanEval数据集
【网安AIGC专题10.19】论文3代码生成:ChatGPT+自协作代码生成+角色扮演(分析员、程序员、测试员)+消融实验、用于MBPP+HumanEval数据集
116 0
|
机器学习/深度学习 PyTorch 算法框架/工具
如何将模糊照片人脸恢复清晰,GFPGAN机器学习开源项目使用 | 机器学习
如何将模糊照片人脸恢复清晰,GFPGAN机器学习开源项目使用 | 机器学习
如何将模糊照片人脸恢复清晰,GFPGAN机器学习开源项目使用 | 机器学习
|
10月前
图像风格迁移
图像风格迁移
79 0
|
8月前
|
自然语言处理 测试技术 网络安全
中文大模型能力缺陷和改进方向:来自双盲测评的发现
近年来,预训练语言模型在自然语言处理任务上的应用取得长足进展。作为该类模型的重要代表之一,中文预训练语言模型也得到广泛关注。然而,中文预训练模型的真实语言理解和生成能力如何,目前还存在争议。为客观评估主流中文预训练模型的优劣,本研究采用中文竞技场,以双盲测试的原则,设计了系统的模型测评方案。
|
8月前
|
自然语言处理 人工智能
中文竞技场大模型测评后续之模型自动对话
中文竞技场大模型测评延续中,模型自动对话场景测评
317 0
中文竞技场大模型测评后续之模型自动对话
|
9月前
|
人工智能 JSON 数据格式
HarmonyOS学习路之开发篇—AI功能开发(文档检测校正)
基本概念 文档校正提供了文档翻拍过程的辅助增强功能,包含两个子功能:
|
12月前
|
数据可视化 PyTorch 算法框架/工具
AIGC背后的技术分析 | 图像风格迁移
本文为实战篇,介绍图像风格迁移
306 0
AIGC背后的技术分析 | 图像风格迁移
|
12月前
|
计算机视觉
ELITE项目原作解读:基于扩散模型的快速定制化图像生成
ELITE项目原作解读:基于扩散模型的快速定制化图像生成
|
12月前
|
存储 测试技术 数据库
「机会和方案」TOGAF建模:项目环境图
「机会和方案」TOGAF建模:项目环境图