How geekyghost/comfyui-geekyremb works
Project Type and Purpose
• Type: A ComfyUI plugin (node suite) for advanced image‐processing tasks
• Purpose: Provide four interconnected custom nodes (Geeky RemB, Animator, Light & Shadow, Keyframe Position) that extend ComfyUI’s graph-based workflow with AI-powered background removal, mask processing, composition, animation, lighting, and shadow effects.
Main Architectural Components
a. Host Application Layer
– ComfyUI Core (graph editor, node execution engine, UI)
– Plugin Loader (scans custom_nodes and registers Python node definitions)
b. Node Definition Layer (scripts/GeekyRembv2.py)
– GeekyRemB Core Node
– GeekyRemB Animator Node
– GeekyRemB Light & Shadow Node
– GeekyRemB Keyframe Position Node
c. Processing Modules (internal to the node suite)
– Background Removal Module (wraps rembg models, chroma keying)
– Mask Processing Module (expansion, contraction, edge detection, blur, small region removal)
– Composition Module (position, scale, aspect ratio, alpha channel management)
– Animation Module (parameter handling, easing, multi-frame orchestration)
– Lighting & Shadow Module (normal mapping, specular, directional light, shadow generation, perspective)
– Keyframe Manager (frame‐specific transforms, interpolation)
d. Shared Infrastructure
– Thread Pool (concurrent frame processing)
– LRU Cache (reuse processed masks/frames)
– Configuration & Metadata (pyproject.toml, requirements.txt, .github workflows)
e. External Dependencies & Models
– Python Packages: rembg, Pillow (PIL), numpy, ComfyUI API
– AI Models: u2net, isnet-anime, lighter variants
– OS-level: GPU acceleration (optional)
Relationships and Data Flows
• User Input (image source files) → ComfyUI UI → Node Graph Editor
• ComfyUI Execution Engine
→ Instantiates Node Definitions (GeekyRemB suite)
→ Passes data buffers (image, mask, parameters)
• Within a single workflow:
1. Input Image → GeekyRemB Core Node
↳ Calls Background Removal → Mask Processing → Composition
2. GeekyRemB Animator Node (optional)
↳ Supplies per‐frame transform & timing parameters
3. GeekyRemB Light & Shadow Node (optional)
↳ Applies lighting & generates shadows
4. GeekyRemB Keyframe Position Node(s) (optional)
↳ Overrides transform at specified frames
5. Frame outputs stored in LRU Cache and delivered to downstream nodes or final output
• Thread Pool manages concurrent execution of multi‐frame tasks.
• LRU Cache intercepts repeated requests for identical input/parameters.
Architectural Patterns & Principles
• Plugin Architecture: loose coupling between ComfyUI core and custom nodes
• Graph / Dataflow Pattern: nodes as composable functional units
• Modular Design: each feature set (background removal, animation, lighting) in its own module
• Concurrency & Caching: optimize performance for animations and batch processing
• Dependency Injection: parameter objects injected into processing modules