GeekyGhost cd754900a9 Update GeekyRembv2.py
Foreground Scaling and Aspect Ratio:

New: Introduced separate foreground_scale and foreground_aspect_ratio parameters.
Original: Used scale and aspect_ratio parameters.


Input Types:

New: Removed scale and aspect_ratio from the main INPUT_TYPES and added foreground_scale and foreground_aspect_ratio to the optional inputs.
Original: Had scale and aspect_ratio in the optional inputs.


Mask Processing:

New: Added a separate process_mask method to handle mask operations (inversion, expansion, blurring).
Original: Mask processing was done within the process_single_image function.


Image Resizing Logic:

New: More sophisticated logic for resizing the foreground image, considering both scale and aspect ratio separately.
Original: Simpler resizing logic using a single scale factor.


Opacity Handling:

New: Applied opacity to both the foreground image and its mask separately.
Original: Applied opacity to the entire scaled foreground image.


Error Handling:

New: More specific error handling in the process_single_image function.
Original: Less detailed error handling.


Code Structure:

New: Generally more modular with separate functions for different operations.
Original: More operations combined in the process_single_image function.


Default Values:

New: Introduced default values for foreground scale and aspect ratio based on the original image dimensions.
Original: Used fixed default values for scale and aspect ratio.


Compatibility:

New: Designed to be more flexible with optional parameters for foreground scaling and aspect ratio.
Original: Less flexible in terms of foreground image manipulation.


Performance Optimizations:

New: Potential for better performance due to more efficient mask processing and image manipulation.
Original: Less optimized in terms of image and mask processing.
2024-07-18 19:14:23 -04:00
2024-07-18 17:52:27 -04:00
2024-07-18 19:14:23 -04:00
2024-06-28 11:28:41 -04:00
2024-07-14 04:52:39 -04:00
2024-07-14 02:22:39 -04:00

This is a custom node for ComfyUI which can be found here! https://github.com/comfyanonymous/ComfyUI

ComfyUI-GeekyRemB ComfyUI-GeekyRemB

Overview ComfyUI-GeekyRemB is a powerful and versatile image processing node for ComfyUI, designed to remove or replace backgrounds with advanced customization options. This node leverages the rembg library and offers a wide range of features for fine-tuning the background removal process and enhancing the resulting images. Key Features

Multiple Background Removal Models: Supports various AI models for accurate background removal:

u2net u2netp u2net_human_seg u2net_cloth_seg silueta isnet-general-use isnet-anime

Alpha Matting: Enables fine-tuned edge detection for smoother transitions between foreground and background. Chroma Key: Offers additional background removal using color-based keying for green, blue, or red backgrounds. Flexible Background Modes:

Transparent Solid color Image replacement

Advanced Mask Processing:

Supports input masks Mask inversion Feathering for precise control

Edge Detection: Adds customizable outlines to the extracted foreground. Shadow Generation: Creates realistic drop shadows for extracted foreground objects. Color Adjustment: Modify brightness, contrast, and saturation of the output image. Scaling and Positioning: Resize and reposition the foreground image when using image backgrounds. Batch Processing: Efficiently handles multiple images in a single operation.

Usage

Input an image or batch of images for background removal.

Select the desired AI model for background removal.

Adjust alpha matting settings for edge refinement if needed.

Apply chroma keying if working with solid color backgrounds.

Choose the background mode (transparent, color, or image).

Fine-tune the result with mask processing, edge detection, and shadow options.

Adjust color settings as needed.

Scale and position the foreground when using image backgrounds.

The node outputs both the processed image(s) and the corresponding mask(s), allowing for further manipulation in your ComfyUI workflow.

Implementation Details

For developers interested in the technical aspects:

Chroma Key Implementation: The apply_chroma_key function uses OpenCV (cv2) to perform color-based background removal. It converts the image to HSV color space and creates a mask based on the specified color range.

Image Processing Core: The process_single_image function handles the main image processing logic, including background removal, mask application, and all post-processing effects.

Batch Processing: The remove_background function manages batch processing and overall node operation. It uses tqdm for progress tracking during batch operations.

Tensor Handling: The node uses PyTorch tensors for efficient GPU processing, with helper functions tensor2pil and pil2tensor for conversion between tensor and PIL image formats.

Image Manipulation: Extensive use of PIL (Python Imaging Library) for various image processing tasks, including resizing, rotating, and applying filters.

Installation [Include instructions for installing the node in ComfyUI] Dependencies

numpy rembg Pillow torch opencv-python (cv2) tqdm

Acknowledgements Special thanks to WASasquatch for licensing their repository under the MIT license, which has contributed to the development and enhancement of this node. License [MIT] Contributing [Claude Sonnet 3.5 fixing my mess]

Screenshot 2024-06-29 134500

Output examples can be found here - https://civitai.com/models/546180/geeky-remb

Remember, the effectiveness of each setting can vary depending on the input image. Experimentation is key to achieving the best results for your specific use case within ComfyUI workflows.

Inspired by tools found here https://github.com/WASasquatch/was-node-suite-comfyui.git

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