DanceIR: Dance Information Retrieval Toolbox
A modular Python toolbox for dance motion analysis, feature extraction, and tempo estimation from 2D keypoint data.
This toolbox implements a kinematic anchor–based framework for estimating musical tempo from dance movement, as described in the following manuscript currently under review:
Estimating Music Tempo from Dance Movement Using Kinematic Rhythmic Anchors (under review)
Features
- Multi-anchor dance tempo estimation: Robust dance tempo estimation using multiple body segments (hands, feet, torso)
- COCO-format keypoint support: Load and process standard 2D keypoint formats
- Feature extraction: Center of mass, anchor detection, and energy-based features
- Signal preprocessing: Detrending, normalization, and filtering utilities
- Evaluation metrics: Octave-invariant metric for dance tempo estimation evaluation
Installation
From PyPI
pip install danceir
From source
git clone https://github.com/sagar0dutta/danceir.git
cd danceir
pip install -e .
Optional dependencies
For demo notebooks and video processing:
pip install danceir[demo]
For development:
pip install danceir[dev]
Quick Start
Basic Tempo Estimation
import numpy as np
from danceir.io import KeypointLoader
from danceir.pipelines import estimate_tempo_from_keypoints
# Load keypoint data (COCO format)
loader = KeypointLoader()
keypoints_data = loader.load_keypoints_pickle("keypoints.pkl")
keypoints_2d = loader.extract_all_keypoints_2d(keypoints_data)
# Shape: (num_frames, num_joints, 2) where last dim is [x, y]
# Estimate tempo
result = estimate_tempo_from_keypoints(
keypoints_2d,
marker_groups=[(9, 10), (15, 16)], # both hands, both feet
axis='y',
use_com=True, # Include torso center of mass
fps=60.0
)
# Get results
tempo_info = result['combined_anchors']
print(f"Estimated tempo: {tempo_info['gtempo']} BPM")
print(f"Best segment: {tempo_info['best_segment']}")
Evaluation
from danceir.evaluation import dance_tempo_evaluation
# Compare estimated tempo with reference
ref_tempo = 120.0 # Ground truth BPM
est_tempo = tempo_info['gtempo']
eval_result = dance_tempo_evaluation(ref_tempo, est_tempo)
print(f"Accuracy: {eval_result.accuracy}%")
print(f"Mean DTS: {eval_result.mean_dts:.3f}")
Keypoint Format
DanceIR expects COCO-format 2D keypoints:
- Input shape:
(num_persons, num_frames, num_joints, 3) - Last dimension:
[x, y, confidence] - Joint indices: 0=nose, 1=left_eye, ..., 9=left_wrist, 10=right_wrist, ..., 15=left_ankle, 16=right_ankle
API Overview
Main Pipeline
estimate_tempo_from_keypoints(): High-level tempo estimation from keypoints
I/O
KeypointLoader: Load COCO-format keypoint data from pickle filesAnchorIO: Save/load anchor sequencesPathManager: Manage data paths
Features
compute_com_variants(): Compute center of mass (hips, shoulders, torso)detect_segment_anchor(): Detect anchors from motion signalsAnchorExtractor: High-level anchor extraction interfaceEnergyExtractor: Energy-based feature extraction
Analysis
estimate_dance_tempo(): Multi-anchor tempo estimationcompute_tempogram(): Compute tempogram from anchor signalscompute_alignment(): Align signals with sinusoidal templates
Evaluation
dance_tempo_evaluation(): Compute Octave-invariant metrics
Requirements
- Python >= 3.8
- numpy >= 1.20.0
- scipy >= 1.7.0
- librosa >= 0.9.0
Documentation
Full documentation:
Examples
See the demo/ directory for Jupyter notebook examples:
- Demo.ipynb: Complete tutorial with tempo estimation from keypoint files and video processing with MediaPipe pose estimation
- Basic tempo estimation from keypoint files
- Video processing with MediaPipe pose estimation
The demo notebook demonstrates:
- Loading COCO-format keypoint data
- Extracting multi-anchor features (hands, feet, torso)
- Running tempo estimation pipeline
- Evaluating results with reference tempos
- Processing videos with MediaPipe for pose estimation
License
MIT License - see LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Issues
Report bugs or request features on GitHub Issues.
Author
Sagar Dutta - sagar0dutta@gmail.com
Metadata
Release files for danceir 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| danceir-1.0.0.tar.gz | 34.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| danceir-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 76.6 kB
Release files / danceir-1.0.0.tar.gz
| Download URL | danceir-1.0.0.tar.gz |
|---|---|
| Size | 34.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9d51c07942fac48067ce7717c94ed42d6668d53e0808e09cc01ba6a78b6fb2eb
|
|
BLAKE2b-256 checksum How to use checksums |
082834cdab5bde44e53615759871c1e58e9a415c745c401feaa33c54054b6129
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.9
|
Release files / danceir-1.0.0-py3-none-any.whl
| Download URL | danceir-1.0.0-py3-none-any.whl |
|---|---|
| Size | 41.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
986677b9f8c412b68eff3176bfed45434165a90c1e22796e9378f7d5e174e7f2
|
|
BLAKE2b-256 checksum How to use checksums |
369d3d3858aaa76c2ea6dbe5fbb9948023928ef79b22d025c77209934f836896
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.9
|