Show HN: FeyNoBg – Automatic background removal model and training library

Hacker News Top Models

Summary

FeyNoBg is a state-of-the-art automatic background removal model that achieves top scores on four of eight benchmarks and comes within 2% of the leader on the rest. The accompanying NoBg library is open-source for running or training custom models.

Hey HN, I’m Shreyash from Feyn. We help companies build custom models from their data.<p>Today, we’re releasing FeyNoBg, an automatic background removal model. Alongside it, we&#x27;re open-sourcing NoBg, the Python library we built to train and run it.<p>Try the model here: <a href="https:&#x2F;&#x2F;huggingface.co&#x2F;spaces&#x2F;feyninc&#x2F;feynobg" rel="nofollow">https:&#x2F;&#x2F;huggingface.co&#x2F;spaces&#x2F;feyninc&#x2F;feynobg</a>. Check out the library here: <a href="https:&#x2F;&#x2F;github.com&#x2F;feyninc&#x2F;nobg" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;feyninc&#x2F;nobg</a><p>Some sample outputs:<p>(1) Soccer Freekick: <a href="https:&#x2F;&#x2F;drive.google.com&#x2F;file&#x2F;d&#x2F;1MZkAGLwbhNVOZ0Oi7XvpCfSEu9QPCbwj&#x2F;view?usp=sharing" rel="nofollow">https:&#x2F;&#x2F;drive.google.com&#x2F;file&#x2F;d&#x2F;1MZkAGLwbhNVOZ0Oi7XvpCfSEu9Q...</a><p>(2) Hair in wind: <a href="https:&#x2F;&#x2F;drive.google.com&#x2F;file&#x2F;d&#x2F;1Odc2m0XMVH9uZtvI_KjaRbXzhLLdGK8Z&#x2F;view?usp=sharing" rel="nofollow">https:&#x2F;&#x2F;drive.google.com&#x2F;file&#x2F;d&#x2F;1Odc2m0XMVH9uZtvI_KjaRbXzhLL...</a><p>(3) Bicycle with visible spokes: <a href="https:&#x2F;&#x2F;drive.google.com&#x2F;file&#x2F;d&#x2F;1h99ahjfrtS1MFQJJgiKE2fuM3HZyQ-QJ&#x2F;view?usp=sharing" rel="nofollow">https:&#x2F;&#x2F;drive.google.com&#x2F;file&#x2F;d&#x2F;1h99ahjfrtS1MFQJJgiKE2fuM3HZ...</a><p>(4) Live Demo video: <a href="https:&#x2F;&#x2F;youtu.be&#x2F;b1heHPvY8BM" rel="nofollow">https:&#x2F;&#x2F;youtu.be&#x2F;b1heHPvY8BM</a><p>Background removal separates an image&#x27;s subject from its surrounding. We&#x27;ve all tried it at some point. Often it is to reuse the subject in a different artifact. Nowadays, it is common to make chat stickers out of it. It is one of the most common but under-appreciated uses of AI. It is also surprisingly complex. Models can be easily confused by camouflage, motion blur, or fine structures like hair.<p>The task requires two skills. First, a model has to identify the foreground. Second, it has to trace the foreground’s boundary and estimate an opacity value for each pixel. Generally, these skills are taught with different datasets. That creates a failure point. A poor training mix can improve one skill at the expense of the other. We saw this in our controlled evaluation. A training run with just the MaskFactory dataset improved on the CAMO benchmark but regressed on DIS5K.<p>For FeyNoBg, we took an interpretability-first approach to training. We first studied how BiRefNet’s stages contribute to finding the foreground and reconstructing its boundary. We discovered that the third stage of it&#x27;s feature extractor holds a lot of information. Both localization and boundary reconstruction depend heavily on the feature map produced here.<p>This led us to expand this stage from 18 to 24 blocks while preserving the pre-trained weights. We then trained FeyNoBg on 26.1K diverse examples assembled from 10 datasets. The goal was to improve foreground identification and boundary precision without sacrificing either one.<p>Across eight benchmarks, FeyNoBg achieves the best published score on four and comes within 2% of the leader on the rest.<p>Building FeyNoBg also exposed a tooling problem. Image matting models are usually released as isolated repositories with incompatible preprocessing, training, and evaluation code. We built NoBg to solve this. NoBg puts these workflows behind one Python interface. It supports BiRefNet today, with more architectures coming. We hope you build something exciting with it!<p>Happy to answer any questions!
Original Article
View Cached Full Text

Cached at: 07/27/26, 07:46 PM

# FeyNoBg: A SOTA Model For Background Removal — Feyn Source: [https://usefeyn.com/blog/feynobg/](https://usefeyn.com/blog/feynobg/) ![Three rental bicycles parked on a busy city sidewalk](https://usefeyn.com/blog/feynobg/showcase/bikes-original.webp) OriginalBackground removed We’re introducing FeyNoBg, a state\-of\-the\-art model for automatic background removal\.**Across eight benchmarks, it posts the best published S\-measure on four and comes within 2% of the leader on the rest\.** Benchmark**UHRSD\-TE** FeyNoBg**0\.981** BiRefNet**0\.957** Description Tests salient\-object masks in ultra\-high\-resolution images, including 4K and 8K scenes\. We’re also releasing NoBg, the library we used to train our model\. Use NoBg to run FeyNoBg or train your own background removal model\. Both are open source\. Download[FeyNoBg on Hugging Face](https://huggingface.co/feyninc/FeyNobg), or build with[NoBg on GitHub](https://github.com/feyninc/nobg)\. ## Removal Requires Combination In your computer, images are stored as grids of pixels\. The goal of a background removal algorithm is to predict an opacity value for each pixel such that background pixels become transparent, foreground pixels remain opaque, and boundary pixels become translucent\. Producing this opacity map requires two skills\. First, the model has to separate the foreground from the background\. When the subject stands against a plain backdrop, this can be done easily by comparing colors\. However, in low contrast, crowded, or camouflaged images, the model has to use shape, texture, and context to recognize which pixels form the subject\. Second, the model has to trace the foreground’s boundary\. In simple images, a sharp change in color or texture provides a strong edge signal\. But real boundaries are more difficult\. Hair, fur, thin wires, and motion blur can blend foreground and background elements together\. The model has to measure how much of an edge pixel belongs to the subject and set its opacity accordingly\. This is called image matting\. Generally, these skills are taught with different kinds of focused data\. This creates a failure point\. A poor training mix can produce unbalanced models where improvements in one skill come at the expense of the other\. Outputs either miss parts of the subject or lack clean edges\. Real images are complex and require deftness in foreground recognition and boundary precision\. This was our key insight when training FeyNoBg\. ## Creating Room To Learn We chose BiRefNet as the foundation for FeyNoBg, as its architecture already matched our goal\. BiRefNet gives two parts of the model complementary responsibilities\. Its localization module finds the foreground, while its reconstruction module traces the subject’s boundary\. The model starts by passing the input image through a feature extractor that runs in four stages\. Early stages capture local details\. Later stages combine the gathered details into broader image representations called feature maps\. The localization module uses these maps to find the subject, while the reconstruction module uses them to recover its boundary\. The third stage of the feature extractor has the hardest job\. It sees enough of the image to reason about the whole subject while retaining the spatial detail needed to represent its shape\. Both localization and boundary reconstruction depend heavily on the feature map produced here\. Given the rich image representation this stage holds, we expected that adding more depth here would help the model retain information better and thus improve performance\. Accordingly, we expanded the third stage from 18 to 24 blocks\. This grew the model modestly from 222M parameters to 263M\. Origin**BiRefNet**222M parameters `depths=\[2, 2, 18, 2\]` Grown model**FeyNoBg**263M parameters `depths=\[2, 2, 24, 2\]` We preserved every compatible pre\-trained weight during the expansion\. Only the six new blocks started untrained\. This gave FeyNoBg additional capacity to learn new skills without forgetting what the base model already knows\. With room to learn more, it was time to teach an old model some new tricks\. ## Strength in Diverse Data Our first training run was with MaskFactory, a collection of synthetic image and mask pairs created for precise foreground segmentation\. This was the only dataset used for the run\. If our intuition was correct, the resulting model would improve on some benchmarks while regressing on others\. That is what happened in our controlled evaluation, where the model improved on the CAMO benchmark but regressed on DIS5K\. Next, we focused on building a more diverse dataset\. We assembled 26\.1K images from 10 datasets covering crowded scenes, camouflage, high resolution subjects, portraits, and anime, then trained for 7,000 steps\. Our goal was to expose the model to as many scenarios as possible during training\. Dataset**S3OD** What it added Synthetic scenes designed to help models generalize beyond familiar image collections\. We revised our original mix before the final run\. We added 4,000 images from S3OD, reduced Anime to 500 images, and removed ThinObject\-5K, HIM\-2K, and COIFT\. This left us with the sources that contributed the most useful, consistent training examples\. Combining the datasets introduced two problems\. First, they varied greatly in size\. Without limits, the largest sources would dominate training and cause the same specialization we saw before\. Consequently, we capped each source to 4,000 images and then shuffled them together\. Second, the datasets used different annotations\. Segmentation datasets provided foreground masks, while matting datasets provided alpha mattes\. We converted both into binary foreground masks so every image shared the same training target\. The matting datasets therefore contributed precisely outlined subjects, not soft\-opacity supervision\. This gave us one consistent training set with deliberately varied images\. Our model could now learn to identify and outline foregrounds across a much wider range of scenarios\. ## Results To understand performance, we recorded S\-measure\. Scored from 0 to 1, S\-measure compares the predicted foreground with the correct mask\. It rewards both complete subjects and faithful shapes\. A higher score is better\. We compared FeyNoBg’s S\-Measure to the best published result on eight benchmarks covering camouflage, low contrast scenes, fine structures, high resolution images, and video\. FeyNoBg led on four and was within 2% of the leader on the remaining four\. **UHRSD\-TE** **HRSOD\-TE** **DIS5K** **DAVIS\-S** **DUTS\-TE** **COD10K\-TE** **DUT\-OMRON** **CAMO\-TE** Notably, the broader training mix turned our DIS5K regression into a benchmark\-leading result\. ## The NoBg Library Image matting models are usually released as isolated repositories\. Comparing models or fine\-tuning one requires writing several adapters before any experiments can begin\. This setup can quickly become too messy and frustrating to do good work in\. To solve this, we created NoBg\. It is a Python library that provides a consistent interface to run and train background removal models\. We used it ourselves to train FeyNoBg\. To encourage more development in this field, we are releasing NoBg in the open source\. You can use it to run FeyNoBg, or train your own model\. ### Performant and Convenient A consistent interface should not cost performance\. We compared NoBg’s BiRefNet with the original implementation at batch sizes 1, 2, and 4\. NoBg delivered higher throughput, lower latency, and lower peak GPU memory at every size\. ### Run FeyNoBg NoBg resizes and normalizes the image before inference\. It then converts the model output into an alpha matte at the original size and saves the cutout as a transparent PNG\. ``` 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") ``` ### Train Your Own Model NoBg provides the model, processor, and loss needed to train BiRefNet on your own image and mask pairs\. It also works with the Hugging Face`Trainer`, which handles the training loop, checkpointing, and evaluation\. Given a dataset with`image`and`mask`columns, training looks like this: ``` 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() ``` ## Get Started Download[FeyNoBg from Hugging Face](https://huggingface.co/feyninc/FeyNobg)and run the model with NoBg\. Try it online in our[Hugging Face Space](https://huggingface.co/spaces/feyninc/feynobg)\. Install NoBg with`pip install nobg`\. You can also find it on[GitHub](https://github.com/feyninc/nobg)\. FeyNoBg and NoBg are built by Feyn\. Find us on[X](https://usefeyn.com/blog/feynobg/x.com/feynai),[GitHub](https://github.com/feyninc), or[LinkedIn](https://www.linkedin.com/company/107081181/)\. ## Acknowledgements FeyNoBg builds on BiRefNet and the work of Peng Zheng, Dehong Gao, Deng\-Ping Fan, Li Liu, Jorma Laaksonen, Wanli Ouyang, and Nicu Sebe\. We also thank the teams that released the models, code, and datasets used here\. References \[1\]Zheng et al\. "Bilateral Reference for High\-Resolution Dichotomous Image Segmentation\."*CAAI Artificial Intelligence Research*3 \(2024\)\.*arXiv:2401\.03407*\. \[2\]Sargsyan and Navasardyan\. "FlowDIS: Language\-Guided Dichotomous Image Segmentation with Flow Matching\."*CVPR*2026\.*arXiv:2605\.05077*\. \[3\]Kupyn, Kataoka, and Rupprecht\. "S3OD: Towards Generalizable Salient Object Detection with Synthetic Data\."*arXiv:2510\.21605*\(2025\)\. Cite this note ``` @note{feynobg2026, title = {FeyNoBg: Better Background Removal Without Forgetting}, author = {Hichri, Hafedh and Nigam, Shreyash and Feyn Research}, year = {2026}, venue = {Feyn Field Notes} } ```

Similar Articles

fottoai/remove-bg-2

Replicate Explore

fottoai/remove-bg-2 is an open-source background removal model available on Replicate, running on A100 GPUs with ~2s inference time and $0.0018 per run.

851-labs/background-remover

Replicate Explore

851-labs/background-remover is an open-source AI model for removing backgrounds from images, available on Replicate with low cost and fast inference on Nvidia T4 GPUs.

lucataco/remove-bg

Replicate Explore

An AI model for removing image backgrounds, using the tracer_b7 neural network, available on Replicate with open-source code.

Training Video Foundation Models with NVIDIA NeMo

Papers with Code Trending

This paper presents a scalable open-source pipeline using NVIDIA NeMo for training and inference of Video Foundation Models, addressing challenges in generating high-quality videos with accelerated dataset curation and parallelized training.