Last update broke using single images for the background when using video input for the foreground without adding animation effects. Corrected it and also improved frame composition.
GeekyRemB: Advanced Background Removal & Image Processing Node Suite for ComfyUI
GeekyRemB is a sophisticated image processing node suite that brings professional-grade background removal, blending, animation capabilities, and lighting effects to ComfyUI. It combines AI-powered processing with traditional image manipulation techniques to offer a comprehensive solution for complex image processing tasks.
Table of Contents
- Installation
- Node Overview
- Core Node: Geeky RemB
- Animation Node: Geeky RemB Animator
- Lighting & Shadow Node: Geeky RemB Light & Shadow
- Keyframe Position Node: Geeky RemB Keyframe Position
- Workflow Examples
- Advanced Features
- Troubleshooting
- License
- Acknowledgements
Installation
-
Install ComfyUI if you haven't already. Follow the ComfyUI installation guide for detailed instructions.
-
Clone the GeekyRemB repository into your ComfyUI custom nodes directory:
cd ComfyUI/custom_nodes git clone https://github.com/GeekyGhost/ComfyUI-GeekyRemB.git -
Install dependencies:
cd ComfyUI-GeekyRemB pip install -r requirements.txt -
Restart ComfyUI to load the new nodes.
Node Overview
GeekyRemB consists of four interconnected nodes that work together to provide a complete image processing system:
- Geeky RemB - The core node handling background removal, mask processing, and composition
- Geeky RemB Animator - Provides animation parameters for creating dynamic sequences
- Geeky RemB Light & Shadow - Controls lighting effects and shadow generation
- Geeky RemB Keyframe Position - Enables precise control through keyframe-based animation
These nodes can be used independently or connected together for advanced workflows.
Core Node: Geeky RemB
The main node responsible for background removal, image processing, and composition.
Key Features
-
AI-Powered Background Removal
- Multiple rembg models optimized for different subjects
- Professional chroma keying with color selection and tolerance control
-
Advanced Mask Processing
- Mask expansion/contraction
- Edge detection and refinement
- Blur and threshold controls
- Small region removal
-
Image Composition
- Position control for foreground elements
- Aspect ratio and scaling options
- Alpha channel management
-
Animation Support
- Multi-frame processing
- Integration with animation and lighting nodes
Usage Instructions
-
Basic Background Removal:
- Connect your input image to the
foregroundinput - Set
enable_background_removalto true - Choose your removal method (
rembgorchroma_key) - For
rembg, select an appropriate model for your subject - For
chroma_key, select the key color and adjust tolerance
- Connect your input image to the
-
Mask Refinement:
- Use
mask_expansionto grow or shrink the mask (positive values expand, negative contract) - Enable
edge_detectionand adjustedge_thicknessfor sharper outlines - Use
mask_blurto smooth edges - Enable
remove_small_regionsand setsmall_region_sizeto clean up noise
- Use
-
Advanced Composition:
- Connect a background image to the
backgroundinput - Set
x_positionandy_positionto place the foreground - Adjust
scaleto resize the foreground - Specify
aspect_ratiofor consistent dimensions
- Connect a background image to the
-
Using Alpha Matting:
- Enable
alpha_mattingfor high-quality edge refinement - Adjust
alpha_matting_foreground_thresholdandalpha_matting_background_thresholdfor fine control - Useful for subjects with fine details like hair or fur
- Enable
-
Animation Setup:
- Set
framesto the desired number of output frames - Connect an animator node to the
animatorinput - Connect a light & shadow node to the
lightshadowinput - Connect keyframe nodes to the
keyframeinput for precise control
- Set
Parameters Guide
Essential Parameters
- output_format: Choose between RGBA (with transparency) or RGB output
- foreground: The input image to process
- enable_background_removal: Toggle background removal processing
- removal_method: Choose between AI-based (
rembg) or color-based (chroma_key) - model: Select AI model for the
rembgmethod - chroma_key_color: Select the color to key out (
green,blue, orred) - chroma_key_tolerance: Adjust sensitivity of color keying (0.0-1.0)
- spill_reduction: Remove color spill from edges (0.0-1.0)
Mask Processing Parameters
- mask_expansion: Expand or contract the mask (-100 to 100)
- edge_detection: Enable edge detection for sharper outlines
- edge_thickness: Control thickness of detected edges (1-10)
- mask_blur: Apply blur to mask edges (0-100)
- threshold: Set the threshold for mask generation (0.0-1.0)
- invert_generated_mask: Invert the mask (switch foreground/background)
- remove_small_regions: Remove small artifacts from the mask
- small_region_size: Set minimum size of regions to keep (1-1000)
Composition Parameters
- aspect_ratio: Set output aspect ratio (e.g., "16:9", "4:3", "1:1", "portrait", "landscape")
- scale: Scale the foreground (0.1-5.0)
- frames: Number of frames to generate (1-1000)
- x_position: Horizontal position of foreground (-2048 to 2048)
- y_position: Vertical position of foreground (-2048 to 2048)
Advanced Parameters
- alpha_matting: Enable advanced edge refinement
- alpha_matting_foreground_threshold: Threshold for foreground detection (0-255)
- alpha_matting_background_threshold: Threshold for background detection (0-255)
- edge_refinement: Enable additional edge refinement for chroma key
Optional Inputs
- background: Secondary image for background composition
- additional_mask: Extra mask for complex selections
- invert_additional_mask: Invert the additional mask
- animator: Connection to GeekyRemB_Animator node
- lightshadow: Connection to GeekyRemB_LightShadow node
- keyframe: Connection to GeekyRemB_KeyframePosition node
Animation Node: Geeky RemB Animator
Provides animation parameters to the main GeekyRemB node, controlling movement, transitions, and timing.
Key Features
-
Multiple Animation Types:
- Movement animations (bounce, travel, slide)
- Transform animations (scale, rotate, flip)
- Opacity animations (fade in/out)
- Special effects (shake, wave, pulse)
-
Animation Control:
- Speed and duration settings
- Repeat and reverse options
- Easing functions for natural motion
-
Keyframe Support:
- Integration with keyframe position nodes
- Frame-accurate positioning
Usage Instructions
-
Basic Animation Setup:
- Add the Geeky RemB Animator node to your workflow
- Select the desired
animation_type - Set
animation_speedandanimation_duration - Connect the node's output to the main GeekyRemB node's
animatorinput
-
Animation Timing:
- Set
fpsto control the smoothness of animation - Adjust
repeatsto loop the animation - Enable
reverseto alternate direction on repeats - Set
delayto postpone the start of animation
- Set
-
Motion Control:
- Set the initial position with
x_positionandy_position - Adjust
scaleandrotationfor the starting state - Use
stepsto create multi-step animations - Set
phase_shiftfor staggered animations
- Set the initial position with
-
Keyframe Animation:
- Enable
use_keyframesto use keyframe-based animation - Connect keyframe position nodes to the
keyframe1throughkeyframe5inputs - Set
easing_functionto control the interpolation between keyframes
- Enable
Parameters Guide
Animation Type
- animation_type: Choose from various animation types:
none: No animationbounce: Up and down movementtravel_left/travel_right: Horizontal movementrotate: Continuous rotationfade_in/fade_out: Opacity transitionszoom_in/zoom_out: Scale transitionsscale_bounce: Pulsing size changesspiral: Combined rotation and movementshake: Quick oscillating movementsslide_up/slide_down: Vertical movementflip_horizontal/flip_vertical: Mirroring effectswave: Sinusoidal movementpulse: Periodic scalingswing: Pendulum-like rotationspin: Continuous spinningflash: Brightness fluctuation
Timing Controls
- animation_speed: Rate of animation (0.1-10.0)
- animation_duration: Length of one animation cycle (0.1-10.0)
- repeats: Number of times to repeat the animation (1-10)
- reverse: Toggle direction reversal on repeats
- fps: Frames per second (1-120)
- delay: Wait time before animation starts (0.0-5.0)
Motion Parameters
- x_position: Initial horizontal position (-1000 to 1000)
- y_position: Initial vertical position (-1000 to 1000)
- scale: Initial scale factor (0.1-5.0)
- rotation: Initial rotation angle (-360.0 to 360.0)
- steps: Number of steps in multi-step animations (1-10)
- phase_shift: Phase shift for staggered animations (0.0-1.0)
Easing Functions
- easing_function: Controls how animations accelerate/decelerate:
linear: Constant speedease_in_quad/ease_out_quad/ease_in_out_quad: Quadratic easingease_in_cubic/ease_out_cubic/ease_in_out_cubic: Cubic easingease_in_sine/ease_out_sine/ease_in_out_sine: Sinusoidal easingease_in_expo/ease_out_expo/ease_in_out_expo: Exponential easingease_in_bounce/ease_out_bounce/ease_in_out_bounce: Bouncy easing
Keyframe Controls
- use_keyframes: Enable keyframe-based animation
- keyframe1 through keyframe5: Connect to keyframe position nodes
Lighting & Shadow Node: Geeky RemB Light & Shadow
Controls lighting effects and shadow generation for the processed images.
Key Features
-
Realistic Lighting Effects:
- Directional lighting with intensity control
- Light color and falloff adjustment
- Normal mapping for 3D-like lighting
- Specular highlights for reflective surfaces
-
Dynamic Shadow Generation:
- Shadow opacity and blur control
- Shadow direction and color customization
- Perspective shadows for realism
- Distance-based shadow fading
Usage Instructions
-
Basic Lighting Setup:
- Add the Geeky RemB Light & Shadow node to your workflow
- Enable
enable_lightingto activate lighting effects - Adjust
light_intensityto control strength - Set
light_direction_xandlight_direction_yto position the light source - Connect the node's output to the main GeekyRemB node's
lightshadowinput
-
Light Customization:
- Choose between RGB color control or Kelvin temperature
- Enable
use_kelvin_temperatureand setkelvin_temperaturefor natural lighting - Or adjust
light_color_r,light_color_g, andlight_color_bfor custom colors - Set
light_radiusandlight_falloffto control illumination area
-
Advanced Lighting:
- Enable
enable_normal_mappingfor 3D-like lighting effects - Turn on
enable_specularand adjustspecular_intensityfor highlights - Set
specular_shininessto control highlight sharpness - Adjust
ambient_lightfor global illumination level
- Enable
-
Shadow Configuration:
- Enable
enable_shadowto activate shadow generation - Set
shadow_opacityandshadow_blurfor shadow appearance - Adjust
shadow_direction_xandshadow_direction_yfor shadow placement - Customize
shadow_color_r,shadow_color_g, andshadow_color_b
- Enable
-
Realistic Shadows:
- Enable
perspective_shadowfor distance-based perspective effects - Set
light_source_heightto control shadow length - Turn on
distance_fadeand adjustfade_distancefor natural fading - Toggle
soft_edgesfor realistic shadow edges
- Enable
Parameters Guide
Lighting Controls
- enable_lighting: Toggle lighting effects
- light_intensity: Strength of lighting effect (0.0-1.0)
- light_direction_x: Horizontal light direction (-200 to 200)
- light_direction_y: Vertical light direction (-200 to 200)
- light_radius: Area of light effect (10-500)
- light_falloff: Rate of light falloff (0.1-3.0)
- light_from_behind: Toggle backlighting effect
Light Color
- use_kelvin_temperature: Use color temperature instead of RGB
- kelvin_temperature: Light color temperature (2000-10000K)
- light_color_r/g/b: RGB components of light color (0-255)
Advanced Lighting
- enable_normal_mapping: Enable 3D-like lighting effects
- enable_specular: Add specular highlights
- specular_intensity: Strength of highlights (0.0-1.0)
- specular_shininess: Sharpness of highlights (1-128)
- ambient_light: Global illumination level (0.0-1.0)
- light_source_height: Height of light source (50-500)
Shadow Controls
- enable_shadow: Toggle shadow generation
- shadow_opacity: Shadow transparency (0.0-1.0)
- shadow_blur: Shadow edge softness (0-50)
- shadow_direction_x: Horizontal shadow offset (-50 to 50)
- shadow_direction_y: Vertical shadow offset (-50 to 50)
- shadow_expansion: Shadow size adjustment (-10 to 20)
- shadow_color_r/g/b: RGB components of shadow color (0-255)
Advanced Shadow
- perspective_shadow: Enable perspective-based shadows
- distance_fade: Fade shadow with distance
- fade_distance: Distance at which shadow begins to fade (10-500)
- soft_edges: Toggle soft shadow edges
Keyframe Position Node: Geeky RemB Keyframe Position
Provides precise control over animation through keyframe-based positioning.
Key Features
- Frame-Specific Controls:
- Position, scale, and rotation settings for specific frames
- Opacity control for visibility transitions
- Easing function selection for smooth interpolation
Usage Instructions
-
Creating Keyframes:
- Add the Geeky RemB Keyframe Position node to your workflow
- Set
frame_numberto the target frame - Adjust
x_positionandy_positionfor placement - Set
scaleandrotationas needed - Connect multiple keyframe nodes to the Animator's keyframe inputs
-
Keyframe Configuration:
- Define the canvas size with
widthandheight - Set
opacityfor transparency control - Select an
easingfunction for interpolation between keyframes
- Define the canvas size with
-
Building Keyframe Sequences:
- Create multiple keyframe nodes with different frame numbers
- Connect them to consecutive keyframe inputs on the Animator node
- Enable
use_keyframeson the Animator node
Parameters Guide
Canvas Settings
- width: Width of the animation canvas (64-4096)
- height: Height of the animation canvas (64-4096)
Keyframe Controls
- frame_number: Target frame for this keyframe (0-1000)
- x_position: Horizontal position at this keyframe (-2048 to 2048)
- y_position: Vertical position at this keyframe (-2048 to 2048)
- scale: Scale factor at this keyframe (0.1-5.0)
- rotation: Rotation angle at this keyframe (-360.0 to 360.0)
- opacity: Transparency at this keyframe (0.0-1.0)
Interpolation
- easing: Easing function for interpolation to the next keyframe
- Options match the easing functions available in the Animator node
Workflow Examples
Basic Background Removal
- Connect an image source to Geeky RemB's
foregroundinput - Set
enable_background_removalto true - Choose
rembgas the removal method - Select an appropriate model (e.g.,
u2netfor general purposes,isnet-animefor anime images) - Adjust mask processing parameters as needed
- Connect the output to your workflow
Animated Character with Lighting
-
Add a Geeky RemB Animator node
- Set
animation_typetobounce - Set
animation_speedto 1.0 - Set
repeatsto 2 - Set
easing_functiontoease_in_out_sine
- Set
-
Add a Geeky RemB Light & Shadow node
- Enable
enable_lightingandenable_shadow - Set
light_direction_xto -50 andlight_direction_yto -100 - Set
shadow_opacityto 0.4 - Set
shadow_blurto 15
- Enable
-
Connect both to a Geeky RemB node
- Connect your character image to
foreground - Connect a background image to
background - Set
framesto 30 - Set
enable_background_removalto true
- Connect your character image to
Keyframe Animation Sequence
-
Create multiple Geeky RemB Keyframe Position nodes:
- Keyframe 1:
frame_number: 0,x_position: 0,y_position: 0 - Keyframe 2:
frame_number: 15,x_position: 200,y_position: -50,rotation: 45 - Keyframe 3:
frame_number: 30,x_position: 400,y_position: 0,rotation: 0
- Keyframe 1:
-
Add a Geeky RemB Animator node:
- Set
use_keyframesto true - Connect the keyframe nodes to
keyframe1,keyframe2, andkeyframe3 - Set
fpsto 30
- Set
-
Connect to a Geeky RemB node:
- Set
framesto 30 - Set other parameters as needed
- Set
Advanced Features
Multi-frame Processing with Thread Pooling
GeekyRemB optimizes performance by using thread pools to process multiple frames in parallel. This makes it efficient for handling animations and batch processing.
Sophisticated Caching System
An LRU (Least Recently Used) cache system is implemented to store and reuse processed frames, reducing redundant computations and improving performance.
Edge Refinement Techniques
Multiple edge processing methods are available, including alpha matting, edge detection, and mask refinement, enabling high-quality results even with complex subjects.
Perspective Shadow Generation
The shadow system can create realistic perspective-based shadows that simulate the effect of a 3D light source, adding depth to compositions.
Normal Mapping for 3D-like Lighting
Advanced lighting effects include normal mapping, which simulates surface details for more realistic illumination without requiring actual 3D models.
Troubleshooting
Common Issues and Solutions
-
Slow Background Removal
- Try using a lighter model like
u2netpinstead ofu2net - Reduce the image size before processing
- Ensure GPU acceleration is available and enabled
- Try using a lighter model like
-
Poor Edge Quality
- Enable
alpha_mattingfor better edge refinement - Adjust
mask_blurfor smoother edges - Try different
mask_expansionvalues
- Enable
-
Memory Issues with Animation
- Reduce the number of frames
- Lower the resolution of input images
- Close other memory-intensive applications
-
Missing Shadow or Light Effects
- Verify that both
enable_lightingandenable_shadoware turned on - Check that the Light & Shadow node is connected to the main node
- Adjust direction values to ensure effects are visible
- Verify that both
-
Keyframes Not Working
- Confirm that
use_keyframesis enabled on the Animator node - Check that keyframe nodes are connected in the correct order
- Verify that frame numbers are set correctly and within range
- Confirm that
Performance Optimization
- Use the appropriate rembg model for your needs - lighter models like
u2netpare faster - For batch processing, set a reasonable number of frames to avoid memory issues
- Adjust thread count if needed by modifying the
max_workersvalue in the code - Pre-process images to reduce resolution before applying effects
License
This project is licensed under the MIT License. See the LICENSE file for details.
Note: Some included models may have separate licensing requirements for commercial use.
Acknowledgements
GeekyRemB builds upon several outstanding open-source projects:
- Rembg by Daniel Gatis: Core background removal capabilities
- ComfyUI: The foundation of our node system
- WAS Node Suite: Inspiration for layer utility features
Special thanks to:
- The ComfyUI Community: For valuable feedback and suggestions
- Open-Source Contributors: Who help improve the nodes continuously
- AI Model Creators: Whose work enables our advanced background removal features
For updates, issues, or contributions, please visit the GitHub repository. We welcome feedback and contributions from the community.