Nodes/ComfyUI_DiffuEraser/DiffuEraser_PreData
ComfyUI Node

DiffuEraser_PreData

Turns your frames into the conditioning bundle — and can even build the mask for you

By smthemex·Created 2 years ago·Updated 5 months ago· 279
DiffuEraser_PreData
  • images
  • video_mask_image
  • video_mask
  • conditioning
seg_repobriaai/RMBG-2.0

Every inpainting graph needs two things before anything is erased: the frames themselves and a mask saying what to erase. DiffuEraser_PreData is the node that packages both into the conditioning bundle the rest of the pack consumes - and if you don't have a mask handy, it'll quietly generate one for you with a background-removal model. It's the first node in the DiffuEraser half of the graph, and the only one that takes raw video frames as input.

Inputs:

  • images - a batch of frames, usually from VHS Load Video (load the clip as "AnimateDiff" format) or any node that outputs an IMAGE sequence.
  • seg_repo - a string, default briaai/RMBG-2.0. This is the HuggingFace repo used for automatic mask generation when you don't supply one. Swap it for ZhengPeng7/BiRefNet if you want sharper edges - BiRefNet is the background-removal crowd's current favorite and handles hair and fuzzy boundaries far better than the older RMBG cutouts. It auto-downloads to your HF cache on first run.
  • video_mask_image / video_mask - optional. If you already have a mask sequence (say, a tracking or segmentation node, or an mp4 of masks), you can bypass auto-segmentation entirely. Give a single mask and it replicates it across every frame; give too many or too few and it truncates or wraps to match. This is the route the README recommends for watermarks, where you'd rather paint the mask once than trust segmentation.

How it works: the node rounds the frame dimensions down to a multiple of 8 (the UNet's downsampling factor), converts the tensor to PIL images, and then picks a mask source in priority order - your video_mask, else your video_mask_image, else the segmentation model named in seg_repo. That last path runs AutoModelForImageSegmentation frame-by-frame with trust_remote_code, so it depends on the transformers library being installed and working. If you give it none of the three, it raises a clear error telling you to either set seg_repo or wire in a mask - the node was written to fail loudly rather than guess.

Output: a single conditioning output. Despite the CONDITIONING label it's not a text-conditioning bundle - it's a Python dict carrying the frames, the masks, and the dimensions, passed between the pack's own nodes. It feeds Propainter_Sampler first (which adds a rough fill), and then the refined bundle flows into DiffuEraser_Sampler.

Gotchas worth knowing before you build: the default seg_repo is a background-removal model, which masks the subject - great for swapping out a person or object, wrong if you want to remove a watermark or caption, because the model won't treat text as foreground. For that, either feed your own video_mask or pick a segmentation repo that matches the target. And remember this is per-frame segmentation with no temporal consistency, so auto-generated masks can wobble on fast motion - the pack's own ProPainter pass does a lot of smoothing work, but a hand-painted mask over the first frame is often the more reliable start.

CategoryDiffuEraser

Inputs (4)

NameTypeDefaultDescription
imagesIMAGE
seg_repoSTRINGbriaai/RMBG-2.0
video_mask_imageoptIMAGE
video_maskoptMASK

Outputs (1)

NameTypeDescription
conditioningCONDITIONING