BEN2 Modular Diffusers

Modular Diffusers blocks for BEN2 (Background Erase Network 2) by Prama LLC: remove an image's background as a soft alpha matte that keeps hair and fine edges. The blocks ship the model code and load the weights from OzzyGT/ben2_diffusers.

Usage

import torch
from diffusers import ModularPipelineBlocks


blocks = ModularPipelineBlocks.from_pretrained("OzzyGT/ben2_custom_blocks", trust_remote_code=True)
pipe = blocks.init_pipeline()
pipe.load_components(dtype=torch.float32)
pipe.to("cuda")

state = pipe(image="photo.jpg")
state.get("images")[0].save("cut_out.png")  # RGBA
state.get("matte").save("matte.png")  # the alpha matte alone

image is a path or a PIL image. On CUDA the model runs in float16 autocast, as the original does.

Licensing

The blocks are Apache-2.0. ben2_model.py and matte.py are adapted from BEN2, MIT: its notice is in LICENSE-BEN2. The weights are MIT too, see the model repository.

Downloads last month
42
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for OzzyGT/ben2_custom_blocks

Base model

PramaLLC/BEN2
Finetuned
(3)
this model