MagicMirror is a Python application that uses computer vision; image processing and deep learning to transfer hairstyles from a face (a source image) to another (a target image).
Deep learning is applied to recognize face shapes, which is then used to filter user hairstyle feeds to only display faces with similar face shapes to ensure high quality Hair Transfer.
Implicitly, hair transfer uses face swapping but a modest attempt is made here to emphasize on hair features of the target image.
TensorFlow was used for deep learning. The Inception V3 deep learning model was retrained to recognize five face shapes.
- Python 3.6+
- pip package manager
-
Create and activate a virtual environment
# Create virtual environment python3 -m venv myenv # Activate virtual environment # On Unix/macOS: source myenv/bin/activate # On Windows: myenv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
Running the Application
Development mode
python app/main.pyor
flask run
Production Deployment
This project uses a Procfile for deployment.
Procfile
web: gunicorn app:app --log-file -
Deployment Platforms
This project is compatible with:
- Heroku
- Render
- Railway
- AWS Elastic Beanstalk
Technical Overview
- Computer Vision: OpenCV
- Deep Learning: TensorFlow (Inception V3 fine-tuned)
- Image Processing: NumPy + OpenCV
- Face Shape Classification: 5 categories
- Core feature: AI-driven hairstyle transfer using face-aware filtering
Credits: Switching Eds with Python



