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:
@@ -0,0 +1,369 @@
|
||||
# Model Selection Guide for Body Parts and Editing Tasks
|
||||
|
||||
## Quick Reference: Best Models by Use Case
|
||||
|
||||
### Human Features (Faces, Hands, Bodies)
|
||||
|
||||
**Best Choice: `realistic-vision` (Replicate)**
|
||||
|
||||
```env
|
||||
AI_PROVIDER=replicate
|
||||
REPLICATE_API_KEY=your-key
|
||||
REPLICATE_MODEL=realistic-vision
|
||||
```
|
||||
|
||||
**Why:** Trained specifically on human anatomy and realistic photos. Handles difficult features like:
|
||||
- ✅ Hands (notoriously hard for AI)
|
||||
- ✅ Faces and facial features
|
||||
- ✅ Skin textures and tones
|
||||
- ✅ Body proportions
|
||||
- ✅ Portraits
|
||||
|
||||
**Examples:**
|
||||
- "Fix the hand position"
|
||||
- "Remove red eye"
|
||||
- "Smooth skin blemishes"
|
||||
- "Adjust facial expression"
|
||||
- "Fix fingers"
|
||||
|
||||
**Cost:** ~$0.020/image
|
||||
**Quality:** ⭐⭐⭐⭐⭐
|
||||
|
||||
---
|
||||
|
||||
### Object Removal
|
||||
|
||||
**Best Choice: `lama` (Replicate)**
|
||||
|
||||
```env
|
||||
AI_PROVIDER=replicate
|
||||
REPLICATE_MODEL=lama
|
||||
```
|
||||
|
||||
**Why:** Specifically designed for inpainting and object removal. Excellent at:
|
||||
- ✅ Removing objects cleanly
|
||||
- ✅ Filling in backgrounds naturally
|
||||
- ✅ Maintaining surrounding context
|
||||
- ✅ Fast and cheap
|
||||
|
||||
**Examples:**
|
||||
- "Remove the person"
|
||||
- "Delete the watermark"
|
||||
- "Erase the object"
|
||||
- "Clean up the background"
|
||||
|
||||
**Cost:** ~$0.002/image (cheapest!)
|
||||
**Quality:** ⭐⭐⭐⭐
|
||||
|
||||
---
|
||||
|
||||
### General Purpose Editing
|
||||
|
||||
**Best Choice: `sdxl-inpaint` (Replicate or Stability AI)**
|
||||
|
||||
```env
|
||||
# Option 1: Replicate
|
||||
AI_PROVIDER=replicate
|
||||
REPLICATE_MODEL=sdxl-inpaint
|
||||
|
||||
# Option 2: Stability AI Direct
|
||||
AI_PROVIDER=stability
|
||||
STABILITY_MODEL=sdxl
|
||||
```
|
||||
|
||||
**Why:** SDXL (Stable Diffusion XL) is the best all-around model for:
|
||||
- ✅ Landscapes and scenery
|
||||
- ✅ Objects and textures
|
||||
- ✅ Creative edits
|
||||
- ✅ Style changes
|
||||
- ✅ Adding elements
|
||||
|
||||
**Examples:**
|
||||
- "Change sky to sunset"
|
||||
- "Add flowers"
|
||||
- "Make it autumn"
|
||||
- "Replace with grass"
|
||||
|
||||
**Cost:**
|
||||
- Replicate: ~$0.025/image
|
||||
- Stability AI: ~$0.040/image
|
||||
|
||||
**Quality:** ⭐⭐⭐⭐⭐
|
||||
|
||||
---
|
||||
|
||||
## Detailed Comparison by Body Part
|
||||
|
||||
### Hands ✋
|
||||
|
||||
**Challenge:** Hands are the hardest thing for AI to generate correctly. Common issues:
|
||||
- Wrong number of fingers
|
||||
- Unnatural finger positions
|
||||
- Distorted proportions
|
||||
- Weird joints
|
||||
|
||||
**Best Models (in order):**
|
||||
|
||||
1. **Realistic Vision** (Replicate) - ⭐⭐⭐⭐⭐
|
||||
- Best overall for hands
|
||||
- Understands hand anatomy
|
||||
- Cost: ~$0.020/image
|
||||
|
||||
2. **SDXL Inpainting** (Replicate/Stability) - ⭐⭐⭐
|
||||
- Decent but less consistent
|
||||
- Cost: ~$0.025-0.040/image
|
||||
|
||||
3. **DALL-E 2** (OpenAI) - ⭐⭐
|
||||
- Often struggles with hands
|
||||
- Not recommended
|
||||
|
||||
**Tips for Better Hand Edits:**
|
||||
- Use detailed prompts: "realistic human hand with five fingers"
|
||||
- Add negative prompts if provider supports: "deformed, extra fingers, missing fingers"
|
||||
- Use Mode B (full image context) for better results
|
||||
- Consider editing in multiple passes if needed
|
||||
|
||||
---
|
||||
|
||||
### Faces 😊
|
||||
|
||||
**Challenge:** Faces need to look natural and maintain proper proportions
|
||||
|
||||
**Best Models:**
|
||||
|
||||
1. **Realistic Vision** (Replicate) - ⭐⭐⭐⭐⭐
|
||||
- Excellent for facial features
|
||||
- Natural skin textures
|
||||
- Good expression handling
|
||||
|
||||
2. **SDXL Inpainting** - ⭐⭐⭐⭐
|
||||
- Good for general facial edits
|
||||
- Better for style than realism
|
||||
|
||||
**Use Cases:**
|
||||
- Remove blemishes
|
||||
- Fix red eye
|
||||
- Adjust expressions
|
||||
- Change hair
|
||||
- Smooth wrinkles
|
||||
|
||||
---
|
||||
|
||||
### Full Body / Torso 🧍
|
||||
|
||||
**Best Model:** Realistic Vision
|
||||
|
||||
**Why:** Maintains body proportions and realistic anatomy
|
||||
|
||||
**Examples:**
|
||||
- "Fix the clothing wrinkles"
|
||||
- "Change shirt color to blue"
|
||||
- "Remove the stain"
|
||||
|
||||
---
|
||||
|
||||
### Hearts ♥️ (Decorative Elements)
|
||||
|
||||
**Best Model:** SDXL Inpainting
|
||||
|
||||
**Why:** Great for creative and decorative elements
|
||||
|
||||
**Examples:**
|
||||
- "Add heart shape"
|
||||
- "Draw a heart pattern"
|
||||
- "Replace with hearts"
|
||||
|
||||
---
|
||||
|
||||
## Auto-Selection Feature
|
||||
|
||||
The system automatically selects the best model based on your prompt:
|
||||
|
||||
### Keywords that trigger `realistic-vision`:
|
||||
- hand, hands, finger, fingers
|
||||
- face, facial, portrait, eyes, nose, mouth
|
||||
- body, person, human, skin, people
|
||||
- realistic, photo, photograph
|
||||
|
||||
### Keywords that trigger `lama` (removal):
|
||||
- remove, delete, erase, cleanup
|
||||
- disappear, hide, clear
|
||||
|
||||
### Default: `sdxl-inpaint`
|
||||
- Everything else uses SDXL for best general quality
|
||||
|
||||
**Example Auto-Selection:**
|
||||
```python
|
||||
# User prompt: "Fix the hand" → auto-selects realistic-vision
|
||||
# User prompt: "Remove the person" → auto-selects lama
|
||||
# User prompt: "Change to sunset" → auto-selects sdxl-inpaint
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Manual Model Override
|
||||
|
||||
### Via Environment Variable
|
||||
Set default model in `.env`:
|
||||
```env
|
||||
REPLICATE_MODEL=realistic-vision
|
||||
```
|
||||
|
||||
### Via API Request
|
||||
Override per-edit in the API:
|
||||
```json
|
||||
{
|
||||
"prompt": "Fix the hand",
|
||||
"ai_provider": "replicate",
|
||||
"ai_model": "realistic-vision",
|
||||
"mode": "A",
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
### Via Frontend (Future Feature)
|
||||
Model selector dropdown in the UI.
|
||||
|
||||
---
|
||||
|
||||
## Cost Optimization Strategies
|
||||
|
||||
### For Low-Volume Users (< 100 edits/month)
|
||||
**Recommendation:** Use Replicate with auto-selection
|
||||
|
||||
**Why:**
|
||||
- No minimum purchase
|
||||
- Pay only for what you use
|
||||
- Auto-selects cheapest appropriate model
|
||||
|
||||
**Estimated Cost:** $1-3/month
|
||||
|
||||
---
|
||||
|
||||
### For Medium-Volume Users (100-1000 edits/month)
|
||||
**Recommendation:** Replicate or Stability AI
|
||||
|
||||
**Strategy:**
|
||||
- Use `lama` for removals ($0.002/image)
|
||||
- Use `realistic-vision` for humans ($0.020/image)
|
||||
- Use `sdxl-inpaint` for general ($0.025/image)
|
||||
|
||||
**Estimated Cost:** $10-30/month
|
||||
|
||||
---
|
||||
|
||||
### For High-Volume Users (1000+ edits/month)
|
||||
**Recommendation:** Consider local GPU or cloud GPU
|
||||
|
||||
**Why:**
|
||||
- No per-image cost
|
||||
- Best quality control
|
||||
- Privacy
|
||||
|
||||
**Setup:**
|
||||
- Local: RTX 3060+ GPU ($300-2000 one-time)
|
||||
- Cloud: RunPod/Vast.ai ($0.30-1.00/hour)
|
||||
|
||||
---
|
||||
|
||||
## Quality Comparison Table
|
||||
|
||||
| Use Case | DALL-E 2 | Stability SDXL | Replicate SDXL | Replicate Realistic | Replicate LaMa |
|
||||
|----------|----------|----------------|----------------|---------------------|----------------|
|
||||
| Hands | ⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐ |
|
||||
| Faces | ⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐ |
|
||||
| Bodies | ⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐ |
|
||||
| Objects | ⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐ | N/A |
|
||||
| Landscapes | ⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐ | N/A |
|
||||
| Removal | ⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐⭐⭐ |
|
||||
| Creative | ⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐ | ⭐ |
|
||||
|
||||
---
|
||||
|
||||
## Advanced Tips
|
||||
|
||||
### For Difficult Hands
|
||||
1. **Use Mode B** - Provides full image context
|
||||
2. **Be specific** - "realistic five-fingered hand in natural pose"
|
||||
3. **Multiple passes** - Fix gross errors first, then refine
|
||||
4. **Reference images** - Mode B helps AI understand the pose
|
||||
|
||||
### For Facial Features
|
||||
1. **High feather value** - 10-15px for smooth blending
|
||||
2. **Small selections** - Target specific features
|
||||
3. **Natural lighting** - Mention lighting in prompt
|
||||
|
||||
### For Body Parts
|
||||
1. **Maintain proportions** - Use Mode B for body context
|
||||
2. **Clothing context** - Include clothing description in prompt
|
||||
3. **Skin tone consistency** - Mention skin tone if needed
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting Common Issues
|
||||
|
||||
### "Hands have too many fingers"
|
||||
- **Solution:** Switch to `realistic-vision` model
|
||||
- **Prompt:** "realistic human hand with exactly five fingers"
|
||||
- **Try:** Multiple generations, pick best result
|
||||
|
||||
### "Face looks unnatural"
|
||||
- **Solution:** Use `realistic-vision` model
|
||||
- **Increase:** Feather value to 15-20px
|
||||
- **Try:** Mode B for better context
|
||||
|
||||
### "Removal leaves artifacts"
|
||||
- **Solution:** Use `lama` model (designed for removal)
|
||||
- **Alternative:** SDXL with prompt "clean background"
|
||||
|
||||
### "Colors don't match"
|
||||
- **Increase:** Feather value to 20-30px
|
||||
- **Try:** Mode B for better color context
|
||||
- **Prompt:** Include color description
|
||||
|
||||
---
|
||||
|
||||
## Quick Start Examples
|
||||
|
||||
### Example 1: Fix a Hand
|
||||
```json
|
||||
{
|
||||
"prompt": "realistic human hand with five fingers, natural pose",
|
||||
"ai_provider": "replicate",
|
||||
"ai_model": "realistic-vision",
|
||||
"mode": "B",
|
||||
"feather_px": 10
|
||||
}
|
||||
```
|
||||
|
||||
### Example 2: Remove an Object
|
||||
```json
|
||||
{
|
||||
"prompt": "remove the object, clean background",
|
||||
"ai_provider": "replicate",
|
||||
"ai_model": "lama",
|
||||
"mode": "A",
|
||||
"feather_px": 5
|
||||
}
|
||||
```
|
||||
|
||||
### Example 3: Change Sky
|
||||
```json
|
||||
{
|
||||
"prompt": "sunset sky with orange and pink clouds",
|
||||
"ai_provider": "replicate",
|
||||
"ai_model": "sdxl-inpaint",
|
||||
"mode": "A",
|
||||
"feather_px": 15
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Summary
|
||||
|
||||
**For Body Parts:** Use `realistic-vision` (Replicate)
|
||||
**For Removal:** Use `lama` (Replicate)
|
||||
**For Everything Else:** Use `sdxl-inpaint` (Replicate or Stability)
|
||||
|
||||
**Let the auto-selection do its job** - it's optimized for these use cases!
|
||||
@@ -0,0 +1,350 @@
|
||||
# Quick Start Guide
|
||||
|
||||
## How to Choose the Right AI Model
|
||||
|
||||
### For Body Parts (Hands, Faces, Bodies)
|
||||
|
||||
Use **Replicate with `realistic-vision`** model:
|
||||
|
||||
```env
|
||||
AI_PROVIDER=replicate
|
||||
REPLICATE_API_KEY=your-key-here
|
||||
REPLICATE_MODEL=realistic-vision
|
||||
```
|
||||
|
||||
**Why:** This model is specifically trained on human anatomy and handles difficult features like:
|
||||
- ✅ Hands (even complex finger positions)
|
||||
- ✅ Faces and expressions
|
||||
- ✅ Skin textures
|
||||
- ✅ Body proportions
|
||||
|
||||
**Cost:** ~$0.020/image
|
||||
|
||||
### For Removing Objects
|
||||
|
||||
Use **Replicate with `lama`** model:
|
||||
|
||||
```env
|
||||
AI_PROVIDER=replicate
|
||||
REPLICATE_MODEL=lama
|
||||
```
|
||||
|
||||
**Why:** Designed specifically for inpainting and removal
|
||||
**Cost:** ~$0.002/image (cheapest!)
|
||||
|
||||
### For General Edits (Landscapes, Objects, Creative)
|
||||
|
||||
Use **Replicate with `sdxl-inpaint`** model (default):
|
||||
|
||||
```env
|
||||
AI_PROVIDER=replicate
|
||||
REPLICATE_MODEL=sdxl-inpaint
|
||||
```
|
||||
|
||||
**Cost:** ~$0.025/image
|
||||
|
||||
---
|
||||
|
||||
## Auto-Model Selection
|
||||
|
||||
The system automatically picks the best model based on your prompt:
|
||||
|
||||
| Your Prompt | Auto-Selected Model | Why |
|
||||
|-------------|-------------------|-----|
|
||||
| "Fix the hand" | realistic-vision | Detects "hand" keyword |
|
||||
| "Remove person" | lama | Detects "remove" keyword |
|
||||
| "Change sky to sunset" | sdxl-inpaint | General purpose default |
|
||||
|
||||
**You don't need to manually specify models** - the auto-selection is optimized for quality and cost!
|
||||
|
||||
---
|
||||
|
||||
## Patch Library: Save and Reuse Parts
|
||||
|
||||
### What is the Patch Library?
|
||||
|
||||
A library where you can save image patches (regions) and reuse them across different images.
|
||||
|
||||
**Use Cases:**
|
||||
- Save a well-generated hand to reuse later
|
||||
- Save a perfect face for multiple photos
|
||||
- Build a collection of good body parts
|
||||
- Save textures, objects, or backgrounds
|
||||
- Reuse AI-generated elements that came out great
|
||||
|
||||
### How to Save a Patch
|
||||
|
||||
#### Option 1: Save AI-Generated Result
|
||||
|
||||
After an AI edit completes:
|
||||
|
||||
```bash
|
||||
POST /patches/
|
||||
{
|
||||
"name": "Perfect Hand",
|
||||
"description": "Well-formed left hand, palm up",
|
||||
"source_type": "ai_generated",
|
||||
"source_edit_id": 123,
|
||||
"category": "hand",
|
||||
"tags": "left, palm, realistic"
|
||||
}
|
||||
```
|
||||
|
||||
This saves the AI-generated output (`patch_out.png`) to your library.
|
||||
|
||||
#### Option 2: Save Manual Selection
|
||||
|
||||
Select any region from your current image:
|
||||
|
||||
```bash
|
||||
POST /patches/
|
||||
{
|
||||
"name": "Good Face",
|
||||
"description": "Frontal face with good lighting",
|
||||
"source_type": "manual_selection",
|
||||
"source_project_id": 456,
|
||||
"bbox": {"x": 100, "y": 100, "width": 200, "height": 200},
|
||||
"category": "face",
|
||||
"tags": "front, smile, female"
|
||||
}
|
||||
```
|
||||
|
||||
This saves whatever is currently in that region of your image.
|
||||
|
||||
#### Option 3: Import from File
|
||||
|
||||
Upload an external image:
|
||||
|
||||
```bash
|
||||
POST /patches/
|
||||
FormData:
|
||||
name: "Downloaded Hand"
|
||||
source_type: "imported"
|
||||
file: [uploaded PNG file]
|
||||
category: "hand"
|
||||
```
|
||||
|
||||
### How to Apply a Saved Patch
|
||||
|
||||
```bash
|
||||
POST /patches/apply
|
||||
{
|
||||
"project_id": 789,
|
||||
"patch_id": 123,
|
||||
"bbox": {"x": 300, "y": 400, "width": 200, "height": 200},
|
||||
"feather_px": 10
|
||||
}
|
||||
```
|
||||
|
||||
This places the saved patch at the specified location in your image.
|
||||
|
||||
### Browse Your Patch Library
|
||||
|
||||
```bash
|
||||
# List all patches
|
||||
GET /patches/
|
||||
|
||||
# Filter by category
|
||||
GET /patches/?category=hand
|
||||
|
||||
# Filter by tags
|
||||
GET /patches/?tags=realistic
|
||||
|
||||
# Get specific patch
|
||||
GET /patches/123
|
||||
|
||||
# Get patch image
|
||||
GET /patches/123/image
|
||||
|
||||
# Get patch thumbnail
|
||||
GET /patches/123/image?thumbnail=true
|
||||
```
|
||||
|
||||
### Organize Your Patches
|
||||
|
||||
**Categories:**
|
||||
- `hand` - Hand images
|
||||
- `face` - Facial features
|
||||
- `body` - Body parts
|
||||
- `object` - Objects and items
|
||||
- `texture` - Textures and patterns
|
||||
- `background` - Backgrounds and scenery
|
||||
|
||||
**Tags:** Comma-separated keywords for searching
|
||||
- "left, palm, realistic"
|
||||
- "front, smile, female"
|
||||
- "five fingers, open hand"
|
||||
|
||||
---
|
||||
|
||||
## Complete Workflow Example
|
||||
|
||||
### Scenario: Fix hands in a portrait photo
|
||||
|
||||
**Step 1: Create project and upload image**
|
||||
```bash
|
||||
POST /projects/ {"name": "Portrait Edit"}
|
||||
POST /projects/1/upload [upload photo]
|
||||
```
|
||||
|
||||
**Step 2: Try to fix the hand with AI**
|
||||
```bash
|
||||
POST /edits/projects/1/fix
|
||||
{
|
||||
"prompt": "realistic human hand with five fingers, natural pose",
|
||||
"mode": "B", # Use full image for context
|
||||
"selection_type": "rectangle",
|
||||
"bbox": {"x": 200, "y": 300, "width": 150, "height": 200},
|
||||
"feather_px": 10
|
||||
}
|
||||
```
|
||||
|
||||
The system auto-selects `realistic-vision` model because prompt mentions "hand".
|
||||
|
||||
**Step 3: If result is good, save it for later**
|
||||
```bash
|
||||
POST /patches/
|
||||
{
|
||||
"name": "Good Left Hand",
|
||||
"source_type": "ai_generated",
|
||||
"source_edit_id": 1,
|
||||
"category": "hand",
|
||||
"tags": "left, natural, realistic, five fingers"
|
||||
}
|
||||
```
|
||||
|
||||
**Step 4: Use saved hand on another photo**
|
||||
```bash
|
||||
# On a different project
|
||||
POST /patches/apply
|
||||
{
|
||||
"project_id": 2,
|
||||
"patch_id": 1,
|
||||
"bbox": {"x": 150, "y": 250, "width": 150, "height": 200},
|
||||
"feather_px": 15
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Cost Comparison
|
||||
|
||||
### Example: Fixing 10 hands in different photos
|
||||
|
||||
**Option A: Generate each hand with AI**
|
||||
- 10 edits × $0.020 = **$0.20**
|
||||
|
||||
**Option B: Generate one good hand, save it, reuse it**
|
||||
- 1 AI generation: $0.020
|
||||
- 9 patch applications: $0.00 (no AI cost)
|
||||
- **Total: $0.020** (90% savings!)
|
||||
|
||||
### When to Use Saved Patches vs AI
|
||||
|
||||
**Use Saved Patches When:**
|
||||
- You have a perfect result you want to reuse
|
||||
- Same angle/lighting/style needed
|
||||
- Want to maintain consistency across images
|
||||
- Want to avoid AI generation costs
|
||||
|
||||
**Use AI Generation When:**
|
||||
- Need unique/different result each time
|
||||
- Different angle or perspective needed
|
||||
- Want variation and creativity
|
||||
- Patch doesn't fit the context
|
||||
|
||||
---
|
||||
|
||||
## Pro Tips
|
||||
|
||||
### Building a Good Patch Library
|
||||
|
||||
1. **Save your best AI results** - When AI generates something great, save it immediately
|
||||
2. **Organize with categories** - Use consistent categories for easy finding
|
||||
3. **Tag descriptively** - Include orientation (left/right), pose, lighting, etc.
|
||||
4. **Create variations** - Save multiple versions of common needs (left hand, right hand, etc.)
|
||||
5. **Build gradually** - Your library becomes more valuable over time
|
||||
|
||||
### Maximizing Quality
|
||||
|
||||
1. **For hands:** Always use `realistic-vision` model or save good results
|
||||
2. **For faces:** Use Mode B (full image context) for better matching
|
||||
3. **Use high feather values** (15-20px) when applying saved patches
|
||||
4. **Test positioning** before finalizing - patches work best when lighting/angle matches
|
||||
|
||||
### Saving Money
|
||||
|
||||
1. **Build a patch library** of common needs
|
||||
2. **Use `lama` for removals** instead of expensive models
|
||||
3. **Let auto-selection work** - it picks the cheapest appropriate model
|
||||
4. **Reuse successful patches** instead of regenerating
|
||||
|
||||
---
|
||||
|
||||
## API Quick Reference
|
||||
|
||||
```bash
|
||||
# List available patches
|
||||
GET /patches/
|
||||
|
||||
# Get patch details
|
||||
GET /patches/{id}
|
||||
|
||||
# Get patch image
|
||||
GET /patches/{id}/image
|
||||
GET /patches/{id}/image?thumbnail=true
|
||||
|
||||
# Create patch from AI edit
|
||||
POST /patches/
|
||||
{
|
||||
"name": "My Patch",
|
||||
"source_type": "ai_generated",
|
||||
"source_edit_id": 123,
|
||||
"category": "hand"
|
||||
}
|
||||
|
||||
# Create patch from manual selection
|
||||
POST /patches/
|
||||
{
|
||||
"name": "My Patch",
|
||||
"source_type": "manual_selection",
|
||||
"source_project_id": 456,
|
||||
"bbox": {"x": 100, "y": 100, "width": 200, "height": 200}
|
||||
}
|
||||
|
||||
# Apply saved patch
|
||||
POST /patches/apply
|
||||
{
|
||||
"project_id": 789,
|
||||
"patch_id": 123,
|
||||
"bbox": {"x": 300, "y": 400, "width": 200, "height": 200},
|
||||
"feather_px": 10
|
||||
}
|
||||
|
||||
# Delete patch
|
||||
DELETE /patches/{id}
|
||||
|
||||
# Update patch metadata
|
||||
PUT /patches/{id}
|
||||
{
|
||||
"name": "Updated Name",
|
||||
"tags": "new, tags",
|
||||
"category": "hand"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Summary
|
||||
|
||||
✅ **For hands/faces/bodies:** Use `realistic-vision` model
|
||||
✅ **For removal:** Use `lama` model
|
||||
✅ **For general edits:** Use `sdxl-inpaint` (default)
|
||||
✅ **Auto-selection works great** - just write natural prompts
|
||||
✅ **Save good AI results** to patch library for reuse
|
||||
✅ **Save manual selections** from any image
|
||||
✅ **Reuse patches across images** to save money and maintain consistency
|
||||
|
||||
**You now have the best of both worlds:**
|
||||
- AI generation when you need something new
|
||||
- Saved patches when you need consistency or want to save money
|
||||
Reference in New Issue
Block a user