lucida / README.md
egeorcun's picture
Upload README.md with huggingface_hub
fcdb138 verified
|
Raw
History Blame Contribute Delete
2.6 kB
---
license: mit
pipeline_tag: image-segmentation
base_model: ZhengPeng7/BiRefNet_HR
datasets:
- joelseytre/toonout
tags:
- background-removal
- image-matting
- BiRefNet
- transparency
- camouflage
- text-preservation
- illustration
- rgba
library_name: transformers
---
# 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](https://huggingface.co/spaces/egeorcun/lucida-demo).
## Usage
```python
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](https://huggingface.co/ZhengPeng7/BiRefNet_HR) (MIT). Lucida is a fine-tune; the original copyright notice is preserved.
- Illustration data includes [ToonOut](https://huggingface.co/datasets/joelseytre/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).