musclemap-data is the data-generation stage of the MuscleMap thesis pipeline:
- Load Motion-X++ SMPL-X motion (
[T, 322]) - Convert to OpenSim coordinates and run static optimization
- Save muscle activations and aligned text metadata for model training
This repo is Project 1 of 3:
musclemap-data(this project): motion -> muscle activation datasetmusclemap-model(future): text -> muscle activations (fine-tuned MotionGPT)musclemap-eval(future): benchmarking and comparisons
Project 2 is expected to train from this project's output_dataset/ artifact layout (described below).
- Miniforge / Anaconda / Micromamba (
condaonPATH) - Python
3.11from conda (environment.yml) - Platform support:
- macOS arm64 / x86_64
- Linux x86_64
- Windows x86_64
cd /path/to/musclemap-dataFrom the repo root:
conda env create -f environment.yml
conda activate musclemap-data
python -m pip install -e .The env name is musclemap-data (see name: in environment.yml). If it already exists:
conda env update -f environment.yml --prune
conda activate musclemap-data
python -m pip install -e .pip install -e . installs the src package in editable mode (minimal pyproject.toml + setuptools). Pure conda cannot replace this one line without vendoring the package layout.
OpenSim comes from the opensim-org channel; numerical stacks come from conda-forge; pyrender, torch, smplx, and rerun-sdk are installed via the pip: subsection (still inside the same conda env).
Place OpenSim model files under models/ (default points to models/Rajagopal2016.osim).
For optional notebook mesh preview, download official SMPL-X model files and set:
paths.smplx_model_folderto the parent directory containingsmplx/- expected layout example:
<folder>/smplx/SMPLX_NEUTRAL.npz
- expected layout example:
python scripts/download_dataset.py --config config.yamlUseful options:
--subset IDEA400(repeatable)--modality motion --modality text_seq --modality text_frame(repeatable)--yes(non-interactive where applicable)
python scripts/setup_check.py --config config.yamlThis script validates imports and writes:
paths.opensim_python_exepaths.opensim_conda_env
Use --dry-run to inspect without writing.
Use notebooks/01_explore_and_tune.ipynb to:
- inspect motion/text samples
- preview original and reconstructed motion with multiple backends:
- Rerun (
build_rerun_smplx_animation,animate_motion_interactive) - Dash/Plotly (
show_dash_smplx_motion,show_dash_app)
- Rerun (
- run one-sequence OpenSim pipeline with progress bars
- inspect solver metrics and activation plots
Use the musclemap-data conda kernel for Jupyter (same env as OpenSim and all deps). After conda activate musclemap-data and pip install -e ., register once:
conda activate musclemap-data
cd /path/to/musclemap-data
python -m pip install -e .
python -m ipykernel install --user --name musclemap-data --display-name "musclemap-data"Select that kernel in the notebook UI. If import opensim still fails, run python scripts/setup_check.py --config config.yaml so paths.opensim_python_exe matches this interpreter, or set DRY_RUN=True in the pipeline cell to skip OpenSim.
Recommended comparison workflow in notebook:
# 1) Original source motion (raw SMPL-X)
from src.visualization import show_dash_smplx_motion, show_dash_app
show_dash_smplx_motion(
smplx_motion=motion, # from load_sample(sample)["motion"]
config=cfg,
inline=True,
)
# 2) Reconstructed motion from OpenSim coordinates + activations
mot_path = (tmp_root / sample.id / "viz_coords.mot").resolve()
show_dash_app(
mot_path=mot_path,
activations=acts,
muscle_names=muscle_names,
config=cfg,
smplx_motion=motion, # optional overlay of raw SMPL-X joints
inline=True,
)Run full (or limited) dataset processing:
python scripts/run_batch.py --config config.yamlCommon flags:
--workers Noverridebatch.num_workers--limit Nprocess first N remaining samples--dry-runskip OpenSim and generate synthetic activations--reset-checkpointclear progress checkpoint before run
Batch artifacts:
output_root/batch.logoutput_root/batch_summary.jsonoutput_root/failed_files.log(on failures)
Generated dataset layout:
output_dataset/
<sequence_id>/
activations.npy # float32, [T, N_muscles]
smplx_322.npy # float32, [T, 322] passthrough
semantic_label.txt # sequence-level text description
pose_descriptions/
<frame_idx>.txt # per-frame text
muscle_names.json # list[str], len == N_muscles
metadata.json # dict[id -> {T, fps, source, n_muscles, status}]
Important invariants:
activations.npyis alwaysfloat32- output FPS comes from config (
output.output_fps) - muscle count is inferred from names (
muscle_names.json)
Main sections:
paths:- dataset root (
motionx_root) - output root (
output_root) - OpenSim model path (
opensim_model) - OpenSim python executable (
opensim_python_exe) - temporary dir (
temp_dir) - optional regressor path (
smplx_to_opensim_regressor) - optional SMPL-X mesh model folder (
smplx_model_folder)
- dataset root (
dataset:- subdirectories for motion / sequence text / frame text
- source fps
download:- Google Drive folder id, subset/modality toggles, cache controls
conversion:- target/output FPS, filtering, velocity clamp, ROM limits
ik,rra,static_optimization:- OpenSim stage settings and solver controls
- optional solver log/metric persistence
visualization:- Rerun settings (
rerun_app_id,rerun_recording_id,rerun_spawn) - Dash settings (
dash_port,dash_inline,dash_scene_bg, etc.) - stick figure camera and 3D settings (for helper transforms/bounds)
- mesh preview parameters
- Rerun settings (
output:- output fps and output file toggles
batch:- retries, worker count, checkpoint filename
This project can optionally run OpenSim RRA (Residual Reduction Algorithm), but it is disabled by default (rra.enabled: false) because it is typically impractical for large-scale Motion-X++ processing:
- Runtime cost: RRA adds a full forward dynamics pass (often multiple iterations), which dominates wall-clock time when processing thousands of clips.
- Missing experimental signals: robust RRA normally relies on external loads / GRFs (force plates) and better-tuned model conditions; Motion-X++ provides kinematics only, so RRA can be fragile or require heavy assumptions.
With RRA disabled, the effective pipeline used for dataset generation is:
SMPL-X motion → coordinates .mot → IK → Static Optimization → activations.npy
Run full test suite:
conda activate musclemap-data
pytest tests/ -q- Ensure OpenSim is installed in a conda env
- Run
python scripts/setup_check.py --config config.yaml - Confirm notebook/CLI is using the intended Python executable
- Re-run
scripts/download_dataset.py - Use cached zips under
.download_cache/ - Follow manual fallback instructions printed by the script
- Re-run
scripts/run_batch.py(checkpoint resumes automatically) - Use
--reset-checkpointonly if you want to restart from scratch
- Set
cfg["visualization"]["rerun_spawn"] = Falseto render in-cell viarr.notebook_show(). - Ensure the active notebook kernel has
rerun-sdkinstalled.
- Pass
inline=Truetoshow_dash_app(...)/show_dash_smplx_motion(...). - For robust inline support, install
jupyter-dash; otherwise the code falls back to a browser tab.
- Mesh deps are included in
environment.yml(torch, smplx); runconda env update -f environment.yml --prune - Set
paths.smplx_model_foldercorrectly (parent ofsmplx/)