SceneWorks commited on
Commit
1406cbc
Β·
verified Β·
1 Parent(s): 456efa2

Add model card

Browse files
Files changed (1) hide show
  1. README.md +114 -0
README.md ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: mixed-upstream-see-card
4
+ library_name: mlx
5
+ pipeline_tag: text-to-image
6
+ tags:
7
+ - instantid
8
+ - sdxl
9
+ - mlx
10
+ - apple-silicon
11
+ - face-id
12
+ - controlnet
13
+ - ip-adapter
14
+ - identity-preservation
15
+ ---
16
+
17
+ # SceneWorks/instantid-mlx
18
+
19
+ Converted weights for running **InstantID** identity-preserving SDXL **natively on Apple Silicon
20
+ with MLX** β€” zero Python at inference time. These are the three artifacts the
21
+ [`mlx-gen-instantid`](https://github.com/michaeltrefry/mlx-gen) provider loads to compose InstantID
22
+ out of the SDXL backbone + the native MLX face stack (`mlx-gen-face`).
23
+
24
+ This repo holds **only the InstantID-specific glue weights**. The SDXL base (e.g.
25
+ `SG161222/RealVisXL_V5.0` or `stabilityai/stable-diffusion-xl-base-1.0`), the IdentityNet
26
+ ControlNet (`InstantX/InstantID` β†’ `ControlNetModel/`), and the OpenPose ControlNet for pose mode
27
+ (`xinsir/controlnet-openpose-sdxl-1.0`) are loaded directly from their own diffusers repos β€” no
28
+ conversion needed for those.
29
+
30
+ ## Files
31
+
32
+ | File | Size | What it is | Source | Converter |
33
+ |---|---|---|---|---|
34
+ | `ip-adapter.safetensors` | 1.57 GB | The InstantID face **IP-Adapter**: the image-projection **Resampler** (`image_proj.*`, ArcFace 512-d β†’ 16Γ—2048 face tokens) + the 70 decoupled cross-attention **K/V pairs** (`ip_adapter.*`). Re-serialized from the upstream torch **pickle** `ip-adapter.bin` into safetensors (MLX's loader reads safetensors, not pickle). | [`InstantX/InstantID`](https://huggingface.co/InstantX/InstantID) β†’ `ip-adapter.bin` | `tools/convert_instantid.py` |
35
+ | `scrfd_10g.safetensors` | 16 MB | **SCRFD** 5-point face detector (bbox + landmarks) β€” the detection half of the native face stack. Ported from the insightface `antelopev2` `scrfd_10g_bnkps` ONNX graph. | insightface `antelopev2` (`scrfd_10g_bnkps.onnx`) | `tools/convert_scrfd.py` |
36
+ | `arcface_iresnet100.safetensors` | 248 MB | **ArcFace** `iresnet100` 512-d recognition embedder β€” the identity-fidelity half. Ported from the insightface `antelopev2` `glintr100` ONNX graph. | insightface `antelopev2` (`glintr100.onnx`) | `tools/convert_glintr100.py` |
37
+
38
+ ### Checksums (sha256)
39
+
40
+ ```
41
+ fa5608b6121ffaa40228e76ac96e10f56e39b3aba2f6c4905ff7ef9046391c29 ip-adapter.safetensors
42
+ 7b40147a85771139e70a8d9fe6be27ffcf32f4c911770ef24b5b05c29f534eda scrfd_10g.safetensors
43
+ 9deff2fef8fe1b3e357a99c01f28cc478dd8acbeab0d3749d252f6d69990ee39 arcface_iresnet100.safetensors
44
+ ```
45
+
46
+ ## Usage
47
+
48
+ ### In `mlx-gen-instantid` (Rust / MLX)
49
+
50
+ ```rust
51
+ use mlx_gen::weights::Weights;
52
+ use mlx_gen::WeightsSource;
53
+ use mlx_gen_instantid::{InstantId, InstantIdPaths, InstantIdRequest};
54
+
55
+ let model = InstantId::load(&InstantIdPaths {
56
+ sdxl_base: "/path/to/RealVisXL_V5.0".into(), // diffusers SDXL snapshot
57
+ identitynet: WeightsSource::Dir("/path/to/InstantX--InstantID/ControlNetModel".into()),
58
+ ip_adapter: "ip-adapter.safetensors".into(), // <- from this repo
59
+ })?
60
+ .with_face(
61
+ &Weights::from_file("scrfd_10g.safetensors")?, // <- from this repo
62
+ &Weights::from_file("arcface_iresnet100.safetensors")?, // <- from this repo
63
+ )?;
64
+
65
+ let out = model.generate(&InstantIdRequest { /* prompt, w/h, steps, guidance, scales, seed */ ..Default::default() }, &reference_image)?;
66
+ ```
67
+
68
+ For pose mode add `.with_openpose(&WeightsSource::Dir("/path/to/xinsir--controlnet-openpose-sdxl-1.0".into()))?`
69
+ and call `generate_pose(req, &reference, &keypoints)`; for the ADetailer-style face-restore pass
70
+ call `restore_face(req, &base, &reference_embedding)`.
71
+
72
+ ### In SceneWorks (download-on-first-use)
73
+
74
+ The SceneWorks Rust GPU worker fetches these three files from this repo on first use into its app
75
+ cache (mirroring the `SceneWorks/yolo11m-person-detect-mlx` and `SceneWorks/sam2-mlx` pattern). You
76
+ can pre-stage them with the env override `SCENEWORKS_INSTANTID_WEIGHTS=/dir/with/the/three/files`.
77
+
78
+ ### Validation (real-weight, MLX, RealVisXL_V5.0 @ 1024Β²/30, fp16)
79
+
80
+ | Mode | Metric | Result |
81
+ |---|---|---|
82
+ | Single identity (`generate`) | ArcFace-cosine(ref, generated) | **0.8731** (torch baseline β‰ˆ 0.876) |
83
+ | Angle set (`generate_angle`, three-quarter right) | ArcFace-cosine | **0.8343** |
84
+ | Pose mode (`generate_pose`, full-body) | ArcFace-cosine | **0.7129** (small full-body face) |
85
+ | Face-restore (`restore_face`) | ArcFace-cosine | base 0.7370 β†’ **0.8338** |
86
+
87
+ ## Reproducing the conversion
88
+
89
+ All three converters live in [`mlx-gen/tools/`](https://github.com/michaeltrefry/mlx-gen/tree/main/tools)
90
+ and run in a torch venv (torch + safetensors; insightface for SCRFD/ArcFace ONNX import):
91
+
92
+ ```bash
93
+ python tools/convert_instantid.py # InstantX/InstantID ip-adapter.bin -> ip-adapter.safetensors
94
+ python tools/convert_scrfd.py # antelopev2 scrfd_10g_bnkps.onnx -> scrfd_10g.safetensors
95
+ python tools/convert_glintr100.py # antelopev2 glintr100.onnx -> arcface_iresnet100.safetensors
96
+ ```
97
+
98
+ ## Provenance & licensing
99
+
100
+ These are **format conversions** of third-party weights; the upstream licenses govern use. Verify
101
+ you comply with each before using them:
102
+
103
+ - **`ip-adapter.safetensors`** β€” derived from [`InstantX/InstantID`](https://huggingface.co/InstantX/InstantID)
104
+ (Apache-2.0). InstantID research: *"InstantID: Zero-shot Identity-Preserving Generation in Seconds"*
105
+ (Wang et al., 2024).
106
+ - **`scrfd_10g.safetensors`** and **`arcface_iresnet100.safetensors`** β€” derived from the
107
+ [InsightFace](https://github.com/deepinsight/insightface) `antelopev2` model pack (`scrfd_10g_bnkps`
108
+ + `glintr100`). **The InsightFace pretrained models are released for non-commercial research
109
+ purposes only** β€” see the InsightFace repository for their terms. Do not use these two files in a
110
+ commercial setting without securing appropriate rights from the upstream authors.
111
+
112
+ `license: other` reflects this mix; this card is the authoritative license statement. No additional
113
+ license is granted by the conversion. Conversions produced by the
114
+ [`mlx-gen`](https://github.com/michaeltrefry/mlx-gen) tooling (Apache-2.0 code).