ComfyUI-BiRefNet-ZHO is an enhanced version of the BiRefNet extension for ComfyUI, designed to provide superior background removal capabilities for both images and videos. This extension is particularly useful for AI artists who need to isolate subjects from their backgrounds with high precision and efficiency. ComfyUI-BiRefNet-ZHO operates by utilizing the BiRefNet model, which is a cutting-edge neural network designed for high-resolution dichotomous image segmentation. In simpler terms, it can accurately distinguish and separate the foreground (the main subject) from the background in both images and videos.
Imagine you have a photo of a person standing in front of a complex background. ComfyUI-BiRefNet-ZHO can automatically detect the person and remove the background, leaving you with a clean image of the person on a transparent background. The extension separates the tasks of model loading and image processing, which significantly enhances the processing speed. One of the standout features is the ability to directly output images with transparent backgrounds in PNG format. ComfyUI-BiRefNet-ZHO extends its capabilities to video processing, allowing you to remove backgrounds from videos seamlessly. The extension can also output masks, which are black-and-white images where the foreground is white, and the background is black. The extension uses the BiRefNet model, which is currently one of the best open-source, commercially usable background removal models available.
Key Architecture and Workflow
The solution emphasizes a two-part design: loader and processor. Load the BiRefNet model once, cache it in the graph, and let downstream runs reuse it. The birefnet_model dropdown lists checkpoint files found in ./models/BiRefNet, while torch.load reads the state dict, strips the _orig_mod. prefix, and loads it into the BiRefNet architecture inside the pack. The output is a BRNMODEL object that wires directly into the 🧹BiRefNet node.
To ensure smooth operation, install and restart as needed. The process requires timm as a dependency because the Swin backbone relies on it. Checkpoints come from the HuggingFace repository, and weights should be placed in ComfyUI/models/BiRefNet before restarting so the dropdown can detect them. The dropdown lists only files already present, so a fresh install will show nothing until weights are downloaded. Budget VRAM is a consideration: the Swin-Large backbone can require several gigabytes in FP32, and the internal resize is fixed at 1024×1024, so 2048 HR weights do not provide a benefit here.
The BiRefNet_ModelLoader_Zho node facilitates loading pre-trained BiRefNet models and outputs a ready-to-use model instance. It handles file paths and ensures that the model is correctly loaded into memory, enabling seamless integration into workflows for image segmentation and related tasks. The birefnet_model parameter points to the model file, and the birefnetmodel output provides the loaded model. This setup supports batch processing and streamlined reuse across multiple runs.
For performance considerations, the package emphasizes separating model loading from image processing and notes that HR-capable paths may be better suited for very large inputs. A lightweight version uses swin_v1_tiny as the backbone, offering faster processing and smaller footprint, suitable for edge devices with limited computing power. The comprehensive guide also covers common pitfalls, such as ensuring correct model paths and compatibility with BiRefNet architecture.
Practical Usage
- Drag and drop the BiRefNet-ZHO node into your working environment, ensuring required models are downloaded to ./models/BiRefNet.
- After loading your image or video, connect this node to process and remove backgrounds seamlessly.
- Double-check the model path in the ./models/BiRefNet directory and experiment with the connection sequence of nodes for optimal results.
- Restart ComfyUI after loading models to ensure the UI recognizes new weights.
The loader’s design mirrors ZHO’s approach: separate loading from processing, cache the model, and allow many downstream runs to share it. The extension supports both image and video background removal, as well as mask output, making it a versatile tool for compositing and post-processing tasks.
Model Loading and Compatibility
The BirefNet loader lists all .pth files in models/BiRefNet and uses torch.load to read the state dict, adapting the weight format for the BiRefNet architecture included in the pack. The system highlights the importance of using compatible checkpoints and ensuring the Swin backbone is properly included through the vendored architecture. A typical workflow involves selecting birefnet-general.pth as the weight file, with the output wired directly into the BiRefNet node.
When encountering issues, verify that the model file is compatible with BiRefNet and not corrupted, and ensure the birefnet_model parameter references a valid file. The provided notes emphasize that the HR pathways may not yield benefits if a 1024×1024 internal resize is fixed, so users should align expectations with the available resolution limits.
As part of the broader BiRefNet ecosystem, ZhengPeng7/BiRefNet and related resources are cited with examples for loading in notebooks and local apps. For devices with limited computing power, a lighter Swin backbone version is suggested to improve speed and reduce resource usage, while larger models are available for higher fidelity requirements when hardware permits.
Additional Context and Practical Notes
BiRefNet is positioned as one of the best open-source, commercially usable background removal models. The release notes highlight a two-node design pattern-model loading and processing-across the BRIA RMBG packs, enabling fast batch processing. Users are encouraged to maintain a well-organized model repository, understanding that large HR weights may offer no benefit if internal resizing bottlenecks persist.
In practice, the extension is valuable for AI artists and professionals who require clean subject isolation for projects involving composites, overlays, or transparent assets. By combining the loader with the processing node, workflows can efficiently manage multiple files, reducing per-file load times and enabling rapid iteration across scenes and sequences.
