theLLMs

Last checked: 2026-07-28

Scope: Global. Sources checked as of 2026-07-28.

Hero image for Show HN: FeyNoBg — automatic background removal model and training library

Show HN: FeyNoBg — automatic background removal model and training library

TL;DR

Feyn Labs has open-sourced FeyNoBg, a background removal model built on BiRefNet, and NoBg, the companion training library. The model expands BiRefNet’s third Swin Transformer stage from 18 to 24 blocks, growing parameters from 222M to 263M while preserving all pretrained weights. Across eight benchmarks, FeyNoBg achieves the best published S-measure on four and is within 2% on the remaining four. Both are released under open-source licenses — the model on HuggingFace Hub, the library (Apache-2.0) on GitHub.

Background removal: the hidden bottleneck

Automatic background removal and image matting produce an opacity map — a per-pixel prediction of whether each pixel belongs to the foreground subject or the background, with translucent boundaries for hair, fur, thin wires, and motion blur. The task requires two distinct capabilities. Foreground recognition must separate the subject from complex, low-contrast, or camouflaged backgrounds using shape and context rather than simple color thresholds. Boundary reconstruction (image matting) must measure how much of a boundary pixel belongs to the subject — a harder problem when foreground and background blend.

Most practitioners solve this with closed APIs like Remove.bg or Cloudinary, or with fragmented open-source repositories that require custom adapters to switch between models. The gap between these approaches is friction: every new model needs its own inference script, preprocessing pipeline, and post-processing logic. This is where FeyNoBg and its companion library NoBg aim to intervene.

Architecture: growing what matters

FeyNoBg uses BiRefNet as its foundation. BiRefNet’s architecture divides the model into two complementary modules: a localization module that finds the foreground subject, and a reconstruction module that traces the subject’s boundary. Both depend on the feature maps produced by a four-stage feature extractor.

The third stage is the bottleneck. It sees enough of the image to reason about the whole subject while retaining the spatial detail needed to represent its shape. Feyn Labs expanded this stage from 18 to 24 Swin Transformer blocks, growing the model from 222M to 263M parameters. All compatible pretrained weights were preserved — only the six new blocks started untrained, giving the model additional capacity without forgetting what the base model already knows.

This is a modest change with asymmetric returns: the third stage is where the model’s attention converges on subject-level understanding, and adding depth there directly improves both localization and boundary reconstruction simultaneously.

Training data: diversity over precision

The training approach is deliberately broad. Feyn Labs assembled 26,110 images across ten datasets — S3OD, MaskFactory, DIS5K, DUTS, COD10K, UHRSD, P3M-10K, HRSOD, CAMO, and Anime — each capped at 4,000 samples. All annotations were converted to binary foreground masks, providing a consistent training signal across segmentation and matting sources.

The original training run used only MaskFactory (synthetic image-and-mask pairs). The resulting model improved on some benchmarks (CAMO) but regressed on others (DIS5K). The final training mix addressed this by deliberately exposing the model to a wider range of scenarios — crowded scenes, camouflage, high-resolution subjects, portraits, and anime.

The matting datasets contributed precisely outlined subjects rather than soft-opacity supervision, since all annotations were converted to binary masks. This means the model learns sharp foreground/background separation across diverse content, but does not receive direct alpha-matte supervision for fine boundary details like hair strands.

Benchmark results

Feyn Labs measured S-measure (a 0-to-1 score comparing predicted foreground with the correct mask, rewarding both complete subjects and faithful shapes) across eight benchmarks:

  • UHRSD-TE: +2.5% over BiRefNet
  • HRSOD-TE: +2.3%
  • DIS5K: +1.1%
  • DAVIS-S: +0.2%
  • DUTS-TE: −0.8%
  • COD10K-TE: −1.2%
  • DUT-OMRON: −1.7%
  • CAMO-TE: −1.9%

FeyNoBg leads on four benchmarks and is within 2% of the leader on the remaining four. Notably, the broader training mix reversed a prior DIS5K regression into a benchmark-leading result.

The NoBg library

NoBg is a Python library released under Apache-2.0 that provides a consistent interface for running and training background removal models. It offers AutoModel and AutoProcessor conveniences (mirroring HuggingFace’s auto-loading pattern), batched inference with lower latency and peak GPU memory than the original BiRefNet implementation, and a Trainer-based fine-tuning pipeline using the HuggingFace transformers Trainer API.

Installable via uv add nobg or pip, the library lets you run FeyNoBg or train your own model on custom image-and-mask pairs. The API is designed so that swapping the pretrained checkpoint for a fine-tuned one requires no code changes beyond the model path.

Methodology

  • Data checked: 2026-07-28
  • Sources consulted: Feyn Labs blog post (FeyNoBg announcement), GitHub repository (feyninc/nobg), Hacker News discussion
  • Assumptions: Benchmark results reported by Feyn Labs are taken at face value; independent reproduction would strengthen claims. Model parameter counts and benchmark deltas are as published.
  • Limitations: This article covers FeyNoBg as announced by Feyn Labs. It does not include independent benchmarking, comparison to closed APIs, or performance measurements on specific hardware configurations.
  • Jurisdiction: Global

Source list

Trust Stack

  • Last substantive check: 2026-07-28
  • Corrections policy: Contact via Contact page
  • Affiliation: theLLMs has no vendor affiliation or sponsorship

Change log

  • 2026-07-28: first published