Spaces:
Running
Running
A newer version of the Gradio SDK is available:
5.33.0
README.md
π§ Swap Face and Hair with Mask Detection
This project swaps both face and hair from a source image to a target image using:
- SegFormer (for hair segmentation)
- MediaPipe FaceMesh (for facial structure)
- NumPy and OpenCV for blending
π§ Setup (Google Colab or local Python)
pip install -r requirements.txt
π Project Structure
swap_face_and_hair.py
: main code logicrequirements.txt
: dependenciesREADME.md
: this file
π How to Use
from PIL import Image
import numpy as np
from swap_face_and_hair import swap_face_and_hair
source_img = Image.open("source.jpg")
target_img = Image.open("target.jpg")
result = swap_face_and_hair(np.array(source_img), np.array(target_img))
result.save("result.jpg")
π Notes
- Make sure your source image has clear face + hair in frontal view.
- Target image should ideally be of similar resolution and head pose.
- GPU recommended for faster processing.
Made with β€οΈ using HuggingFace Transformers and MediaPipe.