Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

18 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

StyleForge - AI Style Transfer MVP

Transform your photos with different fashion style presets while preserving your identity.

πŸ”— Live Demo | 🎨 Powered by Replicate


πŸ“Έ Screenshots

Upload your photo Choose a style

Before and after comparison


✨ Features

  • πŸ“€ Upload any photo (JPG, PNG, WebP)
  • 🎭 Choose a style from 7 presets (Tuxedo, Streetwear, Cyberpunk, etc.)
  • πŸ€– AI transforms your outfit while keeping your face
  • πŸ”„ Compare before/after with slider
  • πŸ’Ύ Download your styled image

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Next.js Web   │────▢│   FastAPI API   │────▢│   Redis Queue   β”‚
β”‚   (Port 3000)   β”‚     β”‚   (Port 8000)   β”‚     β”‚   (Port 6379)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                               β”‚                        β”‚
                               β–Ό                        β–Ό
                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                        β”‚  Local Storage  β”‚     β”‚   RQ Worker     β”‚
                        β”‚  /data/uploads  β”‚     β”‚  (Background)   β”‚
                        β”‚  /data/outputs  β”‚     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Quick Start

Prerequisites

  • Docker & Docker Compose
  • Node.js 18+ (for local frontend dev)
  • Python 3.11+ (for local backend dev)

Run with Docker Compose (Recommended)

# Clone and navigate to project
cd /path/to/styleforge

# Copy environment files
cp .env.example .env
cp apps/web/.env.example apps/web/.env.local
cp apps/api/.env.example apps/api/.env

# Note: App renamed from StyleForge to StyleForge

# Start all services
docker-compose up --build

# Access the app
# Frontend: http://localhost:3000
# API: http://localhost:8000
# API Docs: http://localhost:8000/docs

Local Development

Backend (FastAPI)

cd apps/api

# Create virtual environment
python -m venv venv
source venv/bin/activate  # or `venv\Scripts\activate` on Windows

# Install dependencies
pip install -r requirements.txt

# Start Redis (required for job queue)
docker run -d -p 6379:6379 redis:alpine

# Run API server
uvicorn app.main:app --reload --port 8000

# In another terminal, run the worker
rq worker styleforge --with-scheduler

Frontend (Next.js)

cd apps/web

# Install dependencies
npm install

# Run development server
npm run dev

Project Structure

.
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ api/                    # Python FastAPI backend
β”‚   β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”‚   β”œβ”€β”€ main.py         # FastAPI app entry
β”‚   β”‚   β”‚   β”œβ”€β”€ config.py       # Configuration
β”‚   β”‚   β”‚   β”œβ”€β”€ models.py       # Pydantic models
β”‚   β”‚   β”‚   β”œβ”€β”€ routes/         # API endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ services/       # Business logic
β”‚   β”‚   β”‚   β”œβ”€β”€ generators/     # Image generation
β”‚   β”‚   β”‚   β”œβ”€β”€ workers/        # Background tasks
β”‚   β”‚   β”‚   └── middleware/     # Logging, rate limiting
β”‚   β”‚   β”œβ”€β”€ tests/              # Unit tests
β”‚   β”‚   β”œβ”€β”€ data/               # Storage (gitignored)
β”‚   β”‚   β”‚   β”œβ”€β”€ uploads/
β”‚   β”‚   β”‚   β”œβ”€β”€ outputs/
β”‚   β”‚   β”‚   └── metadata/
β”‚   β”‚   β”œβ”€β”€ requirements.txt
β”‚   β”‚   └── Dockerfile
β”‚   β”‚
β”‚   └── web/                    # Next.js frontend
β”‚       β”œβ”€β”€ app/                # App Router pages
β”‚       β”œβ”€β”€ components/         # React components
β”‚       β”œβ”€β”€ lib/                # Utilities
β”‚       β”œβ”€β”€ package.json
β”‚       └── Dockerfile
β”‚
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ .env.example
└── README.md

API Endpoints

Method Endpoint Description
GET /api/styles List available style presets
POST /api/jobs Create new transformation job
GET /api/jobs/{job_id} Get job status and result
GET /health Health check
GET /metrics Basic metrics

Create Job Request

POST /api/jobs
Content-Type: multipart/form-data

{
  "image": <file>,
  "style_id": "classic-tuxedo"
}

Job Response

{
  "job_id": "uuid-here",
  "status": "completed",
  "progress": 100,
  "result_url": "/outputs/uuid-result.png",
  "error": null,
  "created_at": "2024-01-01T00:00:00Z"
}

Style Presets

ID Name Description
classic-tuxedo Classic Tuxedo Elegant spy archetype in formal wear
streetwear Modern Streetwear Urban fashion with hoodies and sneakers
techwear Techwear Functional futuristic clothing
old-money Old Money Refined preppy aesthetic
minimalist Minimalist Clean, simple, monochrome looks
cyberpunk Cyberpunk Neon-accented futuristic fashion
crypto-bro Crypto Bro Tech founder vibes with hoodies and Patagonia vests

Adding New Styles

  1. Edit apps/api/app/services/style_registry.py
  2. Add new StylePreset entry with:
    • Unique id (kebab-case)
    • Display name
    • description for UI
    • prompt template for image generation
    • thumbnail path (optional)

Example:

StylePreset(
    id="bohemian",
    name="Bohemian",
    description="Free-spirited, artistic, layered clothing",
    prompt="wearing bohemian style clothing with flowing fabrics, artistic patterns, layered accessories, natural earthy tones",
    thumbnail="/thumbnails/bohemian.jpg"
)

Live Demo

πŸš€ https://styleforge-blush.vercel.app

Image Generator Implementations

StubGenerator (Default - Free)

Returns original image with style-specific color grading and effects. Great for testing the UI/UX without AI costs.

RealGenerator (Replicate - Paid)

Uses Replicate API with Stable Diffusion XL for actual AI-powered clothing changes.

Cost: ~$0.01-0.05 per image

Setting Up AI Generation (Replicate)

  1. Sign up at https://replicate.com (free account)
  2. Go to https://replicate.com/account/api-tokens
  3. Create a new API token
  4. Add credits at https://replicate.com/account/billing (minimum ~$5)
  5. Set environment variables:
    REPLICATE_API_TOKEN=r8_your_token_here
    IMAGE_GENERATOR=real
    

AI Pricing Comparison

Service Cost/Image Quality Face Preservation
Replicate (SDXL) ~$0.01-0.05 ⭐⭐⭐⭐ Medium
Replicate (IP-Adapter) ~$0.03-0.08 ⭐⭐⭐⭐⭐ High
fal.ai ~$0.01-0.03 ⭐⭐⭐⭐ Medium
OpenAI DALL-E 3 ~$0.04-0.08 ⭐⭐⭐⭐ Low

To switch generators, set IMAGE_GENERATOR=stub or IMAGE_GENERATOR=real in your environment.

Deployment

Free Hosting Stack

Service Component Free Tier
Vercel Frontend (Next.js) Unlimited
Render Backend (FastAPI) 750 hrs/month
Upstash Redis 10k commands/day

Deploy to Production

  1. Push to GitHub

    git init
    git add .
    git commit -m "Initial commit"
    gh repo create styleforge --public --source=. --push
  2. Set up Upstash Redis

  3. Deploy Backend to Render

    • Go to https://render.com
    • New β†’ Web Service β†’ Public Git Repository
    • Repo: https://github.com/YOUR_USERNAME/styleforge
    • Root Directory: apps/api
    • Build: pip install -r requirements.txt
    • Start: uvicorn app.main:app --host 0.0.0.0 --port $PORT
    • Add environment variables (see below)
  4. Deploy Frontend to Vercel

    • Go to https://vercel.com
    • Import your GitHub repo
    • Root Directory: apps/web
    • Add: NEXT_PUBLIC_API_URL=https://your-api.onrender.com

Production Environment Variables

Variable Description Example
REDIS_URL Upstash Redis URL rediss://default:xxx@xxx.upstash.io:6379
IMAGE_GENERATOR stub or real real
REPLICATE_API_TOKEN Replicate API key r8_xxx
CORS_ORIGINS Frontend URL https://your-app.vercel.app
UPLOAD_DIR Upload path /tmp/uploads
OUTPUT_DIR Output path /tmp/outputs
METADATA_DIR Metadata path /tmp/metadata
PROCESS_INLINE Skip worker true

Configuration

Environment Variables

Variable Description Default
API_HOST API server host 0.0.0.0
API_PORT API server port 8000
REDIS_URL Redis connection string redis://localhost:6379
UPLOAD_DIR Upload storage path ./data/uploads
OUTPUT_DIR Output storage path ./data/outputs
MAX_FILE_SIZE_MB Max upload size 10
RATE_LIMIT_PER_MINUTE Requests per IP 30
IMAGE_GENERATOR Generator to use stub
CORS_ORIGINS Allowed origins http://localhost:3000

Security Features

  • βœ… File type validation (jpg, png, webp only)
  • βœ… File size limits (10MB default)
  • βœ… Rate limiting per IP
  • βœ… CORS configuration
  • βœ… Request ID tracking
  • βœ… Structured logging

Testing

# Backend tests
cd apps/api
pytest tests/ -v

# Frontend tests
cd apps/web
npm test

License

MIT

About

AI-powered style transfer app - change your outfit in photos while keeping your face

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages