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

目录
相关文章
|
JSON 前端开发 数据格式
【前后端异常】http/https post请求 返回415错误状态码的解决方法
【前后端异常】http/https post请求 返回415错误状态码的解决方法
7566 0
|
网络协议 网络安全
openWRT软路由AdGuardHome 未运行 未重定向无法更新核心解决办法
openWRT软路由AdGuardHome 未运行 未重定向无法更新核心解决办法
16041 0
|
XML JavaScript Java
【JAVA XML 探秘】DOM、SAX、StAX:揭秘 Java 中 XML 解析技术的终极指南!
【8月更文挑战第25天】本文详细探讨了Java中三种主流的XML解析技术:DOM、SAX与StAX。DOM将XML文档转换为树状结构,便于全方位访问和修改;SAX采取事件驱动模式,适用于大型文件的顺序处理;StAX则兼具DOM和SAX的优点,支持流式处理和随机访问。文中提供了每种技术的示例代码,帮助读者理解如何在实际项目中应用这些解析方法。
702 1
|
机器学习/深度学习 边缘计算 PyTorch
PyTorch团队为TorchAO引入1-8比特量化,提升ARM平台性能
PyTorch团队推出创新技术,在其低精度计算库TorchAO中引入低位运算符支持,实现1至8位精度的嵌入层权重量化及8位动态量化激活的线性运算符。该技术通过模块化设计和高效硬件利用,优化了资源受限环境下的深度学习计算,提升了计算效率并降低了资源消耗。新内核与PyTorch生态系统无缝集成,支持即时执行、编译优化及边缘计算,为开发者提供全方位性能优势。测试结果显示,多层次量化策略显著提升了计算效率,保持了模型精度。这一突破为深度学习框架优化开辟了多个研究方向,推动了人工智能在边缘计算等领域的广泛应用。
466 11
PyTorch团队为TorchAO引入1-8比特量化,提升ARM平台性能
|
机器学习/深度学习 人工智能 调度
高效评估多模态预训练对齐质量,中科大提出模态融合率MIR
中国科学技术大学研究团队提出了一种新的评估指标——模态融合率(MIR),用于评估多模态预训练模型的对齐质量。MIR通过衡量不同模态之间的分布距离,有效反映了模型的对齐质量,并在多种训练配置下表现出良好的鲁棒性和通用性。实验结果表明,MIR能够准确评估训练数据选择、训练策略调度和模型架构设计对预训练结果的影响,为多模态学习提供了可靠的方法。
504 22
|
人工智能 自然语言处理 算法
Jarvis×百炼,打造大模型智慧出行客服
本次分享由哈啰集团高级算法专家郭佳盛主讲,主题为“Jarvis×百炼,打造大模型智慧出行客服”。内容涵盖AI在智慧出行领域的应用探索、AI加持客服全链路解决方案、哈罗智能客服的大模型应用、大模型在C端与B端的应用探索,以及企业内部大模型构建与运营。通过实例和经验分享,展示了哈啰如何将大模型应用于实际业务,提升用户体验和运营效率。
|
搜索推荐 Linux Shell
在Linux中,如何创建一个新用户?
在Linux中,如何创建一个新用户?
ERROR: No matching distribution found for tb-nightly
ERROR: No matching distribution found for tb-nightly
803 1
|
存储 缓存 Docker
Docker镜像构建:深入Dockerfile创建自定义镜像
Docker的强大之处在于其能够通过Dockerfile定义和构建自定义镜像,为应用提供独立、可移植的运行环境。在这篇博客文章中,将深入探讨Docker镜像构建的核心概念,通过更加丰富的示例代码,帮助大家全面理解和掌握构建自定义镜像的技术。
|
编解码
笔记本的常见分辨率
笔记本的常见分辨率