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, VFX glows, and illustrations — while staying competitive everywhere else.

On our 191-image, 8-category benchmark (MAE, lower is better) Lucida leads every model we tested — including a commercial reference — in camouflage (0.0273) and illustration (0.0095), matches the commercial reference in text/logo preservation (0.0126), and sets our best-ever transparency (0.0376) and overall (0.0304) scores. Full benchmark, gallery and training recipe: https://github.com/egeorcun/lucida — or try the live demo.

Usage

import torch
from PIL import Image
from torchvision import transforms
from transformers import AutoModelForImageSegmentation

model = AutoModelForImageSegmentation.from_pretrained(
    "egeorcun/lucida", trust_remote_code=True, dtype=torch.float32)
model.eval()

t = transforms.Compose([
    transforms.Resize((1024, 1024)),
    transforms.ToTensor(),
    transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
])
img = Image.open("input.jpg").convert("RGB")
with torch.no_grad():
    preds = model(t(img).unsqueeze(0))[-1].sigmoid()
alpha = transforms.functional.resize(preds[0], img.size[::-1]).squeeze(0)
rgba = img.copy()
rgba.putalpha(Image.fromarray((alpha.numpy() * 255).astype("uint8")))
rgba.save("output.png")

For color decontamination (removing background color fringing) and the full pipeline (CLI, FastAPI service, Docker web UI), see the GitHub repository.

Base model & attribution

  • Architecture and initial weights: ZhengPeng7/BiRefNet_HR (MIT). Lucida is a fine-tune; the original copyright notice is preserved.
  • Illustration data includes ToonOut (CC-BY 4.0).
  • Some training datasets (e.g. P3M-10k, COD10K, DIS5K) are distributed for research purposes; see the GitHub README for the full dataset/license table and evaluate suitability for your use case.

License

MIT (weights and code).

Downloads last month
62
Safetensors
Model size
0.2B params
Tensor type
I64
·
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for egeorcun/lucida

Finetuned
(1)
this model
Merges
1 model

Dataset used to train egeorcun/lucida

Spaces using egeorcun/lucida 2