Spaces:
Sleeping
Sleeping
File size: 5,796 Bytes
4230f20 d7c5b1f 373fbd2 d7c5b1f aacf571 d7c5b1f aacf571 d7c5b1f aacf571 d7c5b1f aacf571 d7c5b1f aacf571 d7c5b1f aacf571 d7c5b1f aacf571 d7c5b1f aacf571 d7c5b1f aacf571 d7c5b1f aacf571 d7c5b1f 03f1d2d aacf571 03f1d2d aacf571 03f1d2d aacf571 d7c5b1f 03f1d2d aacf571 03f1d2d aacf571 d7c5b1f af345df d7c5b1f aacf571 d7c5b1f aacf571 d7c5b1f aacf571 d7c5b1f c600be8 aacf571 d7c5b1f c600be8 af345df d7c5b1f aacf571 d7c5b1f aacf571 d7c5b1f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
---
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
[](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 |