Skip to main content

pybvh-ml

PyPI version Python Tests Docs License: MIT

ML bridge layer for pybvh — turn motion capture data into training-ready inputs for skeleton-based ML models.

Status: pre-1.0. Minor versions can include breaking API changes; see CHANGELOG.md for migration notes.

Documentation · Quick Start · Gallery — every concept, one picture each · Find a function · User Guide · Tutorials

Features

  • Tensor packing to (C, T, V), (T, V, C), and flat (T, D) layouts with round-trip unpacking.
  • Array-level augmentation in quaternion, 6D, axis-angle, rotmat, and Euler — keyword-only, no Bvh round-trip, with composable pipelines and reproducible per-epoch seeding.
  • Preprocessing pipelines — BVH directory → on-disk dataset (.npz / .hdf5) with skeleton-aware harmonization for heterogeneous corpora and dataset-wide z-score normalization.
  • Skeleton-graph metadata — edge lists, body-part partitions, L/R joint pairs for GCN and Transformer models.
  • Optional PyTorch integrationMotionDataset / OnTheFlyDataset / collate_motion_batch with variable-length padding.

Philosophy

pybvh-ml is the layer between pybvh (which parses BVH files and does rotation math) and your model (which consumes tensors). It handles the data plumbing — tensor layout, augmentation, preprocessing, dataset construction — without making assumptions about your model or task. All core functions use NumPy; PyTorch is optional.

It replaces the ~150 lines of preprocessing, augmentation, and dataset-class boilerplate that most BVH-based ML pipelines reinvent. Composable enough to use one piece at a time (just the packer, just the augmentor); opinionated enough to give you a working data loader in a dozen lines.

Installation

pip install pybvh-ml

This pulls in pybvh >= 0.8.1, < 0.9 automatically — pybvh-ml 0.5 tracks pybvh 0.8's API (short representation tokens, radians-first parameters).

With optional dependencies:

pip install "pybvh-ml[torch]"    # PyTorch Dataset classes
pip install "pybvh-ml[hdf5]"     # HDF5 output support

Quick Start

import pybvh_ml

# Preprocess a directory of BVH files into a training-ready .npz.
summary = pybvh_ml.preprocess_directory(
    "walks/", "train.npz", representation="6d",
)
print(f"{summary['num_clips']} clips, "
      f"{summary['skeleton_info']['num_joints']} joints")

# Load back: per-clip arrays, normalization stats, skeleton metadata.
data = pybvh_ml.load_preprocessed("train.npz")
root_pos = data["clips"][0]["root_pos"]      # (F, 3)
joint_rot = data["clips"][0]["joint_rot"]    # (F, J, 6) for 6D
mean, std = data["mean"], data["std"]        # for input normalization

# One clip travels as a MotionArrays — what every augmentation and packer takes.
arrays = pybvh_ml.MotionArrays(root_pos=root_pos, joint_rot=joint_rot)
tensor = pybvh_ml.pack_to_ctv(arrays)        # (C, T, V) for a GCN

From there: runtime augmentation in your data loader, PyTorch Datasets with worker-safe per-epoch seeding, and skeleton graph metadata for GCNs — the documentation covers each piece.

Tutorials

Runnable end-to-end notebooks in tutorials/:

  1. End-to-end pipeline — BVH directory → preprocess → MotionDataset with augmentation → tiny MLP classifier.
  2. Augmentation visualized — every augmentation before/after on a real skeleton, plus set_epoch reproducibility.
  3. Heterogeneous preprocessing — mixing skeletons, frame rates, and up-axes robustly.

Notebooks execute in CI via pytest --nbmake tutorials/, so they can't silently rot.

Stability and versioning

pybvh-ml is in 0.x — expect breaking changes between minor versions.

We treat 0.x as design space: when a past choice turns out to be wrong, we fix it at the root rather than carry scar tissue forward. No deprecation cycles, no compatibility shims; each release ships a single clean migration path, documented in the CHANGELOG. If you depend on pybvh-ml from production code, pin to an exact version (pybvh-ml==0.5.0) and read the upgrade notes before bumping.

This will change at 1.0: from then on, pybvh-ml will commit to strict semver — no breaking changes within a major version, deprecation warnings (at least one minor release) before any future removal. Until 1.0, "make the library better" wins over "preserve the old behavior."

Requirements

  • Python >= 3.9
  • pybvh >= 0.8.2, < 0.9
  • NumPy >= 1.21

Optional: PyTorch >= 2.0 (pip install "pybvh-ml[torch]"), h5py >= 3.0 (pip install "pybvh-ml[hdf5]").

Development

pip install "pybvh-ml[dev]"
pytest tests/                             # unit tests
pytest --nbmake tutorials/                # tutorial notebook execution
mkdocs serve                              # docs preview (pip install "pybvh-ml[docs]")

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pybvh_ml-0.5.0.tar.gz (73.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pybvh_ml-0.5.0-py3-none-any.whl (78.7 kB view details)

Uploaded Python 3

File details

Details for the file pybvh_ml-0.5.0.tar.gz.

File metadata

  • Download URL: pybvh_ml-0.5.0.tar.gz
  • Upload date:
  • Size: 73.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pybvh_ml-0.5.0.tar.gz
Algorithm Hash digest
SHA256 2981bb9f681c1e807b6a7fa6de7b4e858b7ee51349e55da5565718652eb81067
MD5 9ff0a6937cc27337f5feddb6ca967443
BLAKE2b-256 1f2e71b5f752f5e2ad92f52b63c317b560812960ce6a8098cdd8e91465ab00dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for pybvh_ml-0.5.0.tar.gz:

Publisher: publish.yml on VictorS-67/pybvh-ml

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pybvh_ml-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: pybvh_ml-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 78.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pybvh_ml-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aaffa6e762ea069fff1e02881bb498211bbfad25412a599f05cdef322e7e73ca
MD5 94d0f74f61e2b0a5744c343f54ff56f0
BLAKE2b-256 1bf01cf31a7271081b068dc6fb3efddcc55375a31923d54e5222e275f2debfe5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pybvh_ml-0.5.0-py3-none-any.whl:

Publisher: publish.yml on VictorS-67/pybvh-ml

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.6.0

2 files

This release

0.5.0 This release

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page