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:
@@ -1,5 +1,6 @@
|
||||
from app.models.user import User
|
||||
from app.models.project import Project
|
||||
from app.models.edit import Edit
|
||||
from app.models.patch import Patch
|
||||
|
||||
__all__ = ["User", "Project", "Edit"]
|
||||
__all__ = ["User", "Project", "Edit", "Patch"]
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
from sqlalchemy import Column, Integer, String, DateTime, ForeignKey, Text, Boolean
|
||||
from sqlalchemy.orm import relationship
|
||||
from datetime import datetime
|
||||
from app.database import Base
|
||||
|
||||
|
||||
class Patch(Base):
|
||||
__tablename__ = "patches"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
user_id = Column(Integer, ForeignKey("users.id"), nullable=True)
|
||||
name = Column(String, nullable=False)
|
||||
description = Column(Text, nullable=True)
|
||||
created_at = Column(DateTime, default=datetime.utcnow)
|
||||
|
||||
# Source information
|
||||
source_type = Column(String, nullable=False) # "ai_generated", "manual_selection", "imported"
|
||||
source_project_id = Column(Integer, ForeignKey("projects.id"), nullable=True)
|
||||
source_edit_id = Column(Integer, ForeignKey("edits.id"), nullable=True)
|
||||
|
||||
# Patch metadata
|
||||
width = Column(Integer, nullable=False)
|
||||
height = Column(Integer, nullable=False)
|
||||
tags = Column(Text, nullable=True) # Comma-separated tags
|
||||
category = Column(String, nullable=True) # "hand", "face", "body", "object", "texture", etc.
|
||||
|
||||
# Is this patch shared/public?
|
||||
is_public = Column(Boolean, default=False)
|
||||
|
||||
# File path (relative to data dir)
|
||||
file_path = Column(String, nullable=False)
|
||||
thumbnail_path = Column(String, nullable=True)
|
||||
|
||||
# Relationships
|
||||
user = relationship("User", back_populates="patches")
|
||||
source_project = relationship("Project")
|
||||
source_edit = relationship("Edit")
|
||||
@@ -14,3 +14,4 @@ class User(Base):
|
||||
|
||||
# Relationships
|
||||
projects = relationship("Project", back_populates="user", cascade="all, delete-orphan")
|
||||
patches = relationship("Patch", back_populates="user", cascade="all, delete-orphan")
|
||||
|
||||
Reference in New Issue
Block a user