Nodes/comfyui-timesaver/TS Remove Background
ComfyUI Node

TS Remove Background

Remove the background with BiRefNet and return the cutout together with its mask.

By AlexYez·Created 2 years ago·Updated 3 days ago· 11
TS Remove Background
  • image
  • background_color
  • IMAGE
  • MASK
  • MASK_IMAGE
enabletrue
modelBiRefNet-HR-matting
use_custom_resolutionfalse
process_resolution1024
mask_blur0
mask_offset0
invert_outputfalse
backgroundAlpha
precisionauto
temporal_smoothmedian3
ema_alpha0.50
CategoryTS/Image/Cutout

Inputs (13)

NameTypeDefaultDescription
imageIMAGEInput image to be processed for background removal.
enableBOOLEANtrueEnable or disable the background removal process. If disabled, the original image will be passed through.
modelCOMBOBiRefNet-HR-mattingSelect the BiRefNet model variant to use.
use_custom_resolutionoptBOOLEANfalseEnable to use a custom resolution specified below. If disabled, the model's default resolution will be used.
process_resolutionoptINT1024256–4096The resolution for processing the image. It will be adjusted to the nearest multiple of 64.
mask_bluroptINT00–64Specify the amount of blur to apply to the mask edges (0 for no blur, higher values for more blur).
mask_offsetoptINT0-20–20Adjust the mask boundary (positive values expand the mask, negative values shrink it).
invert_outputoptBOOLEANfalseEnable to invert both the image and mask output (useful for certain effects).
backgroundoptCOMBOAlphaChoose background type: Alpha (transparent) or Color (custom background color).
background_coloroptCOLOR#ffffffBackground color when 'background' is set to 'Color'. COLOR widget supports precise eyedropper picking.
precisionoptCOMBOautoInference precision on CUDA. 'auto' picks bf16 on Ampere+ (more numerically robust) and fp16 elsewhere. Force 'fp32' for diagnostics. CPU always runs fp32.
temporal_smoothoptCOMBOmedian3Smooth alpha across frames to reduce 'boiling' edges in video. 'median3' (default) kills random 1-frame flicker; 'median5' is stronger (2-frame lag at clip boundaries); 'ema_causal' is causal averaging (no lag, can blur fast motion); 'off' disables. No-op for single images. Adds ~N*H*W*4 bytes RAM during the pass.
ema_alphaoptFLOAT0.500–0.99Strength of the causal EMA when temporal_smooth = 'ema_causal'. Higher = more smoothing (more lag for moving objects); lower = closer to the raw per-frame alpha.

Outputs (3)

NameTypeDescription
IMAGEIMAGE
MASKMASK
MASK_IMAGEIMAGE