modelbeast/scripts/install_hunyuan3d_mlx.sh
m3ultra 573afa7b7a hunyuan3d_mlx operator (local MLX image→3D) + cluster docs
- server/operators/hunyuan3d_mlx: native-MLX Hunyuan3D 2.1, both stages, PBR.
  Verified end-to-end on M3 Ultra: 260s total, 40k-face GLB w/ 2048² PBR.
  Weights public (no HF login). Runs on M1 (MLX-native).
- scripts/install_hunyuan3d_mlx.sh: uv py3.11 venv + MLX-path deps.
- CLUSTER.md: local-first policy + M3/M1/M4 fleet roles + central-queue howto.
- BENCHMARKS/README/AGENTS: hunyuan3d_mlx rows + trellis head-to-head.
2026-07-16 10:10:43 +10:00

56 lines
2.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# hunyuan3d-mlx — Hunyuan3D 2.1 native MLX port (local image→3D, both stages).
# Unlike trellis-mac there is no upstream setup.sh, so we build the venv here.
# The MLX path is HYBRID: MLX for the diffusion UNet/VAE/rasterizer/super-res,
# but PyTorch(+transformers) for DINOv2-giant image encoding — so torch is
# required, but NOT the CUDA-era requirements.txt (no basicsr/realesrgan/
# lightning/diffusers). bpy is optional (trimesh GLB fallback exists).
# MLX weights (dgrauet/hunyuan3d-2.1-mlx, ~15GB) + dinov2-giant (~4.5GB) are
# public and download at runtime on first generate.
set -euo pipefail
cd "$(dirname "$0")/.."
VENDOR="vendor/hunyuan3d-mlx"
if [ ! -d "$VENDOR" ]; then
echo "[hy3d] ERROR: $VENDOR missing. Vendor the repo there first."
exit 1
fi
cd "$VENDOR"
echo "[hy3d] creating uv venv (python 3.11, matches trellis-mac) ..."
[ -x .venv/bin/python ] || uv venv --python 3.11 .venv
# shellcheck disable=SC1091
source .venv/bin/activate
echo "[hy3d] installing MLX-path dependencies (torch is MPS/CPU, no CUDA) ..."
uv pip install \
mlx mlx-arsenal \
torch torchvision \
transformers timm \
huggingface_hub safetensors \
numpy scipy scikit-image PyMCubes \
trimesh pygltflib xatlas \
opencv-python pillow \
pymeshlab \
einops omegaconf pyyaml tqdm torchdiffeq \
diffusers accelerate \
fast_simplification # trimesh 4.12 delegates simplify_quadric_decimation to this (Stage 2 remesh)
echo "[hy3d] import probe — the authoritative check of the real MLX entry points ..."
export HF_HUB_DISABLE_XET=1
python - <<'PY' || { echo "[hy3d] PROBE FAILED — see ModuleNotFoundError above; add the package to this script and re-run."; exit 2; }
import sys, os
sys.path.insert(0, "hy3dshape")
sys.path.insert(0, "hy3dpaint")
import mlx.core as mx
print("[probe] mlx device:", mx.default_device())
import torch
print("[probe] torch:", torch.__version__, "mps:", torch.backends.mps.is_available())
from hy3dshape.pipeline_mlx import ShapePipeline
print("[probe] Stage 1 ShapePipeline import OK")
from textureGenPipeline_mlx import Hunyuan3DPaintConfigMLX, Hunyuan3DPaintPipelineMLX
print("[probe] Stage 2 Hunyuan3DPaintPipelineMLX import OK")
print("[probe] ALL IMPORTS OK")
PY
echo "[hy3d] done — venv ready. First generate downloads ~15GB MLX weights + dinov2-giant."