STATICAI commited on
Commit
9c13bcb
Β·
verified Β·
1 Parent(s): 425c079

Restore install.sh from Make-It-Animatable

Browse files
Files changed (1) hide show
  1. install.sh +82 -0
install.sh ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Idempotent install script β€” skips steps already completed on previous runs.
3
+ # Model weights and repo are stored in /data for persistence across restarts.
4
+
5
+ set -euo pipefail
6
+
7
+ DATA_ROOT="${DATA_ROOT:-/data}"
8
+ REPO_DIR="${DATA_ROOT}/app"
9
+ SENTINEL="${REPO_DIR}/.install_complete"
10
+ WEIGHTS_DIR="${DATA_ROOT}/models/make-it-animatable"
11
+
12
+ mkdir -p "${DATA_ROOT}/temp" "${WEIGHTS_DIR}"
13
+
14
+ # ── 1. Clone repo (once) ──────────────────────────────────────────────────────
15
+ if [ ! -f "$SENTINEL" ]; then
16
+ echo "==> Cloning Make-It-Animatable..."
17
+ git lfs install
18
+ rm -rf "$REPO_DIR"
19
+ git clone https://github.com/jasongzy/Make-It-Animatable --recursive --single-branch --depth 1 "$REPO_DIR"
20
+ else
21
+ echo "==> Repo already present, skipping clone."
22
+ fi
23
+
24
+ # Symlink so the Space entrypoint can find the upstream package as ./app/.
25
+ # `ln -sfn SOURCE EXISTING_DIR` creates EXISTING_DIR/app instead of replacing
26
+ # the directory, so always resolve the destination explicitly.
27
+ if [ -L "app" ]; then
28
+ ln -sfn "$REPO_DIR" app
29
+ elif [ ! -e "app" ]; then
30
+ ln -s "$REPO_DIR" app
31
+ fi
32
+
33
+ # ── 2. FBX2glTF binary (once) ─────────────────────────────────────────────────
34
+ if [ ! -f "${REPO_DIR}/util/FBX2glTF" ]; then
35
+ echo "==> Downloading FBX2glTF..."
36
+ wget -q https://github.com/facebookincubator/FBX2glTF/releases/download/v0.9.7/FBX2glTF-linux-x64 \
37
+ -O "${REPO_DIR}/util/FBX2glTF"
38
+ chmod +x "${REPO_DIR}/util/FBX2glTF"
39
+ else
40
+ echo "==> FBX2glTF already present."
41
+ fi
42
+
43
+ # ── 3. Model weights (once) ───────────────────────────────────────────────────
44
+ if [ -d "${WEIGHTS_DIR}/data" ] && [ "$(ls -A ${WEIGHTS_DIR}/data 2>/dev/null)" ]; then
45
+ echo "==> Model weights already present, skipping download."
46
+ rm -rf "${REPO_DIR}/data" "${REPO_DIR}/output"
47
+ ln -s "${WEIGHTS_DIR}/data" "${REPO_DIR}/data"
48
+ ln -s "${WEIGHTS_DIR}/output" "${REPO_DIR}/output"
49
+ else
50
+ echo "==> Downloading model weights (one-time only)..."
51
+ TMPDIR="${DATA_ROOT}/temp/hf-weights"
52
+ rm -rf "$TMPDIR"
53
+ python3 -c "
54
+ from huggingface_hub import snapshot_download
55
+ snapshot_download('jasongzy/Make-It-Animatable', local_dir='${TMPDIR}',
56
+ ignore_patterns=['*.git*', '.gitattributes'])
57
+ print('Download complete.')
58
+ "
59
+ [ -d "${TMPDIR}/data" ] && mv "${TMPDIR}/data" "${WEIGHTS_DIR}/data"
60
+ [ -d "${TMPDIR}/output" ] && mv "${TMPDIR}/output" "${WEIGHTS_DIR}/output"
61
+ rm -rf "$TMPDIR"
62
+ rm -rf "${REPO_DIR}/data" "${REPO_DIR}/output"
63
+ ln -s "${WEIGHTS_DIR}/data" "${REPO_DIR}/data"
64
+ ln -s "${WEIGHTS_DIR}/output" "${REPO_DIR}/output"
65
+ echo "==> Weights saved to ${WEIGHTS_DIR}"
66
+ fi
67
+
68
+ # ── 4. Mixamo bones ───────────────────────────────────────────────────────────
69
+ mkdir -p "${REPO_DIR}/data/Mixamo/animation" 2>/dev/null || true
70
+ BONES_SRC="${REPO_DIR}/data/Standard Run.fbx"
71
+ BONES_DST="${REPO_DIR}/data/Mixamo/bones.fbx"
72
+ if [ -f "$BONES_SRC" ] && [ ! -f "$BONES_DST" ]; then
73
+ cp "$BONES_SRC" "$BONES_DST"
74
+ fi
75
+ test -s "$BONES_DST"
76
+
77
+ # ── 5. Runtime patches ────────────────────────────────────────────────────────
78
+ python3 patch_runtime.py
79
+
80
+ # ── 6. Mark complete ──────────────────────────────────────────────────────────
81
+ touch "$SENTINEL"
82
+ echo "==> install.sh done."