当前位置:网站首页>测一测异性的你长什么样?
测一测异性的你长什么样?
2022-08-10 05:32:00 【编程乐趣】
懂PS的,用作图软件做一个异性的自己,可能很多人不觉得稀奇。但我们今天,用人工智能生成的,岂不是更有趣?
这类涉及到图像的AI功能实现,了解深度学习的朋友会知道一些。往往就是用当下很火的GAN生成式对抗网络来实现的,或者说是用DCGAN。而本文谈到的用AI来制作异性的自己,就是用到PaddleGAN的一个性别转换的功能。换句话说,是用PaddleGAN中的人脸属性编辑能力,实现将任意人脸进行性别变换!
一、环境准备
下载PaddleGAN
git clone https://github.com/PaddlePaddle/PaddleGAN
或者
git clone https://gitee.com/PaddlePaddle/PaddleGAN本地安装PaddleGAN
#进入PaddleGAN目录
cd /home/aistudio/PaddleGAN
#安装依赖
pip install -r requirements.txt
#本地安装PaddleGAN
python setup.py develop安装dlib
pip install dlibdlib如果安排失败的,请到官网下载相应的whl版本,手动安装。
二、提取原图Latent Code
这里我们使用Pixel2Style2Pixel提取Latent Code,大家只需要更改两个参数:
input_image:原图路径,即需要提取隐藏特征的照片路径output_path:原图的隐藏特征的存放路径,后续需要放在属性编辑和生成的模块中使用
将input_image部分放上想要变换性别的人脸照片即可,请注意最好是自拍和大头照,无眼镜效果更佳噢~
命令方式:
cd applications/
python -u tools/pixel2style2pixel.py
--input_image '/home/aistudio/人脸测试集/yingbb2.png'
--output_path '/home/aistudio/psp_output/yingbb2'
--model_type ffhq-inversion
--seed 233
--size 1024
--style_dim 512
--n_mlp 8
--channel_multiplier 2编程方式:
import paddle
from ppgan.apps import Pixel2Style2PixelPredictor
predictor = Pixel2Style2PixelPredictor(
output_path="outputs",
weight_path=None,
model_type="ffhq-inversion",
seed=233,
size=1024,
style_dim=512,
n_mlp=8,
channel_multiplier=2)
predictor.output_path = 'outputs'
predictor.run('inputs/src.png')三、生成异性的你
对Latent Code进行特定方向编辑,使用StyleGAN V2将编辑后的向量生成新人脸。
命令方式:
python -u tools/styleganv2editing.py
--latent '/home/aistudio/psp_output/11/dst.npy'
--output_path '/home/aistudio/final_output/11'
--model_type ffhq-config-f
--size 1024
--style_dim 512
--n_mlp 8
--channel_multiplier 2
--direction_name gender
--direction_offset 5 #正数从女转换为男,负数男转变为女,编程方式
import paddle
from ppgan.apps import StyleGANv2EditingPredictor
predictorEditing = StyleGANv2EditingPredictor(
output_path="outputs",
weight_path=None,
model_type="ffhq-config-f",
seed=None,
size=1024,
style_dim=512,
n_mlp=8,
channel_multiplier=2,
direction_path=None)
dstNpyPath="outputs/dst.npy"
predictorEditing.output_path = 'outputs'
direction_offset = 5 #正数从女转换为男,负数男转变为女
predictorEditing.run(dstNpyPath, "gender", direction_offset)四、最终转换的结果

好了,今天就分享到这边,大家有什么想法,欢迎给我留言讨论。
边栏推荐
猜你喜欢

力扣——省份数量

棋类游戏-五子棋小游戏

反射【笔记】

优先队列

The complex "metaverse" will be interpreted for you, and the Link Reading APP will be launched soon!

Chain Reading|The latest and most complete digital collection sales calendar-08.02

MySql constraints

用Pytorch从0到1实现逻辑回归

ORACLE system table space SYSTEM is full and cannot expand table space problem solving process

常用类 String概述
随机推荐
sqlplus 显示上一条命令及可用退格键
ORACLE system table space SYSTEM is full and cannot expand table space problem solving process
R绘制图像,图像特征提取
network security firewall
第二次实验
作业实验四
各个架构指令集对应的机型
PCL点云滤波
链读精选:星巴克着眼于数字收藏品并更好地吸引客户
第六次实验
反射【笔记】
idm下载器如何使用 idm下载器使用技巧
2021-06-22
第十天作业
链读推荐:从瓷砖到生成式 NFT
行盒子的盒模型
AWR1843型号毫米波雷达使用
网络安全作业
链读好文:热加密存储与冷加密存储有什么区别?
String常用方法