v2d / simulation /scripts /fetch_gear_lfs.sh
hk239's picture
Upload v2d project (excluding data and .venv) (part 18)
3f4bb1d verified
Raw History Blame Contribute Delete
2.36 kB
#!/bin/bash
# Fetch Git LFS blobs for GR00T-WholeBodyControl without git-lfs installed.
#
# The checkout stores the GEAR planner weights as 132-byte LFS pointers. GitHub
# serves the real blobs from media.githubusercontent.com, so each pointer is
# read for its sha256 and size, downloaded, verified, and swapped in place.
# A file whose hash does not match is left untouched.
#
# ./scripts/fetch_gear_lfs.sh # planner + walk policy
# ./scripts/fetch_gear_lfs.sh <path>... # specific repo-relative paths
set -uo pipefail
REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../third-party/GR00T-WholeBodyControl" && pwd)"
BRANCH="${GEAR_LFS_BRANCH:-main}"
BASE="https://media.githubusercontent.com/media/NVlabs/GR00T-WholeBodyControl/$BRANCH"
DEFAULT_PATHS=(
"motionbricks/out/G1-clip.ckpt"
"motionbricks/out/motionbricks_root/version_1/checkpoints/model-step=2000000.ckpt"
"motionbricks/out/motionbricks_pose/version_1/checkpoints/model-step=2000000.ckpt"
"motionbricks/out/motionbricks_vqvae/version_1/checkpoints/model-step=2000000.ckpt"
"decoupled_wbc/sim2mujoco/resources/robots/g1/policy/GR00T-WholeBodyControl-Walk.onnx"
"decoupled_wbc/sim2mujoco/resources/robots/g1/policy/GR00T-WholeBodyControl-Balance.onnx"
)
if [[ $# -gt 0 ]]; then
PATHS=("$@")
else
PATHS=("${DEFAULT_PATHS[@]}")
fi
fail=0
for rel in "${PATHS[@]}"; do
file="$REPO/$rel"
if [[ ! -f "$file" ]]; then
echo "skip (missing): $rel"
continue
fi
# A real blob is far larger than a pointer and has no version line.
if ! head -c 64 "$file" | grep -q 'git-lfs.github.com/spec'; then
echo "ok (already real, $(stat -c%s "$file") bytes): $rel"
continue
fi
oid="$(awk -F: '/^oid sha256:/ {print $2}' "$file")"
want="$(awk '/^size / {print $2}' "$file")"
if [[ -z "$oid" || -z "$want" ]]; then
echo "FAIL (unreadable pointer): $rel"
fail=1
continue
fi
tmp="$(mktemp)"
echo "fetch $rel ($want bytes)"
if ! curl -sfL -o "$tmp" "$BASE/$rel"; then
echo "FAIL (download): $rel"
rm -f "$tmp"
fail=1
continue
fi
got="$(sha256sum "$tmp" | awk '{print $1}')"
size="$(stat -c%s "$tmp")"
if [[ "$got" != "$oid" ]]; then
echo "FAIL (sha256 $got != $oid): $rel"
rm -f "$tmp"
fail=1
continue
fi
mv "$tmp" "$file"
chmod 644 "$file"
echo " verified $size bytes"
done
exit "$fail"