Home
Login

FaceSwap is a deep learning-based face swapping tool that can identify and swap faces in images and videos.

GPL-3.0Python 54.2kdeepfakesfaceswap Last Updated: 2025-05-21

FaceSwap - Deep Learning Face Swapping Tool

Project Overview

FaceSwap is a tool that utilizes deep learning technology to identify and swap faces in images and videos. The project is open-source and can run on multiple operating systems such as Windows, Linux, and MacOS.

Project Principles

The FaceSwap project has clear ethical standards and usage principles:

Positive Uses

  • For experimentation and discovery of AI technology
  • Social or political commentary
  • Film making
  • Other ethical and reasonable uses
  • To provide education and experience for anyone who wants to learn AI firsthand

Prohibited Uses

  • Must not be used to create inappropriate content
  • Must not swap faces without consent or with the intention of concealing usage
  • Must not be used for any illegal, unethical, or questionable purposes

Technical Features

System Requirements

  • Python program
  • Supports multiple operating systems (Windows, Linux, MacOS)
  • Requires a modern GPU and CUDA support for optimal performance
  • Supports many AMD GPUs through DirectML (Windows) and ROCm (Linux)

Main Functional Modules

  1. Face Extraction: Extracts faces from original photos
  2. Model Training: Trains a model based on the extracted faces
  3. Face Conversion: Uses the trained model to perform face swapping
  4. GUI Interface: Provides a graphical user interface

Usage Flow

Basic Steps

  1. Collect Materials: Prepare photos and/or videos
  2. Face Extraction: Extract faces from original photos
  3. Model Training: Train a model on the extracted faces
  4. Conversion Application: Use the model to convert source materials

Command Line Operations

Face Extraction

python faceswap.py extract

This command will extract photos from the src folder and extract faces to the extract folder.

Model Training

python faceswap.py train

This command will train using folders containing two face images, and the trained model will be saved in the models folder.

Face Conversion

python faceswap.py convert

This command will get photos from the original folder and apply the new face to the modified folder.

GUI Interface

python faceswap.py gui

Video Processing

Videos can be processed in the following ways:

python tools.py effmpeg -h

Or use ffmpeg to convert the video to photos, process the images, and then convert the images back to video.

Project Architecture

Main Models

  • Phaze-A Model
  • Villain Model
  • Unbalanced Model
  • OHR Model
  • DFL-H128 Model
  • DFaker Model

Core Components

  • FAN Aligner
  • MTCNN Detector
  • GUI Interface

Getting Help

Documentation Resources

  • INSTALL.md: Complete installation instructions
  • USAGE.md: Detailed usage instructions
  • All scripts have -h/--help options

Machine Learning Principles

FaceSwap works based on deep learning and neural network technology. Simply put, it works by:

  • Training Data + Trial and Error = Learning Process

The computer learns how to recognize and shape faces through a large amount of training data. This is a complex machine learning process involving deep training of neural networks.

Technical Background

When face swapping technology was first developed and released, it was groundbreaking and a huge step in AI development. Before "deepfakes," these technologies were like black magic, only practical for those who could understand all the inner workings. The advent of FaceSwap changed all of this, allowing anyone to participate in AI development without having a PhD in mathematics, computer theory, psychology, etc.

Precautions

  • Reusing existing models is much faster than training from scratch
  • If there is insufficient training data, you can start with similar people and then switch data
  • The project strictly adheres to ethical standards and takes a zero-tolerance approach to any inappropriate use
  • All related runtime code issues must be raised in the FaceSwap forum

Star History Chart