DREAMS-AVATAR / scripts /upload_capture.sh
initialneil's picture
Add P2C1 metadata + SMPL-X + previews
ef97c58 verified
Raw
History Blame Contribute Delete
3.6 kB
#!/usr/bin/env bash
# upload_capture.sh <PxCy> [--extract] [--meta-only] [--no-upload]
#
# One finished capture -> the public HF dataset `initialneil/DREAMS-AVATAR`.
#
# Published set (10): P1C1 P1C2 P2C1 P2C2 P3C1 P3C2 P4C1 P4C2 P5C2 P6C2
# C1 = train, C2 = test. P5/P6 are cross-reenact DRIVING only, so only their C2 ships.
# P5C1 does not exist; P6C1 is excluded on purpose (stage_capture.py refuses both).
#
# 1. stage hardlink frameset-videos/NN.mp4 -> staging/data/<PxCy>/videos/camNN.mp4,
# copy cameras.json, write capture.json
# 2. smplx hmt_seq_out/smplx/*.npz -> staging/data/<PxCy>/smplx.npz (verified lossless)
# 3. previews hmt_seq_out/grid_f*.jpg -> staging/previews/<PxCy>_f*.jpg + preview.jpg
# 4. metadata rebuild staging/previews/metadata.jsonl over ALL staged captures
# 5. upload small files in one commit, then the mp4s via resumable upload_large_folder
#
# The tracker's output dir is only ever READ.
# Re-runnable: safe to re-run after a network drop, the large upload resumes.
#
# ./upload_capture.sh P1C1
# ./upload_capture.sh P2C1 --extract # if frameset-videos/ not unpacked yet
# ./upload_capture.sh P1C1 --meta-only # refresh card/smplx/previews, skip the 2 GiB
set -euo pipefail
CAPTURE="${1:?usage: upload_capture.sh <PxCy> [--extract] [--meta-only] [--no-upload]}"
shift || true
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BASE="$(dirname "$HERE")"
STAGING="${STAGING:-$BASE/staging}"
DATASET_ROOT="${DATASET_ROOT:-/mnt/sdb/degas_project/DEGAS_DATASET}"
PY="${PY:-/home/szj/miniconda3/envs/omni_pose/bin/python}"
LOGDIR="$BASE/logs"; mkdir -p "$LOGDIR"
EXTRACT=""; META_ONLY=""; NO_UPLOAD=""
for arg in "$@"; do
case "$arg" in
--extract) EXTRACT="--extract" ;;
--meta-only) META_ONLY="--meta-only" ;;
--no-upload) NO_UPLOAD=1 ;;
*) echo "unknown flag: $arg" >&2; exit 2 ;;
esac
done
echo "=== [1/5] stage $CAPTURE ==============================================="
"$PY" "$HERE/stage_capture.py" "$CAPTURE" --dataset-root "$DATASET_ROOT" \
--staging "$STAGING" $EXTRACT
echo "=== [2/5] consolidate SMPL-X ==========================================="
# --expect-first-frame 0 is the d=0 guard: every capture's per-frame npz must start at
# frame 0. A source still carrying the old 1-based labelling is refused rather than
# silently published one frame out.
"$PY" "$HERE/consolidate_smplx.py" "$CAPTURE" --dataset-root "$DATASET_ROOT" \
--out "$STAGING/data/$CAPTURE/smplx.npz" --expect-first-frame 0
# capture.json is written before smplx.npz exists on a first run -> refresh it
"$PY" "$HERE/stage_capture.py" "$CAPTURE" --dataset-root "$DATASET_ROOT" \
--staging "$STAGING" >/dev/null
echo "=== [3/5] previews ====================================================="
"$PY" "$HERE/make_previews.py" "$CAPTURE" --dataset-root "$DATASET_ROOT" \
--staging "$STAGING"
echo "=== [4/5] metadata.jsonl + scripts ====================================="
"$PY" "$HERE/build_metadata.py" --staging "$STAGING"
mkdir -p "$STAGING/scripts"
cp -f "$HERE"/*.py "$HERE"/*.sh "$STAGING/scripts/" # ship the pipeline with the data
if [[ -n "$NO_UPLOAD" ]]; then
echo "=== [5/5] upload SKIPPED (--no-upload) ==="
exit 0
fi
echo "=== [5/5] upload to HuggingFace ========================================"
LOG="$LOGDIR/upload_${CAPTURE}_$(date +%Y%m%d_%H%M%S).log"
echo "log: $LOG"
"$PY" "$HERE/hf_upload.py" --staging "$STAGING" --capture "$CAPTURE" $META_ONLY 2>&1 | tee "$LOG"
echo "=== done: https://huggingface.co/datasets/initialneil/DREAMS-AVATAR ==="