| #!/usr/bin/env bash |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| set -euo pipefail |
|
|
| HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| REPO_DIR="$(dirname "$HERE")" |
| |
| |
| BITE_ROOT="$REPO_DIR/bite_gradio-hf" |
| ENV_NAME="eccv26_bdoped" |
| MAKE_ENV=0 |
|
|
| while [[ $# -gt 0 ]]; do |
| case "$1" in |
| --bite-root) BITE_ROOT="$2"; shift 2 ;; |
| --env-name) ENV_NAME="$2"; shift 2 ;; |
| --make-env) MAKE_ENV=1; shift 1 ;; |
| -h|--help) sed -n '2,30p' "$0"; exit 0 ;; |
| *) echo "Unknown arg: $1" >&2; exit 2 ;; |
| esac |
| done |
|
|
| echo ">> BITE_ROOT = $BITE_ROOT" |
| echo ">> ENV_NAME = $ENV_NAME (make-env=$MAKE_ENV)" |
|
|
| |
| if [[ "$MAKE_ENV" == "1" ]]; then |
| echo ">> Creating conda env '$ENV_NAME' from $REPO_DIR/environment.yml" |
| conda env create -n "$ENV_NAME" -f "$REPO_DIR/environment.yml" |
| echo ">> Done. Activate with: conda activate $ENV_NAME" |
| fi |
|
|
| command -v git >/dev/null || { echo "git not found" >&2; exit 1; } |
| git lfs version >/dev/null 2>&1 || { echo "git-lfs not found (needed for weights)" >&2; exit 1; } |
|
|
| |
| if [[ -d "$BITE_ROOT/src/smal_pytorch" ]]; then |
| echo ">> BITE code already present at $BITE_ROOT (skipping clone)" |
| else |
| echo ">> Cloning BITE code -> $BITE_ROOT" |
| git clone -b dev https://github.com/camenduru/bite_gradio-hf "$BITE_ROOT" |
| fi |
|
|
| |
| SMAL_PKL="$BITE_ROOT/data/smal_data/new_dog_models/my_smpl_39dogsnorm_Jr_4_dog.pkl" |
| if [[ -f "$SMAL_PKL" ]]; then |
| echo ">> SMAL weights already in place ($SMAL_PKL) — skipping weights download" |
| else |
| TMP_W="$(mktemp -d)" |
| echo ">> Cloning weights huggingface.co/camenduru/bite -> $TMP_W/bite (~2 GB)" |
| GIT_LFS_SKIP_SMUDGE=0 git clone https://huggingface.co/camenduru/bite "$TMP_W/bite" |
| echo ">> Moving data/ checkpoint/ datasets/ into $BITE_ROOT" |
| for d in data checkpoint datasets; do |
| if [[ -d "$TMP_W/bite/$d" ]]; then |
| mkdir -p "$BITE_ROOT/$d" |
| cp -rn "$TMP_W/bite/$d/." "$BITE_ROOT/$d/" |
| fi |
| done |
| rm -rf "$TMP_W" |
| [[ -f "$SMAL_PKL" ]] || { echo "ERROR: expected $SMAL_PKL after setup" >&2; exit 1; } |
| fi |
|
|
| |
| echo ">> Patching BITE code for the renderer (idempotent)" |
| SMAL_PY="$BITE_ROOT/src/smal_pytorch/smal_model/smal_torch_new.py" |
| GEOM_PY="$BITE_ROOT/src/lifting_to_3d/utils/geometry_utils.py" |
| python - "$SMAL_PY" "$GEOM_PY" <<'PYEOF' |
| import sys |
| smal_py, geom_py = sys.argv[1], sys.argv[2] |
|
|
| |
| s = open(smal_py).read() |
| if "keyp_conf == 'all'" in s: |
| print(" - smal_torch_new.py: 'all' branch already present") |
| else: |
| lines = s.split("\n") |
| out, done = [], False |
| for i, ln in enumerate(lines): |
| |
| if (not done and ln.startswith(" else:") |
| and any("elif keyp_conf == 'dict':" in p for p in lines[:i])): |
| out.append(" elif keyp_conf == 'all':") |
| out.append(" relevant_joints = joints") |
| done = True |
| out.append(ln) |
| if not done: |
| sys.exit("ERROR: could not locate insertion point for keyp_conf=='all' in " + smal_py) |
| open(smal_py, "w").write("\n".join(out)) |
| print(" - smal_torch_new.py: inserted keyp_conf=='all' branch") |
|
|
| |
| g = open(geom_py).read() |
| if "torch.cross(b1, b2, dim" in g: |
| print(" - geometry_utils.py: torch.cross dim already set") |
| elif "torch.cross(b1, b2)" in g: |
| open(geom_py, "w").write(g.replace("torch.cross(b1, b2)", "torch.cross(b1, b2, dim=-1)")) |
| print(" - geometry_utils.py: pinned torch.cross dim=-1") |
| else: |
| print(" - geometry_utils.py: torch.cross(b1, b2) not found (skipped)") |
| PYEOF |
|
|
| |
| echo ">> Ensuring chumpy is installed (BITE imports it)" |
| |
| |
| ENV_PY="$(conda info --base 2>/dev/null)/envs/$ENV_NAME/bin/python" |
| if [[ -x "$ENV_PY" ]]; then |
| PY="$ENV_PY" |
| elif command -v python >/dev/null 2>&1; then |
| PY="$(command -v python)" |
| else |
| echo "WARN: no python found to install chumpy; activate the env then re-run." >&2 |
| PY="" |
| fi |
| if [[ -n "$PY" ]]; then |
| echo ">> chumpy target python: $PY" |
| if "$PY" -m pip show chumpy >/dev/null 2>&1; then |
| echo ">> chumpy already installed" |
| else |
| "$PY" -m pip install -U pip setuptools wheel |
| "$PY" -m pip install --no-build-isolation chumpy==0.70 |
| fi |
| fi |
|
|
| echo ">> Setup complete. SMAL model: $SMAL_PKL" |
| echo ">> Render with: python scripts/render_smal_multiview.py --bite-root $BITE_ROOT ..." |
|
|