xocialize commited on
Commit
b989bb7
·
verified ·
1 Parent(s): 4174043

fp16 MLX conversion of ZhengPeng7/BiRefNet (Swin-L, 1024) — soft-alpha matting

Browse files
Files changed (2) hide show
  1. README.md +37 -0
  2. model.safetensors +3 -0
README.md ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ base_model: ZhengPeng7/BiRefNet
4
+ library_name: mlx
5
+ tags:
6
+ - mlx
7
+ - image-segmentation
8
+ - matting
9
+ - background-removal
10
+ - birefnet
11
+ pipeline_tag: image-segmentation
12
+ ---
13
+
14
+ # BiRefNet-fp16 (MLX)
15
+
16
+ [`mlx-community/BiRefNet-fp16`](https://huggingface.co/mlx-community/BiRefNet-fp16) is an **fp16 MLX** conversion
17
+ of [`ZhengPeng7/BiRefNet`](https://huggingface.co/ZhengPeng7/BiRefNet) (MIT) — a Swin-L + ASPP-Deformable
18
+ foreground segmentation / matting model at **1024×1024**, producing a single-channel soft-alpha matte
19
+ (white = foreground). The fast, general-purpose tier.
20
+
21
+ **Parity:** IoU **0.9905** vs the PyTorch reference (zero unused keys). fp16 runtime validated for production
22
+ matting quality.
23
+
24
+ ## Use (Swift / MLX)
25
+
26
+ Loaded by [`mlx-birefnet-swift`](https://github.com/xocialize/mlx-birefnet-swift) — the vendored `BiRefNet`
27
+ core plus a conformant MLXEngine `matting` ModelPackage:
28
+
29
+ ```swift
30
+ import BiRefNet
31
+ let pipeline = try BiRefNetPipeline.fromPretrained("model.safetensors", dtype: .float16) // inputSize 1024
32
+ let matte = try pipeline(cgImage).maskCGImage() // source-resolution soft-alpha
33
+ ```
34
+
35
+ Converted from the official PyTorch checkpoint via the package's `birefnet-convert` (PyTorch NCHW → MLX NHWC;
36
+ 754 → 687 tensors). Single-file `model.safetensors`. See also the higher-res tier
37
+ [`mlx-community/BiRefNet_HR-matting-fp16`](https://huggingface.co/mlx-community/BiRefNet_HR-matting-fp16).
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f1ba66260085fd8d471323dab098fabd36499ad54b0de8ca67deb5d1cf1f0c0e
3
+ size 440483842