high / readme.md
VanNguyen1214's picture
Update readme.md
01787eb verified

A newer version of the Gradio SDK is available: 5.33.0

Upgrade

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 logic
  • requirements.txt: dependencies
  • README.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.