Skip to content

acesley180604/SM_Mirror

Repository files navigation

SM Mirror 2.0 - AI-Powered Professional Makeup Transfer

License Python FastAPI

A cutting-edge AI makeup transfer application that combines Stable-Makeup technology with MediaPipe face detection to deliver professional-quality makeup application results.

🎯 Project Overview

SM Mirror 2.0 is a full-stack application that uses advanced AI to transfer makeup from reference images to source photos while maintaining natural facial features and professional-quality results.

✨ Key Features

  • Professional Makeup Transfer: Powered by Stable-Makeup for superior results vs traditional inpainting
  • Multi-Region Control: Separate control for lips, eyes, eyebrows, and cheeks
  • Real-time Processing: FastAPI backend with async task processing
  • Advanced Face Detection: Hybrid MediaPipe + SPIGA detection system
  • Progressive Makeup: Multi-step makeup application
  • GPU/CPU Support: Optimized for various hardware configurations

πŸ—οΈ Architecture

SM_Mirror_2.0/
β”œβ”€β”€ Stable-Makeup/          # Core Stable-Makeup implementation
β”œβ”€β”€ backend/                # FastAPI server & services
β”œβ”€β”€ pytorch_model_2/        # Pre-trained model weights
β”œβ”€β”€ output/                 # Generated results
β”œβ”€β”€ tasks.md               # Development roadmap
└── instructions.md        # Detailed development guide

πŸš€ Quick Start

Prerequisites

  • Python 3.8+
  • CUDA-capable GPU (recommended)
  • 16GB+ RAM
  • 10GB+ disk space for models

1. Environment Setup

# Clone the repository
git clone <your-repo-url>
cd SM_Mirror_2.0

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r backend/requirements_essential.txt

2. Model Setup

Models are automatically detected from:

  • pytorch_model_2/ (current setup)
  • Stable-Makeup/models/
  • Download from Google Drive

3. Start the Backend

cd backend
python main.py

Server starts at http://localhost:8000

4. Test the API

# Health check
curl http://localhost:8000/health

# Test makeup transfer
curl -X POST http://localhost:8000/api/v1/makeup/transfer \
  -F "source_image=@path/to/source.jpg" \
  -F "reference_image=@path/to/makeup_reference.jpg" \
  --output result.jpg

πŸ”§ API Documentation

Health Check

GET /health
GET /api/v1/makeup/health

Makeup Transfer

POST /api/v1/makeup/transfer
Content-Type: multipart/form-data

Fields:
- source_image: Source image file
- reference_image: Makeup reference image file

Response: Processed image with makeup applied

🧠 Technology Stack

AI/ML Components

  • Stable-Makeup: Professional makeup transfer model
  • MediaPipe: Face landmark detection
  • SPIGA: Advanced facial structure analysis
  • Stable Diffusion v1.5: Base diffusion model
  • PyTorch: Deep learning framework

Backend

  • FastAPI: Modern Python web framework
  • Uvicorn: ASGI server
  • Pillow: Image processing
  • NumPy: Numerical computations

Infrastructure

  • Docker: Containerization (planned)
  • PostgreSQL: Database (planned)
  • Redis/Celery: Async task processing (planned)

πŸ“Š Performance

  • Processing Time: 30-60 seconds per image (GPU)
  • Quality: Professional-grade makeup transfer
  • Memory Usage: ~6-8GB GPU memory
  • Supported Formats: JPG, PNG, WebP

🎨 Makeup Capabilities

Supported Makeup Types

  • βœ… Lipstick: Various colors and finishes
  • βœ… Eye Makeup: Eyeshadow, eyeliner, mascara
  • βœ… Eyebrows: Shape and color enhancement
  • βœ… Blush: Cheek contouring and color
  • πŸ”„ Foundation: Skin tone adjustment (planned)
  • πŸ”„ Highlighter: Face highlighting (planned)

Advanced Features

  • Multi-region Control: Apply different makeup to different facial areas
  • Style Mixing: Combine multiple reference styles
  • Intensity Control: Adjust makeup strength
  • Progressive Application: Step-by-step makeup building

πŸ”„ Development Phases

Phase 0: PoC βœ…

  • MediaPipe integration
  • Stable-Makeup core functionality
  • Basic API endpoints

Phase 1: Walking Skeleton (Current)

  • Complete end-to-end pipeline
  • Frontend integration
  • File upload/download

Phase 2: MVP Features

  • Async processing
  • Multi-region control
  • User interface enhancements

Phase 3: Production Ready

  • User authentication
  • Multi-step makeup
  • Performance optimization
  • Deployment

πŸ§ͺ Testing

# Test Stable-Makeup integration
python backend/test_stable_makeup.py

# Test API endpoints
python backend/test_api_upload.py

# Manual API testing
curl -X POST http://localhost:8000/api/v1/makeup/transfer \
  -F "source_image=@test_images/source.jpg" \
  -F "reference_image=@test_images/reference.jpg" \
  --output result.jpg

πŸš€ Deployment

Local Development

cd backend
python main.py

Production (Planned)

  • GPU-enabled cloud instances (AWS/GCP)
  • Docker containerization
  • Load balancing with Nginx
  • Monitoring and logging

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

πŸ“ž Support

  • Check the Issues for common problems
  • Review instructions.md for detailed development guidance
  • Check tasks.md for development progress

πŸŽ‰ Status: Working!

βœ… Backend Integration: Stable-Makeup + FastAPI working
βœ… Face Detection: MediaPipe + SPIGA hybrid system
βœ… API Endpoints: Upload and process images
βœ… Model Loading: Auto-detection of trained models
πŸ”„ Frontend: In development
πŸ”„ Production: Deployment preparation

Ready for makeup magic! πŸ’„βœ¨

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages