AI face change (supports video face change, supports cpu, low computing power) [with code]

You can directly select a face to replace the face in another picture or video. This project only provides the face replacement part, no data set, no training required!

Table of contents

project instruction

Environmental description

Preparation

how to use

disclaimer


project instruction

Reference source code for this project: GitHub - s0md3v/roop: one-click deepfake (face swap)

Because the above code has some problems in actual use, I have made adjustments in the original project code, which can be used on low-version torch and low-computing hardware, and supports the use in the windows environment.

I will upload some project resources to my cloud disk for you to download.

The quality of the face picture after changing the face is still relatively blurred , so everyone can only use it for entertainment and learning.

Environmental description

numpy>=1.21.6

opencv-python==4.7.0.72

onnx==1.11.0

insightface==0.7.3

psutil==5.9.5

tk==0.1.0

pillow>=9.1.1

torch>=1.7.0

onnxruntime-gpu==1.6.0

cuda:10.2

windows 10

onnxruntime-gpu should correspond to its own cuda version

My GPU is 1650 4G, and it can be reasoned only with CPU.


The effect diagram can be given below. Take my favorite Dou Break Sphere as an example, change Yunyun's face to that of Queen Medusa.

cloud rhyme

Medusa

Medusa after face change

Let's take a look at the video effect~

AI face change [Medusa face change cloud rhyme]

Preparation

Download code: git clone  https://github.com/YINYIPENG-EN/AI_face_swap.git

1. Put the inswapper_128.onnx weight in the directory.

2. Download buffalo_l.zip and extract it to the models file.

models/

|-- buffalo_l

| |-- 1k3d68.onnx

| |-- 2d106det.onnx

| |-- it_10g.onnx

| |-- genderage.onnx

| `-- w600k_r50.onnx

3. Find core/config.py and modify the face detection weight path in line 12. Here I am the roop of the F drive. So my buffalo_l is stored under F:/roop/models/.

FACE_ANALYSER=insightface.app.FaceAnalysis(name='buffalo_l',root='F:/roop/',providers=core.globals.providers)

4. ffmpeg installation. Decompress ffmpeg-6.0-full_build.7z, and add ffmpeg.exe under bin to the environment variable. Then copy ffmpeg.exe to your pytorch environment [just in the same directory as the python under torch]

Weight path:

Link: Baidu Netdisk Please enter the extraction code

Extract code: yypn

how to use

python run.py

If you want to use the GPU

python run.py --gpu

Then a GUI interface will come out.

Select a face is used to select the source face [only supports pictures], and Select a target is the face to be replaced [supports pictures and videos]. Then click Start

The running time of the program is related to your hardware and memory, so be patient. If your hardware environment is relatively poor, it may exit unexpectedly.

Video detection will be limited to 30FPS [enough].

disclaimer

Better deepfake software than this already exists, this is just a hobby project I created to learn about AI. Users should use this program to learn programming and use the software in good faith. Users must seek permission from the person concerned before using their face and must not conceal the fact that it is a deepfake when posting content online. I am not responsible for the malicious actions of end users.

Better deepfake software than this already exist, this is just a hobby project I created to learn about AI. Users are expected to use this program for learning programming and using the software in good faith. Users must get consent from the concerned people before using their face and must not hide the fact that it is a deepfake when posting content online. I am not responsible for malicious behaviour of end-users.

Guess you like

Origin blog.csdn.net/z240626191s/article/details/131067635