MCPcopy Index your code
hub / github.com/MingtaoGuo/StyleSwap

github.com/MingtaoGuo/StyleSwap @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
315 symbols 724 edges 25 files 47 documented · 15%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

StyleSwap

Unofficial implementation of the paper: StyleSwap: Style-Based Generator Empowers Robust Face Swapping

Description


This repo is mainly to re-implement the face swap paper based on stylegan - StyleSwap: StyleSwap: Style-Based Generator Empowers Robust Face Swapping

Getting Started

Prerequisites

  • Linux or macOS
  • NVIDIA GPU + CUDA CuDNN
  • Python 3

Installation

  • Clone the repository:
git clone https://github.com/MingtaoGuo/StyleSwap.git
cd StyleSwap
  • Dependencies:
    We recommend running this repository using Anaconda. All dependencies for defining the environment are provided in environment.yaml.

Train

  • Download the face parsing model from faceparsing
  • Download the face recognition model arcface from insightface Go to Baidu Drive -> arcface_torch -> glint360k_cosface_r50_fp16_0.1 -> backbone.pth

  • Generate face mask by faceparsing

python face_parsing/face_parsing.py --img_dir face_dataset --res_dir face_mask_dataset --resolution 256 --model_path saved_models/79999_iter.pth 
  • Train StyleSwap
python train_simple.py --img_path face_dataset --mask_path face_mask_dataset --arcface saved_models/backbone.pth 

Inference

  • Pretrained model is coming soon!

Author

Mingtao Guo E-mail: gmt798714378 at hotmail dot com

Reference

[1]. Xu, Zhiliang, et al. "StyleSwap: Style-Based Generator Empowers Robust Face Swapping." arXiv preprint arXiv:2209.13514 (2022).

Core symbols most depended-on inside this repo

get_block
called by 12
training/loss/helpers.py
add_path
called by 5
__init_paths.py
_iresnet
called by 5
face_model/arcface.py
backward
called by 5
face_model/op/upfirdn2d.py
requires_grad
called by 4
train_simple.py
get_world_size
called by 4
distributed.py
forward
called by 4
training/lpips/lpips.py
save
called by 4
training/lpips/trainer.py

Shape

Method 150
Function 105
Class 59
Route 1

Languages

Python99%
C++1%

Modules by API surface

face_model/gpen_model.py64 symbols
face_parsing/bisenet.py33 symbols
training/data_loader/degradations.py30 symbols
training/lpips/lpips.py24 symbols
training/lpips/trainer.py20 symbols
face_model/arcface.py16 symbols
training/loss/helpers.py15 symbols
training/lpips/__init__.py14 symbols
training/lpips/pretrained_networks.py12 symbols
face_parsing/resnet.py10 symbols
face_model/op/fused_act.py10 symbols
training/loss/model_irse.py9 symbols

For agents

$ claude mcp add StyleSwap \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact