Face Swap using AI | #deepfake in just 5 lines of python code

preview_player
Показать описание
Introduction to #deepfake face swap in pictures using only python and open source libraries.

Steps:
1. Install Insightface, ONNX Runtime, opencv
2. Use Insightface face analysing model to detect faces in both source and target frame.
3. Use Inswapper model from Huggingface to swap faces

My python Notebook on Github:

Insightface:

CMake (Windows):

C++ build tools (Windows):

ONNX Runtime:

Insightface model for faceanalysis:

HuggingFace inswapper model:

#generativeai
Рекомендации по теме
Комментарии
Автор

thanks for the sharing.
Unfortunately I am not a good programmer or coder, and I use ComfyUI to perform face swapping.
So if you know about ReActor, it seems the code here and ReActor both uses inswapper model for face swapping. It means it is almost identical methods or here with this code we can achieve better results?

aliyilmaz
Автор

very nice, btw how to download swapped image to local storage ? thank you

whitequote-bsvj
Автор

Thank you for sharing. Do you have documentation for inswapper_128? Can you provide it to me? :(

canhdz
Автор

Invalid Protobuf: [ONNXRuntimeError]: 7: INVALID_PROTOBUF: Load model from / content/insightface/models/ inswapper_128.onnx failed: Protobuf parsing failed. Please help

harish_r