Skip to main content

Real-time (GPU) pose estimation pipeline with 🤗 Transformers

Project description

RT-Pose

Real-time (GPU) pose estimation pipeline with 🤗 Transformers

Installation

  1. [Optional] It's recommended to run with uv for faster installation. First, install uv:
pip install uv
  1. Install rt_pose (you can ignore uv in case you want to install with pure pip)
uv pip install rt-pose        # with minimal dependencies
uv pip install rt-pose[demo]  # with additional dependencies to run `scripts/` and `notebooks/`

Quick start

Python snippet

import torch
from rt_pose import PoseEstimationPipeline

# Load pose estimation pipeline
pipeline = PoseEstimationPipeline(
    object_detection_checkpoint="PekingU/rtdetr_r50vd_coco_o365",
    pose_estimation_checkpoint="usyd-community/vitpose-plus-small",
    device="cuda",
    dtype=torch.bfloat16,
    compile=False,  # or True to get more speedup
)

# Run pose estimation on image
output = pipeline(image)

# output.person_boxes_xyxy (`torch.Tensor`): 
#   of shape `(N, 4)` with `N` boxes of detected persons on the image in (x_min, y_min, x_max, y_max) format
# output.keypoints_xy (`torch.Tensor`):
#   of shape `(N, 17, 2)` with 17 keypoints per each person
# output.scores (`torch.Tensor`): 
#   of shape (N, 17) with corresponding scores (aka confidence) for each keypoint

# Visualize with supervision/matplotlib/opencv
# see ./scripts/run_on_image.py

Other object detection checkpoints on the Hub:

Other pose estimation checkpoints on the Hub:

Run pose estimation on image

  • --input can be URL or path
python scripts/run_on_image.py \
    --input "https://res-3.cloudinary.com/dostuff-media/image/upload//w_1200,q_75,c_limit,f_auto/v1511369692/page-image-10656-892d1842-b089-4a7a-80f1-5be99b2b3454.png" \
    --output "results/image.png" \
    --device "cuda:0"

Run pose estimation on video

  • --input can be URL or path
  • --dtype it's recommended to run in bfloat16 precision to get the best precision/speed tradeoff
  • --compile you can compile models in the pipeline to get even more speed up (x2), but compilation can be quite long, so it makes sense to activate for long videos only.
python scripts/run_on_video.py \
    --input "https://huggingface.co/datasets/qubvel-hf/assets/blob/main/rt_pose_break_dance_v1.mp4" \
    --output "results/rt_pose_break_dance_v1_annotated.mp4" \
    --device "cuda:0" \
    --dtype bfloat16

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

rt_pose-0.0.1.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

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

rt_pose-0.0.1-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file rt_pose-0.0.1.tar.gz.

File metadata

  • Download URL: rt_pose-0.0.1.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for rt_pose-0.0.1.tar.gz
Algorithm Hash digest
SHA256 f718ca7c9bb323fa18e5206fc9f2923d3d37dfa338a00f376935bc1ba1dabec1
MD5 42fa3d531080ef25fad73e5a2dab8c0b
BLAKE2b-256 f7a8897a7017a6f9e706e24154e99fce5bf65f470c445ca69578573ab8211242

See more details on using hashes here.

Provenance

The following attestation bundles were made for rt_pose-0.0.1.tar.gz:

Publisher: python-publish.yml on qubvel/rt-pose

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

File details

Details for the file rt_pose-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: rt_pose-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for rt_pose-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 92641cd6fb35bf35560a67645e8f5f8704fd029b4936dc60321bb239fd002be5
MD5 8bae27b6de30571b7e2c5a6cff750e6d
BLAKE2b-256 d97dc455e58531c51de218e80299ddfe09439edbf840683ae1a68c8033035557

See more details on using hashes here.

Provenance

The following attestation bundles were made for rt_pose-0.0.1-py3-none-any.whl:

Publisher: python-publish.yml on qubvel/rt-pose

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

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