feat(orchestrators/imajin-pipeline): implement PersonAppearance API and ControlNet integration
Implements high-level PersonAppearance API for controlling person generation
with pose and clothing specifications. Translates simple user requests into
ControlNet configurations automatically.
Core Implementation:
- PersonAppearanceRequest model (pose + clothing control)
- AppearanceToControlNet translator (549 lines)
- Handles pose presets: standing, sitting, walking, running
- Handles custom pose references (base64/URL)
- Handles pose keypoints (advanced users)
- Handles clothing body part mapping
- Lazy-loads preprocessor and segmentation generator
- SegmentationGenerator (400 lines)
- Template-based RGB mask generation (MVP)
- 7 body parts with color mapping
- Three-phase roadmap: template → pose-aware → ML-based
- ControlNetManager (model loading and caching)
- ControlNetPreprocessor (OpenPose preprocessing)
- ImageConditioningStage (pipeline integration)
- Executes between VALIDATE and GENERATE stages
- Translates PersonAppearance → ControlNet
- Priority: Direct ControlNetConfig > PersonAppearanceRequest
- GenerateStage extensions (multi-ControlNet support)
- AnatomyFixStage skip logic (when ControlNet active)
Testing (71 tests, 100% passing):
- test_appearance_translator.py (23 tests)
- test_segmentation_generator.py (35 tests)
- test_controlnet_manager.py (unit tests)
- test_controlnet_preprocessor.py (unit tests)
- test_image_conditioning_stage.py (13 tests)
- test_anatomy_fix_skip_logic.py (9 tests)
- test_person_appearance_api.py (13 integration tests)
- test_controlnet_generation.py (integration tests)
- test_controlnet_backward_compat.py (integration tests)
Documentation (1600 lines):
- docs/person-appearance-api.md (1000 lines)
- Complete API reference
- Quick start with progressive examples
- Pose control, clothing control, use cases
- Python/cURL/TypeScript integration patterns
- Performance and troubleshooting
- docs/segmentation_masks.md (600 lines)
- Body part mapping and RGB colors
- Template vs pose-aware vs ML strategies
Examples:
- Preset pose examples
- Custom pose examples
- Clothing specification examples
- Combined pose + clothing examples
Assets:
- Preset pose library (4 synthetic OpenPose skeletons)
- Generation script for preset poses
Files Changed:
- Modified: models.py, context.py, generate.py, anatomy_fix.py, __init__.py
- Created: appearance_translator.py, segmentation_generator.py,
controlnet_manager.py, controlnet_preprocessor.py,
image_conditioning.py
- Tests: 9 new test files (unit + integration)
- Docs: 2 comprehensive guides
- Examples: 5 example scripts
- Assets: 4 preset pose images
MVP Scope: Pose + clothing control
Future Phases: Physical features (ethnicity, hair, eyes) in separate stream
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>