Türkiyeegeorcun/lucida
Background removal that keeps what matters: glass, camouflage, text, glow and line art. BiRefNet fine-tune, MIT.
Featured achievements
The project's latest awards
#1 Repository of the week
#1 Repository of the week
#2 Repository of the week
Lucida
Background removal that keeps what matters: glass, camouflage, text, glow, line art and print designs.
Lucida is a BiRefNet-based image matting model fine-tuned specifically for the cases where general-purpose background removers fall apart: semi-transparent objects, camouflaged subjects, logos and typography with soft shadows, glow/VFX effects, illustrations, and print-style designs (stickers, tees). Weights are on Hugging Face: egeorcun/lucida (MIT). Try it in your browser (ZeroGPU, a few seconds per image): live demo.
Benchmark
203 images, 9 categories, MAE against ground-truth alpha (lower is better). Row leaders in bold. Full methodology in docs/benchmark.md; raw table snapshot in docs/benchmark-results.md.
| category (n) | lucida-v7 | inspyrenet | ideogram* | rmbg-2.0 | birefnet-hr |
|---|---|---|---|---|---|
| camouflage (25) | 0.0270 | 0.0582 | 0.1179 | 0.1405 | 0.0752 |
| transparent (25) | 0.0358 | 0.0725 | 0.0343 | 0.0741 | 0.0687 |
| complex (29) | 0.0484 | 0.0110 | 0.1046 | 0.0241 | 0.0385 |
| thin (36) | 0.0322 | 0.0166 | 0.0521 | 0.0180 | 0.0196 |
| hair (40) | 0.0093 | 0.0069 | 0.0112 | 0.0045 | 0.0048 |
| text (12) | 0.0091 | 0.0181 | 0.0123 | 0.0173 | 0.0207 |
| fx (12)** | 0.0180 | 0.0269 | 0.0165 | 0.0268 | 0.0272 |
| illustration (12) | 0.0092 | 0.0242 | 0.0215 | 0.0125 | 0.0157 |
| design (12)*** | 0.0235 | 0.0587 | 0.0518 | 0.0478 | 0.0544 |
| OVERALL (203) | 0.0257 | 0.0295 | 0.0507 | 0.0401 | 0.0346 |
* ideogram = fal.ai Ideogram remove-background, a commercial API used as the quality reference.
** The fx test images and their ground truth come from the earlier (v4-era) synthetic generator; the fx recipe was reworked for v5 training, so this row is a conservative estimate for lucida-v5+.
*** Synthetic print-design/sticker images (scripts/make_design.py), generated with seed 777 — a holdout fully disjoint from the seed-42 training data.
What Lucida wins, honestly:
- Overall: the lowest average error of every model measured — 0.0257 vs InSPyReNet 0.0295 — the first Lucida release to lead the whole table, specialists and commercial reference included.
- Print design: 0.0235, more than 2x better than every competitor (best open RMBG-2.0 0.0478, commercial Ideogram 0.0518). This category exists because a Reddit user reported the failure (issue #2) — community feedback, fixed in v7.
- Camouflage: more than 2x better than the best open competitor (0.0270 vs InSPyReNet 0.0582) and 4.4x better than the commercial reference.
- Text/logos: clearly ahead of the commercial reference (0.0091 vs 0.0123) and of all open models.
- Illustration: ahead of every model measured, including the commercial reference (0.0092 vs RMBG-2.0 0.0125, Ideogram 0.0215).
- Transparency: best of the open models by a wide margin (0.0358 vs the next-best open 0.0687).
And what it loses, just as honestly:
- Ideogram still leads transparency (0.0343 vs our 0.0358). The gap is down to 0.0015; not zero.
- InSPyReNet is the specialist for complex scenes and thin structures (0.0110 / 0.0166 vs our 0.0484 / 0.0322). Complex improved 28% over v6, but the gap stands.
- RMBG-2.0 leads hair (0.0045 vs our 0.0093), though absolute errors there are small for everyone.
- Ideogram edges out fx (0.0165 vs our 0.0180).
If your workload is mostly multi-object product shots or wiry/perforated structures, InSPyReNet or RMBG-2.0 may serve you better. For everything else — transparency, camouflage, typography, glow effects, illustrations, print designs — and on the overall average, Lucida is the strongest option we measured.
Examples
Original | Lucida v7 (RGBA on a dark checkerboard) | competitor. MAE per image shown in the labels.
Camouflage — body paint blended into magnolia petals; Lucida finds the subject, the runner-up keeps the whole image:

Transparency — glass demijohns; the interior stays semi-transparent instead of turning into an opaque blob:

Text / logo — lettering with a soft drop shadow over a noisy background; the shadow survives as partial alpha:

Illustration — anime rider having a meal; clean line-art edges where general-purpose models blur or halo:

Print design — smoke edges and distressed display text; the category born from a community bug report:

Model
Weights: huggingface.co/egeorcun/lucida — BiRefNet
architecture, loadable with transformers:
import torch
from PIL import Image
from torchvision import transforms
from transformers import AutoModelForImageSegmentation
model = AutoModelForImageSegmentation.from_pretrained("egeorcun/lucida", trust_remote_code=True)
model.eval()
# 1024x1024 input is the recommended (and trained) resolution.
preprocess = transforms.Compose([
transforms.Resize((1024, 1024)),
transforms.ToTensor(),
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
])
image = Image.open("input.jpg").convert("RGB")
with torch.no_grad():
alpha = model(preprocess(image).unsqueeze(0))[-1].sigmoid().cpu()[0, 0]
alpha_img = transforms.ToPILImage()(alpha).resize(image.size)
rgba = image.copy()
rgba.putalpha(alpha_img)
rgba.save("output.png")
Install & usage
Requires Python >= 3.12. With uv:
git clone https://github.com/egeorcun/lucida
cd lucida
uv sync
(Plain pip works too: pip install -e .)
CLI
uv run bgr remove input.jpg -o output.png --model lucida-v7
--modelpicks any entry frombgr/registry.py(lucida-v7,rmbg-2.0(default),birefnet-hr,inspyrenet, ...). Thelucida-v7entry loads a local checkpoint fromdata/checkpoints/epoch_7.pth— download it from the Hugging Face repo and place it there.--refineenables the edge-refinement pass;--no-decontaminatedisables color decontamination of the RGBA output.
HTTP service (FastAPI)
uv run uvicorn serving.app:app --port 8756
curl -F "file=@input.jpg" "http://localhost:8756/remove?model=lucida-v7" -o output.png
Query parameters: model (default rmbg-2.0), refine (bool), decontaminate (bool, default
true). GET /health lists the available models.
ComfyUI
Lucida is distributed in ComfyUI's official model collection,
Comfy-Org/BiRefNet. Download lucida.safetensors
from there and place it in ComfyUI/models/background_removal/.
Docker
See docs/docker.md.
How it was trained
Lucida is a fine-tune of BiRefNet_HR (MIT), starting from 52,882 image/alpha pairs across
9 categories (transparent, camouflage, complex, thin, hair, text, fx, illustration, general —
a tenth, design, was added for v7), trained on a single A100 40GB at 1024x1024, batch 2 x
gradient-accumulation 4 (effective batch 8), bf16, using the official BiRefNet Matting task
losses (BCE + MAE + SSIM). Seven epochs — but not seven passes of the same recipe; each epoch was
benchmarked on the held-out test set (191 images through v6, 203 once the design category landed)
and the data or the category sampling was re-calibrated before the next one:
- v1 — transparency + camouflage focus. A
WeightedRandomSamplerpinned those two categories at 20% each of every epoch. Camouflage improved immediately, but everything else starved: complex/thin/hair collapsed. - v2-v3 — rebalance + real backgrounds. Explicit shares for all categories, plus original-background (non-composited) training samples. Complex recovered from 0.156 to 0.075 MAE, hair to 0.0067, transparency kept improving.
- v4 — three new capabilities. Synthetic text/logo renders and procedural glow/VFX data
(
scripts/make_textfx.py) plus ToonOut illustrations, together 26% of the epoch. Text (0.0119) and illustration (0.0129) immediately reached commercial-reference level — but transparency and hair paid for the reallocated share, and the aggressive fx glow data introduced "ghosting" (partial alpha on solid objects). - v5 — ghosting fix + consolidation. The fx generator was reworked (narrow halo band, short streaks, particles concentrated near the object), its share cut, and transparency/hair shares restored. Epoch-5 sampler shares: transparent .22, complex .19, camouflage .12, thin .12, hair .12, text .07, illustration .07, fx .05, general .04.
- v6 — community bug fixes (issue #1). Two
reported failure modes, fixed with derivative training copies (
scripts/make_v6_copies.py): edge-crops that cut 20-60% of the subject bounding box (~9k copies, so subjects touching the frame stop getting erased) and mixed-opacity augments of transparent pairs (up to 4k copies, so solid parts of transparent objects stop going semi-transparent). - v7 — the design category (issue #2). A Reddit
user reported print-design/sticker images — halftone subjects, distressed display text, smoke
and glow melting into white — being erased or ghosted. A new synthetic generator
(
scripts/make_design.py, ~6k pairs) and an 8% sampler share fixed it: design MAE went from 0.0479 (v6) to 0.0235, ahead of every competitor. Complex (0.0670 -> 0.0484) and fx (0.0313 -> 0.0180) also improved over v6. Final epoch-7 sampler shares: transparent .22, complex .19, thin .12, camouflage .10, hair .10, design .08, text .06, illustration .06, fx .05, general .02.
The full decision log lives in training/train_colab_lib.py (sampler preset docstrings) and
docs/reports/.
Datasets & licensing
Training data mixes sources with different licenses. The model weights are released under MIT, following the established practice of the field (BiRefNet itself was trained on largely research-only academic sets and releases MIT weights) — but a data license is not a weight license, and whether training-data restrictions propagate to weights is legally unsettled. The table below is the honest inventory; commercial users should make their own assessment, particularly regarding the research-only sources.
| Source | Category | License | Commercial use |
|---|---|---|---|
| DIS5K | thin / complex | DIS5K Terms of Use | Research-only |
| CAMO | camouflage | CC-BY-NC-SA 4.0 | Research-only |
| COD10K | camouflage | academic release | Research-only |
| P3M-10k | hair | P3M-10k Release Agreement | Research-only (faces blurred for privacy) |
| Transparent-460 | transparent | not stated | Treated as research-only |
| HIM2K | general | not stated | Treated as research-only |
| AM-2k | general | MIT (via release agreement) | Yes |
| BG-20k | backgrounds | MIT (via release agreement) | Yes |
| ToonOut | illustration | CC-BY 4.0 | Yes, with attribution |
| Synthetic text/fx (this repo) | text / fx | MIT (scripts/make_textfx.py) | Yes |
| Synthetic design (this repo) | design | MIT generator (scripts/make_design.py); foregrounds drawn from the sources above | inherits foreground-source licensing |
Limitations
- Transparency: the commercial reference (Ideogram) still leads, 0.0343 vs 0.0358 MAE.
- Complex scenes and thin structures: InSPyReNet's specialist advantage stands (0.0110/0.0166 vs our 0.0484/0.0322); RMBG-2.0 leads hair.
- Semantic coherence: subject selection on scenes with partially visible people or ambiguous multi-object layouts is not perfect — occasional dropped or extra parts.
- fx measurement: the fx benchmark row is conservative for v5+ (test GT from the older generator, see the table footnote).
License & citation
Code and weights: MIT.
Lucida builds on BiRefNet (MIT) — if you use this model in research, please also cite:
@article{zheng2024birefnet,
title = {Bilateral Reference for High-Resolution Dichotomous Image Segmentation},
author = {Zheng, Peng and Gao, Dehong and Fan, Deng-Ping and Liu, Li and Laaksonen, Jorma and Ouyang, Wanli and Sebe, Nicu},
journal = {CAAI Artificial Intelligence Research},
volume = {3},
pages = {9150038},
year = {2024}
}
Illustration training and test data come from the ToonOut dataset by Joël Seytre (joelseytre/toonout, CC-BY 4.0).
Similar Projects
Discover other similar projects and AI models.
Lucida — general-purpose background removal with soft-alpha mastery Lucida is a BiRefNet-based background-removal / image-matting model fine-tuned to excel where most open models fail: camouflaged objects, transparent materials (glass), text & logos...
Bilateral Reference for High-Resolution Dichotomous Image Segmentation Peng Zheng 1,4,5,6,  Dehong Gao 2,  Deng-Ping Fan 1,  Li Liu 3,  Jorma Laaksonen 4,  Wanli Ouyang 5,  Nicu Sebe 6 1 Nankai University&ens...
BRIA Background Removal v3.0 Model Card 🏆 1 in background removal in our head-to-head benchmark against Photoroom, remove.bg (Canva), Ideogram, BiRefNet and RMBG-2.0, on 234 hard images at full resolution. Background removal, reimagined as image ed...
Ultralytics YOLOv5 in PyTorch for object detection, instance segmentation, classification, training, and export.
[CAAI AIR'24] Bilateral Reference for High-Resolution Dichotomous Image Segmentation
Learn AI Engineering! Learn it. Build it. Ship it for others.
BRIA Background Removal v1.4 Model Card RMBG v1.4 is our state-of-the-art background removal model, designed to effectively separate foreground from background in a range of categories and image types. This model has been trained on a carefully sele...
BRIA Background Removal v2.0 Model Card ✨ Discover FIBO on Hugging Face 💜 Bria AI   |   🤗 Hugging Face    |    📑 Blog    🖥️ Demo  |    Github   RMBG v2.0 is our new state-of-the-art...