Nodes/tri3d-comfyui-nodes/BG Remove Mega v5.1.0
ComfyUI Node

BG Remove Mega v5.1.0

Local model or PhotoRoom API

By TRI3D-LC·Created 3 years ago·Updated about a year ago· 27
BG Remove Mega v5.1.0
  • image
  • IMAGE
  • MASK
methodtransparent_background

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_background path - same as tri3d-main_transparent_background: the local InSPyReNet model via the transparent-background CLI, RGB cutout plus alpha-derived MASK output. First run downloads the model into ComfyUI's models folder.
  • photoroom path - the node reads PHOTOROOM_API_KEY from a .env file in the working directory and posts each image to PhotoRoom's /v1/segment endpoint, 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_KEY in .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 found on the local path - the transparent-background CLI 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.

CategoryTRI3D

Inputs (2)

NameTypeDefaultDescription
imageIMAGE
methodSTRINGtransparent_background

Outputs (2)

NameTypeDescription
IMAGEIMAGE
MASKMASK