当前位置:网站首页>Test of the opposite sex what you look like?
Test of the opposite sex what you look like?
2022-08-10 05:55:00 【programming fun】
A lot of people may not find it strange to know PS and use it as a graphics software to be a self of the opposite sex.But isn't it more interesting that we are today, generated with artificial intelligence?
This kind of AI function implementation involving images, friends who understand deep learning will know some.It is often implemented with the very popular GAN generative adversarial network, or DCGAN.And the use of AI to make the opposite sex self mentioned in this article is to use a gender conversion function of PaddleGAN.In other words, it is to use the face attribute editing ability in PaddleGAN to realize gender transformation of any face!
I. Environment preparation
Download PaddleGAN
git clone https://github.com/PaddlePaddle/PaddleGANorgit clone https://gitee.com/PaddlePaddle/PaddleGANInstall PaddleGAN locally
#Enter PaddleGAN directorycd /home/aistudio/PaddleGAN#install dependenciespip install -r requirements.txt#Install PaddleGAN locallypython setup.py developInstall dlib
pip install dlibIf the arrangement of dlib fails, please go to the official website to download the corresponding whl version and install it manually.
Second, Extract the Latent Code of the original image
Here we use Pixel2Style2Pixel to extract Latent Code, you only need to change two parameters:
input_image: the original image path, that is, the photo path where hidden features need to be extractedoutput_path: The storage path of the hidden features of the original image, which needs to be used in the attribute editing and generation module later
Put the face photo of the face you want to change gender in the input_image part, please note that it is best to take a selfie and a big head photo, the effect is better without glasses~
Command method:
cd applications/python -u tools/pixel2style2pixel.py --input_image '/home/aistudio/face test set/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 2Programmatically:
import paddlefrom ppgan.apps import Pixel2Style2PixelPredictorpredictor = 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')Three, generate the opposite sex you
Edit the Latent Code in a specific direction, and use StyleGAN V2 to generate a new face from the edited vector.
Command method:
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 #Convert positive numbers from female to male, and negative numbers from male to female, Programmatically
import paddlefrom ppgan.apps import StyleGANv2EditingPredictorpredictorEditing = 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 #positive numbers are converted from female to male, and negative numbers are converted from male to femalepredictorEditing.run(dstNpyPath, "gender", direction_offset)Four, the final conversion result

Okay, I'll share it here today. If you have any ideas, please leave a message for discussion.
边栏推荐
- 力扣——情侣牵手
- Using sqlplus to operate database in shell script
- impdp import data
- 十年磨一剑!数字藏品行情软件,链读APP正式开放内测!
- cesium rotate image
- Mini Program Study Notes: Communication between Mini Program Components
- Ten years of sharpening a sword!The digital collection market software, Link Reading APP is officially open for internal testing!
- pytorch-07.处理多维特征的输入
- 链读好文:Jeff Garzik 推出 Web3 制作公司
- 操作表 函数的使用
猜你喜欢
随机推荐
网络安全之防火墙
Notes 1
栈和队列
[List Exercise] Traverse the collection and sort by price from low to high,
Small program wx.request simple Promise package
pytorch-10.卷积神经网络(作业)
MySql 约束
transaction, storage engine
error in ./node_modules/cesium/Source/ThirdParty/zip.js
LeetCode 938.二叉搜索树的范围和(简单)
最新最全的数字藏品发售日历-07.27
Knowledge Distillation Thesis Learning
基于 .NET Core MVC 的权限管理系统
【笔记】集合框架体系 Collection
MySQL中MyISAM为什么比InnoDB查询快
多表查询 笔记
Collection tool class
复杂的“元宇宙”,为您解读,链读APP即将上线!
Common class String overview
深度学习TensorFlow入门环境配置









