GeekyRemB: Advanced Background Removal and Image/Video Manipulation Extension for Automatic1111 Web UI
GeekyRemB is a comprehensive extension for the Automatic1111 Web UI, built to bring advanced background removal, image/video manipulation, and blending capabilities into your projects. It offers precise background removal with support for multiple models, chroma keying, foreground adjustments, and advanced effects. Whether working with images or videos, this extension provides everything you need to manipulate visual content efficiently within the Automatic1111 environment.
tmphk52e541.2.mp4
- Multi-model Background Removal: Supports
u2net
,isnet-general-use
, and other models. - Chroma Key Support: Remove specific colors (green, blue, or red) from backgrounds.
- Blending Modes: 10 powerful blend modes for image compositing.
- Foreground Adjustments: Scale, rotate, flip, and position elements precisely.
- Video and Image Support: Process images and videos seamlessly.
- Batch and Multi-threaded Processing: Handle large files efficiently using threading and GPU support.
- Customizable Output Formats: Export in PNG, JPEG, MP4, AVI, and more.
-
Clone the Repository:
git clone https://github.com/GeekyGhost/Automatic1111-Geeky-Remb.git
-
Move to the Extensions Folder: Navigate to your Automatic1111 Web UI installation directory and move the repository into the
extensions
folder:mv Automatic1111-Geeky-Remb ./extensions/
-
Restart the Web UI or use the Reload button within the Web UI to register the extension.
-
Access the Extension: Open the GeekyRemB tab within the Web UI to begin.
- Select Input Type: Choose between Image or Video as your input.
- Upload Foreground Content: Provide the image or video you want to manipulate.
- Adjust Foreground Settings: Modify scaling, aspect ratio, position, rotation, and blending modes.
- Apply Background Removal: Use AI models or chroma key to remove backgrounds.
- Choose Output Format: Select PNG, JPEG, MP4, or other formats.
- Click ‘Run GeekyRemB’: Process the input to generate your final output.
-
Input Type:
Choose between Image or Video. -
Foreground Upload:
Upload your image or video content. -
Output Type:
Define whether the result will be an Image or Video.
-
Scale:
Adjust the size of the foreground between 0.1 to 5.0. -
Aspect Ratio:
Use ratios like16:9
or terms likeportrait
orsquare
. -
Rotation & Position:
Rotate the element from -360° to 360° and adjust X/Y positions within a -1000 to 1000 range. -
Flip Options:
Flip the foreground horizontally or vertically.
-
Remove Background:
Use AI models (e.g.,u2net
) for automatic background removal. -
Chroma Key:
Select a chroma key color (green, blue, red) and set tolerance levels. -
Background Mode:
Options include transparent, solid color, image, or video backgrounds.
-
Blending Modes:
Choose from 10 blend modes:- Normal, Multiply, Screen, Overlay, Soft Light, Hard Light, Difference, Exclusion, Color Dodge, Color Burn.
-
Shadow and Edge Detection:
Add shadows and edges with adjustable thickness and blur. -
Alpha Matting:
Fine-tune mask edges using alpha matting thresholds.
-
Custom Dimensions:
Enable to specify width and height manually. -
Output Formats:
Export images as PNG, JPEG, WEBP, and videos as MP4, AVI, or MOV. -
Video Quality:
Set video quality from 0-100 for optimized exports.
This extension is built with modular, extensible code. Below is an in-depth look at the core classes and methods.
Manages sessions, background removal, threading, and GPU support.
__init__()
:
Initializes the session, checks for CUDA availability, and sets threading parameters.
Handles background removal, blending, chroma keying, and effect applications.
Parameters:
model
: AI model to use for removal.alpha_matting
: Enables edge refinement.chroma_key
: Applies chroma key color.blend_mode
: Blend mode for the result.foreground_scale
: Controls the scale of the foreground.
This function processes both image and video inputs, performing transformations and applying custom background settings.
Applies one of 10 blending modes for compositing.
def apply_blend_mode(target, blend, mode="normal", opacity=1.0):
# Ensures both images have the same dimensions and channels
result = self.blend_modes[mode](target, blend, opacity)
return np.clip(result * 255, 0, 255).astype(np.uint8)
Supported blend modes:
- Normal, Multiply, Screen, Overlay, Soft Light, Hard Light, Difference, Exclusion, Color Dodge, Color Burn
Processes video frame-by-frame using threading for efficient execution.
def process_video(input_path, output_path, background_video_path, *args):
cap = cv2.VideoCapture(input_path)
fps = cap.get(cv2.CAP_PROP_FPS)
# Process frames and write output
...
This function supports CUDA-accelerated encoding and uses ffmpeg for post-processing.
Interprets aspect ratios provided by the user. Accepts terms like portrait
, landscape
, or numerical ratios.
Calculates new dimensions based on scaling and aspect ratio.
def calculate_new_dimensions(self, orig_width, orig_height, scale, aspect_ratio):
new_width = int(orig_width * scale)
new_height = int(new_width / aspect_ratio) if aspect_ratio else int(orig_height * scale)
return new_width, new_height
- GPU Support: Automatically detects and leverages CUDA for faster video processing.
- Thread Pooling: Uses
ThreadPoolExecutor
to batch-process multiple frames. - Memory Management: Dynamically controls batch size to optimize performance.
-
Edges are not smooth?
Enable alpha matting and adjust thresholds for better results. -
Chroma key not working correctly?
Increase the color tolerance to capture more shades of the key color. -
Output size not as expected?
Use the custom dimensions feature to manually set the desired size.
- Real-time Preview: Provide live feedback for adjustments.
- Animation Support: Add keyframe-based animation for dynamic videos.
- New Models: Incorporate additional models for niche use cases.
- rembg Library: This extension is built on top of the rembg library.
- Automatic1111 Community: Thanks to the community for continuous inspiration and support.
We welcome contributions!
Feel free to submit pull requests or open issues with ideas, improvements, or bug reports.
With GeekyRemB, unlock new possibilities in creative projects. Whether you need to fine-tune images or apply advanced effects to videos, this extension empowers your workflow with precision and control.
Recording.2024-10-23.231528.mp4
Happy creating! 🎨