BiRefNet-fp16 / README.md
xocialize's picture
fp16 MLX conversion of ZhengPeng7/BiRefNet (Swin-L, 1024) β€” soft-alpha matting
b989bb7 verified
|
Raw
History Blame Contribute Delete
1.43 kB
---
license: mit
base_model: ZhengPeng7/BiRefNet
library_name: mlx
tags:
- mlx
- image-segmentation
- matting
- background-removal
- birefnet
pipeline_tag: image-segmentation
---
# BiRefNet-fp16 (MLX)
[`mlx-community/BiRefNet-fp16`](https://huggingface.co/mlx-community/BiRefNet-fp16) is an **fp16 MLX** conversion
of [`ZhengPeng7/BiRefNet`](https://huggingface.co/ZhengPeng7/BiRefNet) (MIT) β€” a Swin-L + ASPP-Deformable
foreground segmentation / matting model at **1024Γ—1024**, producing a single-channel soft-alpha matte
(white = foreground). The fast, general-purpose tier.
**Parity:** IoU **0.9905** vs the PyTorch reference (zero unused keys). fp16 runtime validated for production
matting quality.
## Use (Swift / MLX)
Loaded by [`mlx-birefnet-swift`](https://github.com/xocialize/mlx-birefnet-swift) β€” the vendored `BiRefNet`
core plus a conformant MLXEngine `matting` ModelPackage:
```swift
import BiRefNet
let pipeline = try BiRefNetPipeline.fromPretrained("model.safetensors", dtype: .float16) // inputSize 1024
let matte = try pipeline(cgImage).maskCGImage() // source-resolution soft-alpha
```
Converted from the official PyTorch checkpoint via the package's `birefnet-convert` (PyTorch NCHW β†’ MLX NHWC;
754 β†’ 687 tensors). Single-file `model.safetensors`. See also the higher-res tier
[`mlx-community/BiRefNet_HR-matting-fp16`](https://huggingface.co/mlx-community/BiRefNet_HR-matting-fp16).