feat(models): add IDOL (idol) image to 3D Gaussian splats in mlxcel predict
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 8/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- rust
調査の方向性
Start in src/vision/dense/registry.rs at checkpoint_model_type, which fails on configs without a model_type key, and read geometry_io.rs for write_gaussian_ply and the Gaussians struct. The full port spans a new src/vision/dense/idol/ module tree plus a DINOv3 and FLUX.2 VAE reuse decision, so a newcomer should first agree the scope with maintainers. Done means the structural detection resolves to idol and the parity tests in each submodule pass against precomputed features.
索引モデルが issue の本文から書いたものです。
説明
Summary
Port Sperid Labs' IDOL single-image-to-3D model (speridlabs/idol) as a mlxcel predict dense family idol: an object photo becomes a standard 3D Gaussian Splatting .ply, the prepared input PNG and predicted camera parameters. The pipeline is BiRefNet background removal, DINOv3-H+ and FLUX.2 VAE image conditioning, a rectified-flow transformer over an 8192-token object latent and a camera token, an octree point sampler, and a Gaussian decoder. Today mlxcel predict -m speridlabs/idol fails because its config.json has no model_type and no dense family matches. The output surface (mlxcel predict, write_gaussian_ply) already exists from #2349 and #2381, so this is a single-family port with one structural-detection addition.
Upstream reference
- Blaizzy/mlx-vlm#2644 (
92e07596), https://github.com/Blaizzy/mlx-vlm/tree/main/mlx_vlm/models/idol - Pipeline: https://github.com/Blaizzy/mlx-vlm/blob/main/mlx_vlm/models/idol/pipeline.py (
IdolPipeline.preprocess,encode_image,sample,decode,__call__,IdolOutput.save) - Denoiser: https://github.com/Blaizzy/mlx-vlm/blob/main/mlx_vlm/models/idol/dit.py (
LatentSeqMMFlowModel); layers: https://github.com/Blaizzy/mlx-vlm/blob/main/mlx_vlm/models/idol/layers.py (sanitize_weights,MultiHeadRMSNorm,PcdAbsolutePositionEmbedder(v2),SinusoidalEmbedder,RePo3DRotaryEmbedding,UnifiedTransformerBlock,TransformerCrossBlock,ModulatedTransformerCrossOnlyBlock) - Sampler: https://github.com/Blaizzy/mlx-vlm/blob/main/mlx_vlm/models/idol/sampler.py (
sample_flow) - Decoders: https://github.com/Blaizzy/mlx-vlm/blob/main/mlx_vlm/models/idol/decoder.py (
systematic_sample,OctreeProbabilityFixedlenDecoder.sample,GaussianFixedlenDecoder.to_representation); Gaussians and PLY: https://github.com/Blaizzy/mlx-vlm/blob/main/mlx_vlm/models/idol/gaussian.py; camera: https://github.com/Blaizzy/mlx-vlm/blob/main/mlx_vlm/models/idol/camera.py - Conditioning: https://github.com/Blaizzy/mlx-vlm/blob/main/mlx_vlm/models/idol/conditioning.py (
DINOv3,Flux2ImageEncoder,ImageEncoder); preprocessing: https://github.com/Blaizzy/mlx-vlm/blob/main/mlx_vlm/models/idol/preprocess.py; BiRefNet with deformable convolutions: https://github.com/Blaizzy/mlx-vlm/blob/main/mlx_vlm/models/idol/birefnet.py - Original SDK: https://github.com/speridlabs/idol-sdk (Apache-2.0; ported from commit
4702a7f00850e34b6e83a2170cc123c3e9570744, model revision2731c2291fc65a797c5cb627a5e5526fc1490902). The denoiser credits the Wan and Hugging Face teams (diffuserstransformer_wan.py, Apache-2.0).
Architecture (from upstream code and speridlabs/idol/config.json)
config.json has no model_type; it holds denoiser (name: LatentSeqMMFlowModel, q_token_length 8192, in_channels 16, cam_channels 5, model_channels 1024, cond_channels 1280, cond2_channels 128, num_blocks 24, num_refiner_blocks 2, num_heads 16, mlp_ratio 4), decoder (OctreeProbabilityFixedlenDecoder, 1024 channels, cond_channels 16, 4 blocks), decoder_gs (GaussianFixedlenDecoder, 16 blocks, representation_config: num_gaussians 32 per anchor, lr per attribute (_rotation 0.1, others 1.0), perturbe_size 1.5, 3d_filter_kernel_size 0.0009, scaling_bias 0.004, opacity_bias 0.1), image_size 1024, max_voxel_level 8, and image_encoders (dinov3: facebook/dinov3-vith16plus-pretrain-lvd1689m, flux2_vae: black-forest-labs/FLUX.2-dev). Weights: denoiser.safetensors (1.48 GB), decoder.safetensors (0.20 GB), decoder_gs.safetensors (0.95 GB), birefnet.safetensors (0.44 GB).
- Preprocess (
preprocess_image): load as RGBA; resize so the short side is 1024 (LANCZOS); if the alpha channel is not real (min 255), predict one with BiRefNet in f32 at 1024 px; erode the alpha by a 3x3 min filter; crop a square of sidemax(1, bbox_w, bbox_h) * crop_marginaround the alpha bounding-box centre (crop_margin1.2 formode: synthetic, the default, and 1.7 formode: real); resize to 1024 (LANCZOS); composite on black. An empty alpha is an error. - Conditioning (
ImageEncoder): pixels/ 255; DINOv3-H+ (HF layout, CLS + 4 register tokens, axial RoPE with per-axis coordinates(i + 0.5) / n * 2 - 1andrope_theta, gated SiLU MLP, LayerScalelambda1) on ImageNet-normalized input in bf16 by default, then a parameter-free LayerNorm (eps 1e-5) in f32:feature1 [1, 4101, 1280]. The FLUX.2-dev VAE encoder in bf16 onpixels * 2 - 1: posteriormean + exp(0.5 * clip(logvar, -30, 20)) * noise, 2x2 patchify with channel order(C, py, px), batch-norm normalization (eps 1e-4), and 5 leading zero tokens:feature2 [1, 4101, 128]. The two token counts must match. The RNG is seeded after the encoders load, and the VAE posterior noise is drawn from that stream before sampling. - Denoiser (
LatentSeqMMFlowModel, f16 linears, f32 embeddings, norms and learned rotary parameters):h_x = input_layer(latent) + pos_embedder(pos_pe)(a stored scrambled Sobol position table[1, 8192, 3]);h_cond = cond_embedder(feature1) + cond_embedder2(feature2);t_mod = adaLN_modulation(SinusoidalEmbedder(t))(6 x 1024); 2 modulatednoise_refinerblocks on the latent, 2 unmodulatedcontext_refinerblocks on the condition, an MLPcam_refineron the camera token, then 24 jointblocksover[latent, condition, camera]; each block has its ownRePo3DRotaryEmbedding(positions predicted from content: LayerNorm in f32,final_map(silu(gate_map(h)) * content_map(h))to 3 values per head, frequencieslinspace(1, 16, ...)per axis, angles times pi, interleaved-pair rotation in f32); output LayerNorm,shift_table + t_embmodulation,out_layer(latent velocity[B, 8192, 16]) andcam_out_layer([B, 1, 5]). - Sampler (
sample_flow): noiselatent [B, 8192, 16],camera [B, 1, 5];ts = linspace(1, 0, steps + 1),ts = rescale_t * ts / (1 + (rescale_t - 1) * ts); model time1000 * ts[i]; guidance against a zero condition:v = (1 + cfg) * v_cond - cfg * v_zerowhencfg > 0; Eulerx -= v * (ts[i] - ts[i + 1]);batch_cfgruns both passes as one batch. Defaults: 50 steps,cfg_strength 3.0,rescale_t 3.0, seed 42. - Octree decoder: starting from one root cell holding
num_gaussians / 32points, for depth 1..8 predict an 8-way child distribution per cell from the cell centres and the latent (cross-attention-only modulated blocks, level embedding), split counts with systematic sampling (one uniform offset per row, CDF rounding), keep cells with points (host-side variable-length packing); final points are(cell + uniform) / 2^8. - Gaussian decoder: 16 cross blocks over the points and the latent,
out_projto 32 anchors' attributes (_xyz 3,_features_dc 1x3,_scaling 3,_rotation 4,_opacity 1,_offset_scale 1); positionstanh(offset) * 0.75 * softplus(offset_scale + base_offset_scale) + pointwith a stored per-anchor perturbation; activations:xyz - 0.5, softplus scaling with the bias offset andsqrt(s^2 + 0.0009^2), normalized quaternionraw + [1, 0, 0, 0], sigmoid opacity with theopacity_biaslogit offset. - PLY export (
Gaussian.save_ply): binary little-endian with the 17 standard 3DGS float fields; positions rotated from z-up to y-up(x, -z, y), quaternions(w - x, w + x, y - z, y + z) * sqrt(0.5), opacity clipped to[1e-6, 1 - 1e-6]and stored as a logit, scale stored aslog(max(s, 1e-6)); non-finite attributes are an error. - Camera (
decode_camera): yawatan2(dx, dy), pitchasin(dz), radius1 / inverse_distance(orthographic, radius 1000, below 1e-3), vertical FOV in degrees. - Sanitize (
sanitize_weightsper module): conv kernels to MLX layout, transformer linears cast to f16, the rest kept f32; DINOv3 keyslayer.*/model.layer.*toencoder.layer.*; the FLUX.2 VAE keepsencoder.*,quant_conv.*,bn.*with.to_out.0.to.to_out..
Checkpoints and host
| Component | Id | Size | Access |
|---|---|---|---|
| IDOL weights | speridlabs/idol |
3.13 GB | Public, Apache-2.0 |
| DINOv3-H+ encoder | facebook/dinov3-vith16plus-pretrain-lvd1689m |
3.36 GB (840.6M f32 parameters) | Gated (DINOv3 license; accept terms) |
FLUX.2 VAE (only vae/) |
black-forest-labs/FLUX.2-dev |
0.34 GB | Gated (FLUX.2-dev license; accept terms) |
Upstream measured 9.49 GB peak MLX memory for the default 262,144-Gaussian run, so any 16 GB machine is enough. Each piece is under 5 GB (home = both); the gated encoders must be downloaded by someone who accepted their terms. Encoder access is not needed to sample and decode from precomputed features, which is how the unit-level parity tests run.
Current behavior
src/vision/dense/registry.rs:149(checkpoint_model_type) requires amodel_typekey, so IDOL's config fails withmodel_type not found;KNOWN_MODEL_TYPES(:106) andFAMILIEShave noidol.- Reusable in-tree pieces:
src/vision/dense/geometry_io.rs(Gaussians:18,write_gaussian_ply:151, which writes the 17 fields but applies no axis rotation, clamps opacity to[1e-7, 1 - 1e-7]and takesln(scale)without a floor);src/vision/dense/sam3d_objects/(flow-matching object generation and thegaussian.plyoutput precedent);src/vision/dense/sam3d_body/backbone.rs:121(a DINOv3-H+ backbone with storage tokens and axial RoPE, loaded from the SAM 3D Body schema) andsam3d_body/rope.rs:77(apply_rope);src/imagegen/vae/model.rs:286(Flux2Vae, Diffusers names from<model>/vae/,encodeat:466);src/vision/dense/interpolate.rs(resizes,grid_sample).
Proposed solution
New src/vision/dense/idol/ (mod.rs with pub fn load(path) -> Result<Box<dyn DensePredictor>>, config.rs, preprocess.rs, birefnet.rs, deform_conv.rs, conditioning.rs, layers.rs, denoiser.rs, sampler.rs, octree.rs, gaussian.rs, camera.rs, tests beside each); in src/vision/dense/registry.rs a structural fallback in checkpoint_model_type that returns "idol" when model_type is absent and denoiser.name == "LatentSeqMMFlowModel" with decoder_gs and image_encoders present, idol in KNOWN_MODEL_TYPES, and a DenseFamily { model_type: "idol", supports_prompts: false, supports_sidecars: false, load } row; a StandaloneArchitectureFamily in src/models/registry.rs (category dense_prediction, input image, output Gaussian splats).
- Task
gaussian(the only task). Options through--opts:mode(syntheticdefault orreal),num_gaussians(multiple of 32 in[32768, 1048576], default 262144),rescale_t,crop_margin,batch_cfg,dinov3,flux2_vae(local paths; default: the ids inimage_encodersresolved the way-mresolves a model, failing with a message naming the gated repo when absent),dinov3_dtype(bf16default,fp32,fp16),background_removal(default true; false requires a real alpha).--steps-style shared knobs go through--optsassteps,guidance,seed. - Outputs through the shared writer:
gaussian.ply,input.png(the prepared image),camera.json,result.safetensors(latent,camera) andmeta.json(seed, steps, guidance,num_gaussians,mode). - PLY: convert to y-up and apply IDOL's clamps (
max(s, 1e-6), opacity in[1e-6, 1 - 1e-6]) when buildingGaussians, then callwrite_gaussian_plyunchanged; its own clamp is a no-op on those values, so the bytes match upstream's. Do not change the writer (SAM 3D Objects depends on it). - DINOv3-H+: reuse
sam3d_body/backbone.rsif it can be loaded from the HFfacebook/dinov3-vith16plus-pretrain-lvd1689mkey layout through a key map and its RoPE matches (per-axis normalization,rope_thetaperiods); a unit test with shared random weights decides. Otherwise move the DINOv3 ViT intosrc/vision/dense/dinov3.rs, used by both, rather than writing a second copy insideidol/. - FLUX.2 VAE: reuse
Flux2Vae's encoder; add amoments()accessor that returns mean and clipped log-variance so IDOL can sample the posterior; update its// Used by:comment. - BiRefNet: new (Swin-L backbone, ASPP with deformable convolutions, the multi-scale decoder) in
birefnet.rsanddeform_conv.rs; f32. - Host-side packing: the octree's variable-length packing runs on the CPU once per level, as upstream does; all network passes and random draws stay in MLX.
Rejected alternative: a /v1/meshes job API like upstream's. mlxcel dense prediction has no server route; adding one is separate infrastructure (see docs/vision-model-scope.md "Re-scoping a family", condition 2).
Scope
In scope: the module, the structural detection, CLI prediction with background removal, docs/supported-models.md and docs/dense-prediction.md entries (with the gated-encoder instructions), a row in the dense prediction table of docs/vision-model-scope.md, NOTICE (Idol SDK Apache-2.0, diffusers Wan Apache-2.0, mlx-vlm MIT; the DINOv3 and FLUX.2-dev weights keep their own licenses and are not redistributed).
Out of scope: a server route, mesh extraction, text conditioning, quantized weights, matching PyTorch outputs seed for seed (different RNGs).
Implementation notes
- Dtype: transformer linears f16, embeddings and norms f32, rotary computations f32, BiRefNet f32, VAE bf16, DINOv3 bf16 by default.
- Edge cases: an RGBA input with real alpha (skips BiRefNet), an RGB input with
background_removal: false(error), an alpha mask that is empty after erosion (error), a non-square or tiny image,num_gaussiansnot a multiple of 32 or outside the range (error),steps < 1, negative or non-finite guidance orrescale_t(error), a missing encoder (error naming the repo). - Error handling: every validation error has upstream's message; non-finite Gaussian attributes fail the export.
Acceptance criteria
- Detection test: the published
config.jsonresolves toidol; a config withoutmodel_typeand without the IDOL keys still fails withmodel_type not found. - Unit tests:
systematic_samplewith fixed offsets against upstream values; octree point counts sum tonum_gaussians / 32per level;RePo3DRotaryEmbeddingandPcdAbsolutePositionEmbedderv2against hand-computed values; Gaussian activations and the y-up PLY transform on a 2-point example;decode_cameraperspective and orthographic cases; the preprocess crop geometry for both modes; deformable convolution against a direct reference on a 6x6 input. - Parity with fixed inputs against mlx-vlm on
speridlabs/idol(no encoders needed). Upstream'ssampleanddecodedraw their noise, systematic-sampling offsets and final uniforms from the MLX RNG internally, so build the fixtures with a script that runs upstream and records those drawn arrays together with the outputs (upstream'ssystematic_samplealready takesoffsets); give mlxcel's sampler and octree decoder optional injected random inputs for tests. Fixtures: a stored random condition, recorded noise and 4 steps (latent and camera relative error under 3e-3, upstream's mixed-precision bound), anddecodefrom a fixed latent at 32,768 Gaussians with the recorded offsets and uniforms (attribute relative error under 1e-3). They fail on current code. - With the encoders present: BiRefNet alpha on a fixture image within one 8-bit level of upstream's, DINOv3 features cosine similarity above 0.999 and VAE posterior mean relative error under 3e-2 against upstream.
-
mlxcel predict -m speridlabs/idol --image toy-castle.webp --task gaussian -o out/ --opts '{"mode": "synthetic"}'writes a finitegaussian.plywith 262,144 vertices,input.pngandcamera.json; the PLY opens in a standard 3DGS viewer. -
mlxcel archlistsidol.
Verification
cargo test --profile test-fast vision::dense::idol
cargo test --profile test-fast vision::dense::geometry_io
make verify-test
cargo clippy --workspace --all-targets -- -D warnings
cargo fmt --check
./target/release/mlxcel predict -m models/idol --image tests/fixtures/<object>.png --task gaussian -o /tmp/idol --opts '{"num_gaussians": 32768}'
Related
- Dense prediction surface #2349, epic #2382, SAM 3D Objects #2381 (Gaussian PLY output precedent), FLUX.2 VAE from #2424.
- 主要言語
- Rust
- スター
- 505
- フォーク
- 81
- 平均マージ
- 14時間 2分
- マージ済み PR(30日)
- 448
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
lablup/mlxcel のほかの issue
-
area:core priority:high status:ready type:security
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
priority:medium status:ready type:security
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
メンテナーはふだん 1 日以内に返信
-
area:models modeltype:text priority:medium status:in-progress type:bug
難易度 4/5 3〜5日 初心者へのやさしさ 57/100
メンテナーはふだん 1 日以内に返信
-
area:models priority:low status:ready type:test
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
メンテナーはふだん 1 日以内に返信
-
area:models modeltype:omni priority:medium status:ready type:bug
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
TypeScript BM25 drops supplementary characters at the token length limit対応中かも @ErenAta16 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
chroma-core/chroma#8038 ·
メンテナーはふだん 1 日以内に返信
-
p3 ready
難易度 2/5 1〜3時間 初心者へのやさしさ 71/100
メンテナーはふだん 1 日以内に返信
-
area:ui effort:medium enhancement P7 source:agent
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
marketing
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
machine rename accepts a label already used by another machine, making --machine <label> ambiguousオープンmaintainer-needed p2 remote triaged
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信