• Stars
    star
    327
  • Rank 128,686 (Top 3 %)
  • Language
    Python
  • Created over 1 year ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

One-click Face Swapper and Restoration powered by insightface 🔥

inswapper

One-click Face Swapper and Restoration powered by insightface. We don't use the name ROOP here, as the credit should be given to the group that develops this great face swap model.

News

🔥 We release InstantID as a state-of-the-art ID preservering generation method.

Installation

# git clone this repository
git clone https://github.com/haofanwang/inswapper.git
cd inswapper

# create a Python venv
python3 -m venv venv

# activate the venv
source venv/bin/activate

# install required packages
pip install -r requirements.txt

You have to install onnxruntime-gpu manually to enable GPU inference, install onnxruntime by default to use CPU only inference.

Download Checkpoints

First, you need to download face swap model and save it under ./checkpoints. To obtain better result, it is highly recommended to improve image quality with face restoration model. Here, we use CodeFormer. You can finish all as following, required models will be downloaded automatically when you first run the inference.

mkdir checkpoints
wget -O ./checkpoints/inswapper_128.onnx https://github.com/facefusion/facefusion-assets/releases/download/models/inswapper_128.onnx

cd ..
git lfs install
git clone https://huggingface.co/spaces/sczhou/CodeFormer

Quick Inference

from swapper import *

source_img = [Image.open("./data/man1.jpeg"),Image.open("./data/man2.jpeg")]
target_img = Image.open("./data/mans1.jpeg")

model = "./checkpoints/inswapper_128.onnx"
result_image = process(source_img, target_img, -1, -1, model)
result_image.save("result.png")

To improve to quality of face, we can further do face restoration as shown in the full script.

python swapper.py \
--source_img="./data/man1.jpeg;./data/man2.jpeg" \
--target_img "./data/mans1.jpeg" \
--face_restore \
--background_enhance \
--face_upsample \
--upscale=2 \
--codeformer_fidelity=0.5

You will obtain the exact result as above.

Acknowledgement

This project is inspired by inswapper, thanks insightface.ai for releasing their powerful face swap model that makes this happen. Our codebase is built on the top of sd-webui-roop and CodeFormer.

Contact

If you have any issue, feel free to contact me via [email protected].

More Repositories

1

ControlNet-for-Diffusers

Transfer the ControlNet with any basemodel in diffusers🔥
Python
743
star
2

Lora-for-Diffusers

The most easy-to-understand tutorial for using LoRA (Low-Rank Adaptation) within diffusers framework for AI Generation Researchers🔥
Python
684
star
3

Score-CAM

Official implementation of Score-CAM in PyTorch
Python
379
star
4

awesome-conditional-content-generation

Update-to-data resources for conditional content generation, including human motion generation, image or video generation and editing.
212
star
5

Awesome-Computer-Vision

Awesome Resources for Advanced Computer Vision Topics
209
star
6

video-swin-transformer-pytorch

Video Swin Transformer - PyTorch
Python
188
star
7

natural-language-joint-query-search

Search photos on Unsplash based on OpenAI's CLIP model, support search with joint image+text queries and attention visualization.
Jupyter Notebook
184
star
8

T2I-Adapter-for-Diffusers

Transfer the T2I-Adapter with any basemodel in diffusers🔥
125
star
9

CLIFF

This repo equips the official CLIFF [ECCV 2022 Oral] with better detector, better tracker. Support multi-person, motion interpolation, motion smooth and SMPLify fitting.
Python
113
star
10

awesome-mlp-papers

Recent Advances in MLP-based Models (MLP is all you need!)
110
star
11

accurate-head-pose

Pytorch code for Hybrid Coarse-fine Classification for Head Pose Estimation
Python
97
star
12

Train-ControlNet-in-Diffusers

We show you how to train a ControlNet with your own control hint in diffusers framework
52
star
13

mxnet-Head-Pose

An MXNet implementation of Fine-Grained Head Pose
Python
47
star
14

cropimage

A simple toolkit for detecting and cropping main body from pictures. Support face and saliency detection.
Python
34
star
15

awesome-vision-language-modeling

Recent Advances in Vision-Language Pre-training!
25
star
16

visbeat3

Python3 Implementation for 'Visual Rhythm and Beat' SIGGRAPH 2018
Python
16
star
17

DWPose

Inference code for DWCode
Python
15
star
18

Multi-Frame-Rendering-in-Diffusers

7
star
19

stable-diffusion-xl-handbook

6
star
20

mmdet_benchmark

mmdetection、mmdeploy 中的 Mask R-CNN 深度优化
Python
5
star
21

Anime-Facial-Landmarks

Python
4
star
22

lora-block-weight-diffusers

When applying Lora, strength can be set block by block. Support for diffusers framework.
Python
3
star
23

mxnet-Hand-Detection

A simple headmap regression for hand detection
Python
2
star
24

CS188-Project

CS188 Project Fall 2017 Berkeley
Python
1
star
25

pytorch-distributed-training

A simple cookbook for DDP training in Pytorch
Python
1
star
26

KGRN-SR

Official Implementation for Knowledge Graph Routed Network for Situation Recognition [TPAMI'2023]
Python
1
star
27

SD3-diffusers

Stable Diffusion 3 in diffusers
1
star