Add Replicate provider, model selection, and Patch Library features

Major additions:
1. Replicate AI Provider
   - Support for multiple models (SDXL, LaMa, Realistic Vision)
   - Auto-model selection based on prompt keywords
   - Best for human features: realistic-vision (~$0.020/image)
   - Best for removal: lama (~$0.002/image)
   - Best general purpose: sdxl-inpaint (~$0.025/image)
   - Smart keyword detection for automatic model selection

2. Enhanced Stability AI Provider
   - Optimized parameters for better quality
   - Support for multiple engines (SDXL, SD 1.5, SD 2.1)
   - Increased steps and CFG scale for improved results

3. Model Selection System
   - Per-edit model override capability
   - Global default model configuration
   - Provider-specific model options
   - Auto-selection based on prompt analysis

4. Patch Library Feature
   - Save AI-generated patches for reuse
   - Save manually selected regions
   - Import external images as patches
   - Organize with categories and tags
   - Browse and filter patch library
   - Apply saved patches to new images
   - Thumbnail generation for quick preview
   - Cost savings by reusing good results

5. Comprehensive Documentation
   - MODEL_SELECTION_GUIDE.md: Detailed guide for choosing models
     * Best models for hands, faces, bodies
     * Quality comparison table
     * Cost optimization strategies
     * Troubleshooting common issues
   - QUICK_START.md: How-to guide for new features
     * Model selection examples
     * Patch library workflow
     * API reference
     * Pro tips and cost comparisons

6. Configuration Updates
   - Added Replicate API key support
   - Model selection settings
   - Per-edit override toggle
   - Updated .env.example with all options

Benefits:
- Better quality for human features (hands, faces)
- 90% cost reduction using lama for removals
- Reusable patch library saves money and ensures consistency
- Auto-model selection optimizes quality and cost
- Flexibility to choose provider and model per edit

All backend changes are fully functional and ready for use.
Frontend UI for patch library pending.
This commit is contained in:
Claude
2026-01-24 03:32:50 +00:00
parent 35d953ffd6
commit fc394d76cf
12 changed files with 1528 additions and 29 deletions
+20 -4
View File
@@ -1,12 +1,28 @@
# AI Provider Configuration
# Options: openai, stability, mock
# Options: openai, stability, replicate, mock
# - openai: DALL-E 2 (low quality, not recommended)
# - stability: Stability AI SDXL (good quality, ~$0.04/image)
# - replicate: Multiple models (best value, ~$0.002-0.025/image)
# - mock: No AI, returns original (for testing)
AI_PROVIDER=mock
# OpenAI API Key (for OpenAI provider)
# API Keys
OPENAI_API_KEY=
# Stability AI API Key (for Stability AI provider)
STABILITY_API_KEY=
REPLICATE_API_KEY=
# Model Selection (optional, provider-specific)
# Stability AI models: sdxl (default), sd15, sd21
STABILITY_MODEL=sdxl
# Replicate models: sdxl-inpaint (default), lama, realistic-vision
# - sdxl-inpaint: Best general purpose (~$0.025/image)
# - lama: Best for object removal (~$0.002/image)
# - realistic-vision: Best for humans/faces/hands (~$0.020/image)
REPLICATE_MODEL=sdxl-inpaint
# Allow per-edit model override (true/false)
ALLOW_MODEL_OVERRIDE=true
# Secret key for JWT tokens (change in production)
SECRET_KEY=change-this-secret-key-in-production