Skip to main content

Library for manipulating pose keypoints

Project description

posecraft

posecraft is a Python package designed to load, manipulate, and transform pose data. It uses PyTorch to handle pose tensors, allowing you to perform operations such as centering, normalizing distances, filling missing values, and more.


Features

  • Pose Loading Load pose data (stored in .npy format) directly into a PyTorch tensor.

  • Transforms A set of classes (inheriting from torch.nn.Module) that can be chained to modify and clean your pose data, including:

    • CenterToKeypoint: Center all keypoints to a chosen reference keypoint.
    • NormalizeDistances: Enforce a fixed distance between two chosen keypoints.
    • FillMissing: Interpolate and fill missing (NaN) keypoints across frames.
    • InterpolateFrames: Resample frames to a uniform number of frames.
    • NormalizeFramesSpeed: Dynamically adjust frames based on the amount of movement.
    • FilterLandmarks: Filter out unwanted landmarks based on a mask.
    • PadTruncateFrames: Pad or truncate the total number of frames.
    • RandomSampleFrames / RandomSampleFrameLegacy: Randomly sample frames with fixed intervals or by chunks.
    • ReplaceNansWithZeros: Replace all NaN values in the tensor with zeros.
    • UseFramesDiffs: Represent each frame as the difference from the previous frame.
    • FlattenKeypoints: Reshape and flatten the keypoints across frames.
  • Animation Built-in functionality to animate the keypoints over time using matplotlib.animation.FuncAnimation.


Installation (From PyPI)

You can install the package directly from PyPI:

pip install posecraft

Installation (From Source)

  1. Clone this repository or add posecraft to your Python environment.
  2. Install dependencies:
    pip install -r requirements.txt
    
  3. (Optional) For development and documentation, navigate to the docs/ folder and install additional requirements.

Usage

Below is a basic example of how to load a pose and apply some transformations:

import torch
from posecraft.Pose import Pose
from posecraft.transforms import CenterToKeypoint, NormalizeDistances

# Load a pose from a .npy file
pose_data = Pose(path="path/to/pose.npy")

# Create a set of transforms
transforms = torch.nn.Sequential(
    CenterToKeypoint(center_keypoint=0),
    NormalizeDistances(indices=(11, 12), distance_factor=0.2)
)

# Apply transforms
transformed_pose = transforms(pose_data.pose)

# Now do something with 'transformed_pose', like visualizing or saving

You can also chain other available transforms (e.g., FillMissing, FilterLandmarks, etc.) depending on your data cleaning or preprocessing needs.

Documentation

Full documentation can be found at https://pedroodb.github.io/posecraft/.

Also, if installed locally, comprehensive documentation can be found under the docs/ folder. This includes:

  • Guides on setting up a development container (.devcontainer).
  • Instructions for running tests (tests/) and CI workflows.
  • Explanation of each transform class and utility function.

To build and view the documentation locally, navigate to the docs/ folder and run:

make html

Then open the generated HTML files from docs/_build/html/.

Contributing

  1. Fork the repository and create a new branch for your contribution.
  2. Make your changes, then open a pull request (PR).
  3. Ensure all tests and documentation checks pass.

Please follow the CODE_OF_CONDUCT.md for guidance on project etiquette and the LICENSE for usage permissions.


Support and Security

For any questions or issues, please see SUPPORT.md. Security concerns should be reported as outlined in SECURITY.md.


License

This project is licensed under the terms of the MIT License.

Project details


Download files

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

Source Distribution

posecraft-1.0.1rc85.post1.tar.gz (302.7 kB view details)

Uploaded Source

Built Distribution

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

posecraft-1.0.1rc85.post1-py3-none-any.whl (283.5 kB view details)

Uploaded Python 3

File details

Details for the file posecraft-1.0.1rc85.post1.tar.gz.

File metadata

  • Download URL: posecraft-1.0.1rc85.post1.tar.gz
  • Upload date:
  • Size: 302.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.3

File hashes

Hashes for posecraft-1.0.1rc85.post1.tar.gz
Algorithm Hash digest
SHA256 28dfe80cd94a77e10abe6abde3f9c0d3a9d9df62ff526f1cda75cb116348bced
MD5 c90999555e76591cf9e7844f9a33f63a
BLAKE2b-256 124df5f902e047a9fc6bde887854a6d998c6e3be11f6a293ceee6202c159e005

See more details on using hashes here.

File details

Details for the file posecraft-1.0.1rc85.post1-py3-none-any.whl.

File metadata

File hashes

Hashes for posecraft-1.0.1rc85.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 ad9eb3c98dee60d6c4f2ab648e564d3760d06b37c2c1e27b9d01b5f714b1928a
MD5 072c97de06e009b8b87000b7ac5866d8
BLAKE2b-256 f1ba178253fa5e383265c342c65f54794cc9c9a7f22b81a3cfb448c8c7ecfa63

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page