#!/usr/bin/env bash # AutoDL audio→motion DATA environment. Does not install a TextOp/OMG trainer. # Usage: bash scripts/setup_autodl_audio_motion.sh [--install|--help] # Default: print plan only. Use a separate venv, never overwrite the active environment. set -euo pipefail PROJECT_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)" ENV_DIR="${HFD_DATA_ENV:-${PROJECT_ROOT}/.venv-hfd-data}" PYTHON_BIN="${HFD_SETUP_PYTHON:-python3.10}" case "${1:---help}" in --help) printf '%s\n' \ '创建独立的数据读取环境(Python 3.10),不安装完整HFD或baseline训练依赖。' \ '安装:bash scripts/setup_autodl_audio_motion.sh --install' \ "环境:${ENV_DIR}" \ '可选:HFD_SETUP_PYTHON=/path/to/python HFD_DATA_ENV=/path/to/new/env' \ 'PyTorch/CUDA、TextOp/OMG、ASR由各baseline项目按自己的版本安装。' \ '读取tar无需torch;若需webdataset迭代,先按baseline要求安装torch。' exit 0 ;; --install) ;; *) printf '%s\n' 'Unknown option; use --help or --install' >&2; exit 2 ;; esac "${PYTHON_BIN}" -c 'import sys; assert sys.version_info[:2] == (3,10), "Please use Python 3.10"' if [[ -e "${ENV_DIR}" ]]; then printf 'Refusing to overwrite existing environment: %s\n' "${ENV_DIR}" >&2 exit 1 fi "${PYTHON_BIN}" -m venv "${ENV_DIR}" "${ENV_DIR}/bin/python" -m pip install --upgrade pip "${ENV_DIR}/bin/python" -m pip install 'numpy==1.26.4' 'soundfile==0.13.1' 'pandas==2.2.3' 'scipy==1.14.1' 'huggingface_hub>=1.0,<2' 'webdataset==1.0.2' "${ENV_DIR}/bin/python" -c 'import numpy, soundfile, pandas, sqlite3; print("Data dependencies OK; no GPU required")' printf '完成。激活:source %q/bin/activate\n' "${ENV_DIR}"