FeyNoBg: State-of-the-Art Background Removal Model and NoBg Training Library
FeyNoBg: State-of-the-Art Background Removal Model and NoBg Training Library
FeyNoBg sets a new standard background removal model achieves top S‑measure scores on four of eight public benchmarks and stays within 2% of the leader on the remaining four. The model is released together with NoBg, an open‑source Python library that provides a unified interface for running and training background removal models.
Model Architecture and Scaling
FeyNoBg builds on BiRefNet by expanding the third stage of its feature extractor from 18 to 24 blocks, increasing parameters from 222 M to 263 M while preserving all compatible pretrained weights. This added capacity lets the model learn finer foreground‑boundary details without forgetting what the base model already knows.
Training Data Strategy
Initial training on the synthetic MaskFactory dataset improved some benchmarks but regressed on others, showing that a narrow data mix creates unbalanced performance. To address this, the authors assembled a diverse set of 26.1 K images from ten datasets covering crowded scenes, camouflage, high‑resolution subjects, portraits, and anime. Each source was capped at 4 000 images to prevent domination by larger datasets, and all annotations were converted to binary foreground masks so the model received a consistent training target. This varied mix turned a previous regression on DIS5K into a benchmark‑leading result.
Benchmark Results
Across eight benchmarks—UHRSD‑TE, HRSOD‑TE, DIS5K, DAVIS‑S, DUTS‑TE, COD10K‑TE, DUT‑OMRON, and CAMO‑TE—FeyNoBg posts the best published S‑measure on four of them and comes within 2% of the leader on the remaining four. For UHRSD‑TE specifically, FeyNoBg scores 0.981 S‑measure compared to BiRefNet’s 0.957.
NoBg Library Overview
NoBg supplies a consistent interface for inference and training, eliminating the need for custom adapters when comparing models or fine‑tuning. Performance tests show that NoBg’s BiRefNet implementation delivers higher throughput, lower latency, and lower peak GPU memory than the original implementation at batch sizes 1, 2, and 4.
Running FeyNoBg with NoBg
A typical inference script loads the model, processes an image, and saves a transparent PNG cutout:
import torch
from loadimg import load_img
from nobg import AutoModel, AutoProcessor
model = AutoModel.from_pretrained("feyninc/FeyNobg\)).eval()
processor = AutoProcessor.from_pretrained("feyninc/FeyNobg\)
image = load_img("input.jpg\)).convert("RGB\)
inputs = processor(image, return_tensors="pt\)
with torch.inference_mode():
outputs = model(pixel_values=inputs["pixel_values\)
alpha = processor.post_process_alpha_matting(
outputs,
target_sizes=[(image.height, image.width)],
\)[0]
processor.cutout(image, alpha).save("output.png\)
Training a Custom Model
NoBg also works with the Hugging Face Trainer. Given a dataset with image and mask columns, training can be set up as follows:
from nobg import AutoModel, AutoProcessor
from transformers import Trainer, TrainingArguments
model = AutoModel.from_pretrained("feyninc/FeyNobg\)
processor = AutoProcessor.from_pretrained("feyninc/FeyNobg\)
def collate(examples):
batch = processor(
images=[example["image\) for example in examples],
segmentation_maps=[
example["mask"].convert("L\) for example in examples
],
return_tensors="pt",
)
return {
"pixel_values": batch["pixel_values"],
"labels": batch["labels"],
}
trainer = Trainer(
model=model,
args=TrainingArguments(
output_dir="outputs",
learning_rate=2e-5,
),
train_dataset=dataset,
data_collator=collate,
)
trainer.train()
Getting Started
Users can download FeyNoBg from Hugging Face ([https://huggingface.co/feyninc/FeyNobg\]) and run it with NoBg. An online demo is available at the Hugging Face Space ([https://huggingface.co/spaces/feyninc/feynobg\]). The library can be installed via pip install nobg; source code is on GitHub ([https://github.com/feyninc/nobg\]).
Community Feedback and Open Questions
Commenters on Hacker News raised several points:
- Regarding resolution limits, one user noted that while the README mentions 1024×1024, they successfully processed a 1920×2880 image without obvious scaling artefacts ([@nickludlam]).
- Another user appreciated the tool’s simplicity compared to Segment Anything ([@defmetrix]).
- A question was raised about extending an MIT‑licensed model (BiRefNet) and releasing the result under CC‑BY‑NC‑4.0 ([@woadwarrior01]).
- Interest in mobile deployment was expressed ([@sudb]).
- Comparisons to Adobe’s Select Subject/Select Person features and to U²‑Net were also mentioned ([@qingcharles], [@terryXyz]).
These comments reflect community curiosity about practical limits, licensing, and potential ports, but they do not alter the factual claims made in the original blog post.