BG Remove Mega v5.1.0
Local model or PhotoRoom API
- image
- IMAGE
- MASK
tri3d-bgremove-mega is the pack's Swiss-army background removal: one node, two backends, chosen at runtime by a text input. Leave it alone and you get the local transparent-background (InSPyReNet) cutout with a separate mask output. Set the method to photoroom and set a PhotoRoom API key, and the same node starts shipping images to PhotoRoom's commercial segmentation API instead. Handy if you're prototyping locally and want a paid-quality fallback without rewiring your graph.
What it does
Two inputs: image (an IMAGE batch) and method, a string that must be either transparent_background (the default) or photoroom.
transparent_backgroundpath - same astri3d-main_transparent_background: the local InSPyReNet model via thetransparent-backgroundCLI, RGB cutout plus alpha-derived MASK output. First run downloads the model into ComfyUI's models folder.photoroompath - the node readsPHOTOROOM_API_KEYfrom a.envfile in the working directory and posts each image to PhotoRoom's/v1/segmentendpoint, then reads back the RGBA result and splits image/mask. This needs an internet connection and a paid PhotoRoom key; without the key, the node silently falls back to the local model.
Both paths return the same pair: IMAGE (RGB cutout) and MASK (alpha channel). Batches work on both paths - PhotoRoom calls are per-image, so a long batch is a series of API round-trips and a per-call cost.
When the API path is worth it
PhotoRoom's segmentation is noticeably better on difficult edges - hair, jewelry, transparent fabrics - than base InSPyReNet. For one-off hero cutouts where the local model fumbles, it's a nice escape hatch. For anything at volume, do the math: per-call cost plus latency, versus just installing a BiRefNet node locally and getting comparable quality for free. My take: keep the local path as your default and use PhotoRoom for the stubborn handful.
Installing
ComfyUI Manager (search "tri3d"), or:
cd ComfyUI/custom_nodes
git clone https://github.com/TRI3D-LC/tri3d-comfyui-nodes
Install requirements (pip install -r custom_nodes/tri3d-comfyui-nodes/requirements.txt) - transparent-background is needed for the local path, python-dotenv for key loading. For the API path, put PHOTOROOM_API_KEY=... in a .env file where ComfyUI runs.
Troubleshooting
- API path silently uses the local model - no
PHOTOROOM_API_KEYin.env. That's by design, but it can make you think you're testing PhotoRoom when you're not. Check the console for "Using PhotoRoom API". command not foundon the local path - thetransparent-backgroundCLI isn't on PATH for ComfyUI's Python. Reinstall it into the right environment.- API errors - invalid key, exceeded quota, or network. The node prints the HTTP status; 401 means the key, 429 means budget.
Two backends, one interface, a clear default. For a pack that's mostly about local pipelines, the API escape hatch is more useful than it looks - until you hit the per-call pricing.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| method | STRING | transparent_background | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |