GeekyRemB: Advanced Background Removal & Image Processing Node for ComfyUI

https://github.com/user-attachments/assets/3d37362c-2021-44e5-9810-4453262443fd

GeekyRemB is a sophisticated image processing node that brings professional-grade background removal, blending, and animation capabilities 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

  1. User Guide
  2. Developer Documentation
  3. License
  4. Acknowledgements

User Guide

Installation

  1. Install ComfyUI if you haven't already
  2. Clone the repository into your ComfyUI custom nodes directory:
    git clone https://github.com/YourUsername/ComfyUI-GeekyRemB.git
    
  3. Install dependencies:
    pip install -r requirements.txt
    
  4. Restart ComfyUI

Features

Background Removal

  • AI-powered removal using multiple models
    • u2net: General purpose, high quality
    • u2netp: Faster processing
    • u2net_human_seg: Optimized for people
    • u2net_cloth_seg: Specialized for clothing
    • silueta: Enhanced edge detection
    • isnet-general-use: Balanced performance
    • isnet-anime: Optimized for anime/cartoon
  • Professional chroma keying with RGB support
  • Advanced alpha matting for edge refinement

Image Processing

  • Professional blend modes matching industry standards
  • Precise mask refinement tools
  • Support for images of different dimensions
  • Automatic alpha channel management

Animation

  • Multiple animation types:
    • Bounce: Smooth up/down motion
    • Travel: Linear movement
    • Rotate: Circular motion
    • Fade: Opacity transitions
    • Zoom: Scale transitions
  • Configurable speed and frame count
  • Position, scale, and rotation control

Parameters Guide

Essential Settings

  • enable_background_removal: Toggle background processing
  • removal_method: Choose between AI ("rembg") or color-based ("chroma_key")
  • model: Select AI model for "rembg" method
  • blend_mode: Choose how foreground and background combine
  • opacity: Control the strength of blending (0.0-1.0)

Advanced Settings

  • mask_expansion: Fine-tune mask edges (-100 to 100)
  • edge_detection: Enable additional edge processing
  • mask_blur: Smooth mask edges (0-100)
  • alpha_matting: Enable sophisticated edge processing
  • remove_small_regions: Clean up mask artifacts
  • animation_type: Select movement style
  • animation_speed: Control motion speed
  • animation_frames: Set number of output frames

Optional Inputs

  • background: Secondary image for composition
  • additional_mask: Extra mask for complex selections
  • aspect_ratio: Control output dimensions

Developer Documentation

Technical Implementation

Blend Mode System

The node features a sophisticated blending engine that handles complex image compositions:

class BlendMode:
    @staticmethod
    def _ensure_rgba(img):
        """Guarantees RGBA format for consistent processing"""
        
    @staticmethod
    def _apply_blend(target, blend, operation, opacity):
        """Core blending logic with alpha handling"""

Key features:

  • Proper alpha channel management
  • Automatic dimension handling
  • Memory-efficient processing
  • Numerical precision optimization

Animation Engine

The animation system provides smooth, configurable motion:

def animate_element(self, element, animation_type, speed, frame):
    """Generates precise frame-by-frame animations"""

Features:

  • Frame-accurate positioning
  • Sub-pixel interpolation
  • Memory pooling for frame sequences
  • Automatic boundary handling

Background Removal

Multiple removal strategies with sophisticated refinement:

def remove_background_rembg(self, image, alpha_matting):
    """AI-powered background removal with edge refinement"""
    
def remove_background_chroma(self, image, color, tolerance):
    """Color-based removal with precision control"""

Highlights:

  • Model-specific optimizations
  • GPU acceleration when available
  • Advanced edge detection
  • Artifact reduction

Performance Optimizations

The node includes several performance enhancements:

  • ThreadPoolExecutor for parallel processing
  • Efficient numpy operations
  • Smart caching system
  • Memory management optimizations

Error Handling

Robust error management throughout:

try:
    result = self.process_frame(frame, background)
except Exception as e:
    logger.error(f"Processing error: {str(e)}")
    return self.fallback_process(frame)

Notable Technical Achievements

  1. Seamless handling of images with different dimensions
  2. Professional-grade blend modes matching industry standards
  3. Efficient batch processing with memory optimization
  4. Sophisticated alpha channel management
  5. Frame-accurate animation system
  6. Robust error recovery mechanisms

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 node
  • AI model creators whose work enables our background removal features

For updates, issues, or contributions, please visit the GitHub repository. We welcome feedback and contributions from the community.

S
Description
No description provided
Readme MIT
271 KiB
Languages
Python 100%