Today, I’m going to introduce you to an AI black technology, which can perfectly realize the gender transformation of human face, with rich expression, so that you not only have an object in an instant, but also see the other side of yourself, afraid that you accidentally fall in love with yourself.

Without further ado, go straight to the picture above!

Little sister turned handsome little brother \ (o) /

˚ · *♡ॢ˃̶̤̀ ♡ ˂̶̤́♡ॢ* · ˚

What’s more, Big Brother can also transform into ¬ ¬‿¬ ¬ in an instant.

Can’t get enough of the beautiful woman and the handsome man jumping back and forth? One time for everyone!

Eager to GET objects? Not fast to the project home page experience!

⭐⭐ Project link ⭐⭐

Github.com/PaddlePaddl…

Such a powerful, careful project, I hope to give you a Star🌟 developers to encourage, at the same time to master the cutting-edge GAN algorithm tutorial dry!

Isn’t that enough? What are the implementation steps? Xiaobian all meet you!

Principle revealed

StyleGAN V2 and FOM are built into this amazing project to edit face attributes (character transformation) and animate face effects respectively! It can be divided into three steps:

1. Obtain image Latent Code for subsequent attribute editing and face generation

2. According to the specific direction of Latent Code to edit, you can edit the corresponding face attributes, such as age, gender, hair, eyes, etc

3. StyleGAN V2 generates the target face according to the Latent Code vector edited in step 2

* Latent Code: Latent factor, each image corresponds to a Latent factor (a higher dimensional vector), which StyleGAN V2 can use to generate images

Real operating steps

(˘▾˘) You can go to the AI Studio project homepage and use the platform’s free GPU computing power to achieve your own “gender change”.

AI Studio Project Complete project (can use GPU free computing power to run with one click) link:

Aistudio.baidu.com/aistudio/pr…

STEP 1: Extract the Latent Code corresponding to the original image

Here we use Pixel2Style2Pixel to extract Latent Code, you only need to change two parameters:

1. Input_image: original image path, that is, the image path to extract hidden features

2. Output_path: The storage path of hidden features of the original image, which needs to be used in attribute editing and generated modules

Place the input_image section on the path of the face photo that you want to change gender. Please note that it is best to take a selfie or a headshot. It is better without glasses

%cd applications/ ! Python -u tools/pixel2style2pixel. Py \ -- -- input_image '/ home/aistudio/face test set / 11. JPG' \ - output_path '/home/aistudio/psp_output/11' \ --model_type ffhq-inversion \ --seed 233 \ --size 1024 \ --style_dim 512 \ --n_mlp 8 \ --channel_multiplier 2Copy the code

STEP 2&3: Edit Latent Code in a specific direction and use StyleGAN V2 to generate a new face

Only two parameters need to be changed:

1. Atent: The Latent Code path of the original image extracted in STEP 1

2. Output_path: save path of new face (after gender change)

! 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 -5Copy the code

💟 BONUS experience: Make the opposite sex you “move” up 💟

It is worth mentioning that the First Order Motion algorithm provided in this project can move the facial action of character A to the face of character B, so that character B’s face can perfectly interpret the expression of character A:

Therefore, based on the expression transfer ability mentioned above, this project can self-made facial action video (drive video), so that you of the opposite sex can have your customized expression for him/her ~

%cd applications ! Python -u tools/first-order-demo.py \ --driving_video '/home/aistudio/ driver video MOV' \ --source_image '/home/aistudio/final_output/female-cui/dst.editing.png' \ --relative \ --adapt_scale \ --output '/home/aistudio/ your dynamic version of the opposite sex '\ --image_size 512 \ --face_enhancementCopy the code

What are you waiting for? ! Let’s give it a try!

More AI capabilities revealed

What other awesome capabilities does this project have?

Small make up on the project home page turn a circle found that face attribute editor, facial expression migration was just one of dozens of ability turn this magical project also provides voice lip (sound of mouth), video/photo fix (color, super, insert the frame), facial animation, photographs, animation, image generation and migration image style, more than 10 kinds of ability, was a real eye-opener!

Let’s take a look

Girl with a Pearl Earring

Century-old image coloring, frame insertion, and resolution improvement:

Face animation:

Welcome all talented developers to play the above abilities, if you have fun, hard Star to support the open source community spirit ~

Github.com/PaddlePaddl…

Finally,, I hope this small project can bring happiness and warmth to everyone in this cold Double Eleven. With the company of this project, we can never feel lonely!