Nodes/ComfyUI-FeyNobg/Apply FeyNobg
ComfyUI Node

Apply FeyNobg

Getting Clean Hair and Fur with Apply FeyNobg

By idealisticABO·Created 2 months ago·Updated 2 months ago· 9
Apply FeyNobg
  • model
  • image
  • foreground_rgb
  • alpha_mask
  • rgba_image
  • model_info
alpha_modesoft
threshold0.50
preserve_original_sizetrue
invert_maskfalse
premultiply_rgbfalse
horizontal_flip_ttafalse
remove_small_regionsfalse
minimum_region_area64
fill_small_holesfalse
mask_expand0
edge_feather0
clamp_alphatrue

Apply FeyNobg is the node that does the actual work in this pack: it takes a loaded FeyNobg model and an image, and hands you back the subject cut out of its background. FeyNobg is a retrained, upsized BiRefNet - 24 blocks and ~263M params against standard BiRefNet's 18 - and it exists for the cases where the cheap rembg-style cutout goes wrong: flyaway hair, fur, fabric mesh, thin stems. If you've been fighting u2net edges, this is the family of model the ecosystem moved to, and this node is the friendly face of it inside ComfyUI.

How it works

The pipeline is the standard BiRefNet one with some polish bolted on. Your image gets resized to the model's native 1024×1024 (the size comes from the checkpoint's own preprocessor_config.json), run through the network, and the raw logits get a sigmoid. If preserve_original_size is on - it is by default - the resulting alpha is bilinearly upscaled back to your original width and height. Then everything downstream is about what you want that alpha to look like.

The one knob worth understanding before any other is alpha_mode. Soft keeps the continuous probability values, which is what you want for hair and semi-transparency: each pixel gets a fractional alpha. Binary thresholds the mask into hard 0/1, which is right when you're feeding a matte into something that wants a strict selection and don't care about soft edges. threshold (default 0.5) only matters in binary mode - it's where the cut lands.

The inputs that matter

  • alpha_mode (soft/binary) and threshold - covered above; the soft-vs-hard decision is the first thing to make.
  • preserve_original_size - keep this on unless you specifically want a 1024-wide alpha out.
  • invert_mask - flips alpha to 1 - alpha, i.e. "keep the background, drop the subject." Handy for replacing the backdrop rather than the subject.
  • premultiply_rgb - premultiplies the foreground RGB by alpha. Reach for it when you're compositing onto a dark or transparent background and getting fringing.

Then there's a whole shelf of enhancement toggles, all off by default, and this is where the pack earns its keep: horizontal_flip_tta (runs the image mirrored a second time and averages the alpha - nicer asymmetric edges, roughly doubles runtime), remove_small_regions + minimum_region_area (default 64 px, kills specks), fill_small_holes (closes gaps in the mask), mask_expand (−64 to +64 px, positive grows the mask, negative shaves a halo), and edge_feather (0–64 px of Gaussian softening). A sensible cleanup chain for a portrait is TTA + remove small regions + a couple px of mask shrink. clamp_alpha (default on) just pins alpha to [0,1]; leave it.

What comes out

Four outputs. foreground_rgb (IMAGE) is the subject on a black background - wire it into Save Image for a quick preview. alpha_mask (MASK, shaped [B,H,W]) is the selection itself; this is the one you feed into compositing nodes or save as a mask. rgba_image (IMAGE) is the RGBA composite - save it as a PNG and you get actual transparency, which is the whole point. model_info (STRING) just passes through the loader's metadata text if you want it logged or previewed.

Install

Via ComfyUI Manager, search "FeyNobg". Or the manual route:

cd ComfyUI/custom_nodes
git clone https://github.com/idealisticABO/FeyNobg_comfyui
cd FeyNobg_comfyui
pip install -r requirements.txt

Then restart ComfyUI. The ~1GB model downloads automatically on first run into ComfyUI/models/feynobg/ - you don't fetch weights by hand.

Gotchas

Feeding it a 4K image won't give you 4K edges: the model computes alpha at 1024 native and upscales, so very large inputs come back softer than a native-2048 model like BiRefNet_HR would give. If your input is above ~1500px and hair quality is the goal, that's the trade-off to know about. The node catches CUDA out-of-memory, clears the cache and retries once - if you still OOM, switch the loader to fp16/bf16 and set keep_model_loaded off. And if you ever see near-black garbage masks, that's the classic silent-random-weights failure this pack specifically guards against with a weight-coverage check in the loader; update the pack if your copy predates version 1.0.1. Both nodes are Apache-2.0, FeyNobg included - no licence surprise for commercial work.

CategoryFeyNobg

Inputs (14)

NameTypeDefaultDescription
modelFEYNOBG_MODEL
imageIMAGE
alpha_modeCOMBOsoft2 options: soft, binary
thresholdFLOAT0.500–1
preserve_original_sizeBOOLEANtrue
invert_maskBOOLEANfalse
premultiply_rgbBOOLEANfalse
horizontal_flip_ttaoptBOOLEANfalse
remove_small_regionsoptBOOLEANfalse
minimum_region_areaoptINT640–100000
fill_small_holesoptBOOLEANfalse
mask_expandoptINT0-64–64
edge_featheroptINT00–64
clamp_alphaoptBOOLEANtrue

Outputs (4)

NameTypeDescription
foreground_rgbIMAGE
alpha_maskMASK
rgba_imageIMAGE
model_infoSTRING