Files
PaintPlus/backend/app/schemas.py
T
Claude fc394d76cf 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.
2026-01-24 03:32:50 +00:00

115 lines
2.3 KiB
Python

from pydantic import BaseModel, EmailStr
from typing import Optional, List, Dict, Any
from datetime import datetime
# User schemas
class UserCreate(BaseModel):
email: EmailStr
password: str
class UserResponse(BaseModel):
id: int
email: str
created_at: datetime
class Config:
from_attributes = True
# Project schemas
class ProjectCreate(BaseModel):
name: str
class ProjectResponse(BaseModel):
id: int
user_id: int
name: str
created_at: datetime
updated_at: datetime
class Config:
from_attributes = True
# Edit schemas
class EditRequest(BaseModel):
prompt: str
mode: str = "A" # "A" or "B"
selection_type: str # "rectangle", "ellipse", "lasso"
bbox: Dict[str, int] # {x, y, width, height}
feather_px: int = 0
selection_data: Optional[Dict[str, Any]] = None
class EditResponse(BaseModel):
id: int
project_id: int
created_at: datetime
mode: str
prompt: str
selection_type: str
bbox_json: str
feather_px: int
ai_provider: str
status: str
error_message: Optional[str] = None
class Config:
from_attributes = True
# Image upload
class UploadResponse(BaseModel):
project_id: int
original_url: str
current_url: str
# Patch Library schemas
class PatchCreate(BaseModel):
name: str
description: Optional[str] = None
source_type: str # "ai_generated", "manual_selection", "imported"
source_project_id: Optional[int] = None
source_edit_id: Optional[int] = None
category: Optional[str] = None
tags: Optional[str] = None
bbox: Optional[Dict[str, int]] = None
class PatchResponse(BaseModel):
id: int
name: str
description: Optional[str]
created_at: datetime
source_type: str
source_project_id: Optional[int]
source_edit_id: Optional[int]
width: int
height: int
tags: Optional[str]
category: Optional[str]
is_public: bool
file_path: str
thumbnail_path: Optional[str]
class Config:
from_attributes = True
class PatchApply(BaseModel):
project_id: int
patch_id: int
bbox: Dict[str, int]
feather_px: int = 5
# Generic responses
class StatusResponse(BaseModel):
status: str
message: Optional[str] = None
data: Optional[Any] = None