--- title: FaceForgeAI ZeroGPU emoji: ๐Ÿจ colorFrom: pink colorTo: pink sdk: gradio sdk_version: 5.49.1 app_file: app.py pinned: false license: mit short_description: FaceForgeAI_ZeroGPU --- # ๐ŸŽจ FaceForge AI [![Hugging Face Space](https://img.shields.io/badge/๐Ÿค—%20Open%20in-Hugging%20Face%20Space-yellow)](https://huggingface.co/spaces/VcRlAgent/FaceForgeAI) **Author:** Vijay S. Chaudhari **Runtime:** Gradio + Replicate API ๐Ÿš€ --- ## ๐Ÿง  Overview **FaceForge AI** transforms your uploaded photo into professional-quality images powered by AI: - ๐ŸŽญ **Background Remover** โ€“ clean background removal for any image - ๐Ÿ’ผ **Professional Headshots** โ€“ studio-quality portraits in multiple styles - ๐ŸŒ **Scene Changer** โ€“ place yourself in different environments with identity preservation This edition uses **Replicate's InstantID** for high-quality identity-preserving transformations with configurable rate limiting for cost control. --- ## โœจ Key Features โœ… **Three Generation Modes** - **Background Remover** โ€“ removes background using Rembg - **Professional Headshots** โ€“ Studio, Office, Premium Editorial styles - **Scene Changer** โ€“ Coastal Run, Urban Evening, Forest Trail environments โœ… **User Controls** - Preset prompt styles via dropdown - Optional advanced settings (CFG, Steps, Denoise) - Real-time usage tracking โœ… **Rate Limiting** - 5 generations/day (standard mode) - 10 generations/day (dev mode) - Midnight UTC reset - Device-based tracking --- ## ๐Ÿงฉ Tech Stack | Component | Purpose | |-----------|---------| | **Python 3.10+** | Core runtime | | **Gradio 4.x** | Web UI framework | | **Replicate API** | InstantID model hosting | | **InstantID** | Identity-preserving image generation | | **Rembg 2.x** | Background removal | | **PyYAML** | Configuration management | | **Pillow** | Image processing | --- ## ๐Ÿงฐ Installation ### 1๏ธโƒฃ Clone Repository ```bash git clone https://github.com/agentofAI/FaceForgeAI.git cd FaceForgeAI ``` ### 2๏ธโƒฃ Install Dependencies ```bash pip install -r requirements.txt ``` ### 3๏ธโƒฃ Configure Environment ```bash cp .env.example .env # Edit .env and add your REPLICATE_API_TOKEN ``` Get your Replicate API token at: https://replicate.com/account/api-tokens ### 4๏ธโƒฃ Run Locally ```bash python app.py ``` Open the local Gradio URL (typically http://127.0.0.1:7860) in your browser. --- ## ๐ŸŽจ Style Presets ### Professional Headshots | Style | Description | |-------|-------------| | ๐Ÿ“ธ **Studio Headshot** | Professional editorial with neutral background, magazine quality | | ๐Ÿข **Office Setting** | Subtle office background, premium business attire | | โœจ **Premium Editorial** | High-end minimal studio, composed presence | ### Scene Changer | Scene | Description | |-------|-------------| | ๐Ÿ–๏ธ **Coastal Run** | Ocean and horizon background, warm sunrise lighting | | ๐ŸŒƒ **Urban Evening** | City lights, soft ambient night lighting | | ๐ŸŒฒ **Forest Trail** | Trees and dirt path, diffused outdoor light | --- ## ๐Ÿ“ Project Structure ``` faceforge-ai/ โ”‚ โ”œโ”€โ”€ app.py # Main Gradio application โ”œโ”€โ”€ config.yaml # Prompts and settings configuration โ”œโ”€โ”€ rate_limiter.py # Rate limiting logic โ”œโ”€โ”€ replicate_handler.py # Replicate API wrapper โ”œโ”€โ”€ requirements.txt # Python dependencies โ”œโ”€โ”€ .env.example # Environment variables template โ”œโ”€โ”€ rate_limits.json # Auto-generated usage tracking โ””โ”€โ”€ README.md # Documentation ``` --- ## โš™๏ธ Configuration ### Rate Limits (config.yaml) ```yaml rate_limit: default_daily_limit: 5 # Standard mode dev_daily_limit: 10 # Dev mode reset_timezone: "UTC" # Reset at midnight UTC ``` ### Dev Mode Enable higher rate limits in `.env`: ```bash DEV_MODE=true ``` ### Add Custom Styles Edit `config.yaml` to add new headshot or scene styles: ```yaml headshots: "๐ŸŽฏ Your Style": prompt: | Your custom prompt here... multiple lines supported negative: "Things to avoid..." scenes: "๐ŸŽช Your Scene": prompt: "Scene description..." negative: "Things to avoid..." ``` ### Advanced Settings Toggle "Enable Advanced Settings" in UI to control: - **CFG Scale**: Prompt adherence (1.0-10.0) - **Steps**: Generation quality (20-50) - **Denoise**: Transformation strength (0.5-1.0) --- ## ๐Ÿ“Š Rate Limiting - **Tracking**: Server-side session file per device - **Reset**: Midnight UTC daily - **Scope**: Shared across all generation functions - **Override**: Dev mode doubles the limit Device fingerprinting uses IP + User-Agent for consistent tracking. --- ## ๐Ÿงพ Model Credits | Model | Source / License | |-------|------------------| | **InstantID** | [zsxkib/instant-id-basic](https://replicate.com/zsxkib/instant-id-basic) via Replicate | | **Rembg** | [danielgatis/rembg](https://github.com/danielgatis/rembg) (MIT License) | | **Gradio** | [gradio-app/gradio](https://github.com/gradio-app/gradio) (Apache 2.0) | --- ## ๐Ÿ› Troubleshooting **"REPLICATE_API_TOKEN not found"** - Verify `.env` file exists with valid token - Check token at https://replicate.com/account/api-tokens **"Daily limit reached"** - Wait for midnight UTC reset - Enable `DEV_MODE=true` for higher limits **Generation fails** - Verify image uploaded successfully - Check Replicate API status - Ensure internet connectivity **Rate limits not working** - Delete `rate_limits.json` to reset tracking - Verify server-side file permissions --- ## ๐Ÿ“œ License This project is for educational and demonstration purposes. Each model used retains its original open-source license. --- Author: Vijay S. Chaudhari ยฉ 2025 Vijay S. Chaudhari