forma3d-tiny / train-mac.sh
Lucasgitguy-co's picture
Publish evaluated Forma3D-Tiny v0.2
e80b8d8 verified
Raw History Blame Contribute Delete
2.25 kB
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")"
if [[ "${1:-}" != "--publish" && -n "${1:-}" ]]; then
echo 'Usage: bash train-mac.sh [--publish]' >&2
exit 2
fi
FORMA3D_RUNTIME_DIR="${FORMA3D_RUNTIME_DIR:-$HOME/Library/Application Support/Forma3D}"
FORMA3D_PYTHON="$FORMA3D_RUNTIME_DIR/venv/bin/python"
if [[ ! -x "$FORMA3D_PYTHON" ]]; then
bash setup-mac.sh
fi
# Never depend on the caller's PATH, aliases, activation, or editable .pth files.
"$FORMA3D_PYTHON" -m image3d_student.cli doctor
if [[ ! -f base/examples/synthetic-smoke/synthetic-only.pt ]]; then
"$FORMA3D_RUNTIME_DIR/venv/bin/hf" download Lucasgitguy-co/image3d-student \
examples/synthetic-smoke/synthetic-only.pt \
--revision 1738cdfaf1bb940bf576a96d11b742ce014b9139 --local-dir base
fi
"$FORMA3D_PYTHON" - <<'PY'
from pathlib import Path
import hashlib
path = Path("base/examples/synthetic-smoke/synthetic-only.pt")
expected = "dd1a1719541c5603125e7f9379b0ad8ede20b7e9f2816a04e9120244cdbf528e"
if hashlib.sha256(path.read_bytes()).hexdigest() != expected:
raise SystemExit("Base checkpoint checksum mismatch; restore the pinned original checkpoint.")
print("Verified local base checkpoint; no Hugging Face connection required for training.")
PY
if [[ -s data/forma3d-v1/manifest.jsonl && -s data/forma3d-v1/test-manifest.jsonl ]]; then
echo 'Using completed dataset. Training will verify the cached sample hashes.'
else
"$FORMA3D_PYTHON" scripts/prepare_hf.py --out data/forma3d-v1 --cache data/downloads \
--scenario 64 --objaverse 32 --objaverse-shards 8 --grid 16 --views 4 --resume \
--max-file-mb 16 --max-download-mb 2048
fi
"$FORMA3D_PYTHON" -m image3d_student.cli train --manifest data/forma3d-v1/manifest.jsonl \
--init-from base/examples/synthetic-smoke/synthetic-only.pt \
--out runs/forma3d-v1 --device mps --width 64 --steps 5000 \
--batch-size 2 --lr 0.0001 --eval-every 100 --validation-fraction 0.2 --seed 42
if [[ "${1:-}" == "--publish" ]]; then set -- --publish; else set --; fi
"$FORMA3D_PYTHON" scripts/release.py --run runs/forma3d-v1 --data data/forma3d-v1 \
--base base/examples/synthetic-smoke/synthetic-only.pt \
--release release/forma3d-v1 --device mps --repo Lucasgitguy-co/forma3d-tiny \
"$@"