A newer version of the Gradio SDK is available: 6.19.0
metadata
title: Face Swap
emoji: π
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 6.13.0
app_file: app.py
pinned: false
Screenshot
About
Face Swap is a simple web application that lets you swap faces between two images. Upload an original image containing the face you want to replace, and a reference image with the new face to apply β the app handles the rest.
- One-click face swap β Upload two images and hit Submit
- Automatic face detection β Powered by TinyFace's ONNX-based pipeline
- Face enhancement β Built-in GFPGAN post-processing for natural results
- Web UI β Clean Gradio interface with drag-and-drop upload
Tech Stack
| Category | Technology |
|---|---|
| Frontend | Gradio |
| Backend | Python |
| AI/ML | TinyFace, ONNX Runtime |
| Face Detection | SCRFD |
| Face Recognition | ArcFace |
| Face Enhancement | GFPGAN |
| Deployment | Hugging Face Spaces |
Architecture
βββββββββββββββββββββββββββββββββββββββββββ
β Gradio Web UI β
β (Image Upload + Result Display) β
ββββββββββββββββββββ¬βββββββββββββββββββββββ
β
ββββββββββββββββββββΌβββββββββββββββββββββββ
β app.py β
β RGB β BGR conversion + validation β
ββββββββββββββββββββ¬βββββββββββββββββββββββ
β
ββββββββββββββββββββΌβββββββββββββββββββββββ
β TinyFace Pipeline β
β βββββββββββββ ββββββββββββ ββββββββββ β
β β SCRFD β β ArcFace β β GFPGAN β β
β β Detect βββ Swap βββEnhance β β
β βββββββββββββ ββββββββββββ ββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββ
Project Structure
faceswap/
βββ app.py # Main application (Gradio UI + swap logic)
βββ requirements.txt # Python dependencies
βββ screenshot.png # App screenshot
βββ README.md # This file
Getting Started
Prerequisites
- Python 3.10+
- pip
Installation
# Clone the repository
git clone https://github.com/alfredang/faceswap.git
cd faceswap
# Install dependencies
pip install -r requirements.txt
Running
python app.py
Open http://127.0.0.1:7860 in your browser.
Note: On first launch, TinyFace will automatically download the required models (~800MB total).
Deployment
Hugging Face Spaces
This app is deployed on Hugging Face Spaces. To deploy your own:
- Create a new Space with
GradioSDK - Upload
app.py,requirements.txt, and the HFREADME.mdwith Space metadata - The Space will auto-build and download models on first run
Contributing
Contributions are welcome!
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Join the Discussions for questions and ideas.
Powered by Tertiary Infotech Academy Pte Ltd
Acknowledgements
If you found this useful, please give it a β
