- Added Actions gallery with CRUD and JSON sync - Implemented Triple LoRA workflow (Character -> Outfit -> Action) - Added character-integrated previews for Actions with style matching - Implemented granular prompt selection and default persistence for Actions - Added detailed development guide for extending gallery features
2.9 KiB
Feature Development Guide: Gallery Pages & Character Integration
This guide outlines the architectural patterns and best practices developed during the implementation of the Actions and Outfits galleries. Use this as a blueprint for adding similar features (e.g., "Scenes", "Props", "Effects").
1. Data Model & Persistence
- Database Model: Add a new class in
models.py. Includedefault_fields(JSON) to support persistent prompt selections. - JSON Sync: Implement a
sync_[feature]()function inapp.pyto keep the SQLite database in sync with thedata/[feature]/*.jsonfiles. - Slugs: Use URL-safe slugs generated from the ID for clean routing.
2. Triple LoRA Chaining
Our workflow supports chaining three distinct LoRAs from specific directories:
- Character:
Illustrious/Looks/(Node 16) - Outfit:
Illustrious/Clothing/(Node 17) - Action/Feature:
Illustrious/Poses/(Node 18)
Implementation Detail:
In _prepare_workflow, LoRAs must be chained sequentially. If a previous LoRA is missing, the next one must "reach back" to the Checkpoint (Node 4) or the last valid node in the chain to maintain the model/CLIP connection.
3. Adetailer Routing
To improve generation quality, route specific JSON sub-fields to targeted Adetailers:
- Face Detailer (Node 14): Receives
character_name,expression, and action-specifichead/eyestags. - Hand Detailer (Node 15): Receives priority hand tags (Wardrobe Gloves > Wardrobe Hands > Identity Hands) and action-specific
arms/handstags.
4. character-Integrated Previews
The "Killer Feature" is previewing a standalone item (like an Action or Outfit) on a specific character.
Logic Flow:
- Merge Data: Copy
character.data. - Override/Merge: Replace character
defaultswith feature-specific tags (e.g., Action pose overrides Character pose). - Context Injection: Append character-specific styles (e.g.,
[primary_color] simple background) to the main prompt. - Auto-Selection: When a character is selected, ensure their
identityandwardrobefields are automatically included in the prompt, even if the feature page has its own manual checkboxes.
5. UI/UX Patterns
- Selection Boxes: Use checkboxes next to field labels to allow users to toggle specific tags.
- Default Selection: Implement a "Save as Default Selection" button that persists the current checkbox state to the database.
- Session State: Store the last selected character and field preferences in the Flask
sessionto provide a seamless experience when navigating between items. - AJAX Generation: Use the WebSocket + Polling hybrid pattern in the frontend to show real-time progress bars without page reloads.
6. Directory Isolation
Always isolate LoRAs by purpose to prevent dropdown clutter:
get_available_loras()-> Charactersget_available_clothing_loras()-> Outfitsget_available_action_loras()-> Actions/Poses