SpinePose Inference Library
Python Library
Lightweight CLI and Python API for running SpinePose models today, with SimSpine inference support coming next.
The SpinePose Inference Library provides a simple way to run spine-aware pose estimation from Python or the command line. It currently supports the released SpinePose ONNX models and will also host upcoming SimSpine inference models.
Installation
Recommended Python version: 3.9-3.12
pip install spinepose
On Linux or Windows with CUDA:
pip install spinepose[gpu]
CLI Usage
usage: spinepose [-h] (--version | --input_path INPUT_PATH) [--vis-path VIS_PATH] [--save-path SAVE_PATH] [--mode {xlarge,large,medium,small}] [--nosmooth] [--spine-only]
SpinePose Inference
options:
-h, --help show this help message and exit
--version, -V Print the version and exit.
--input_path INPUT_PATH, -i INPUT_PATH
Path to the input image or video
--vis-path VIS_PATH, -o VIS_PATH
Path to save the output image or video
--save-path SAVE_PATH, -s SAVE_PATH
Save predictions in OpenPose format (.json for image or folder for video).
--mode {xlarge,large,medium,small}, -m {xlarge,large,medium,small}
Model size. Choose from: xlarge, large, medium, small (default: medium)
--nosmooth Disable keypoint smoothing for video inference (default: enabled)
--spine-only Only use 9 spine keypoints (default: use all 37 keypoints)
Example:
spinepose --input_path path/to/video.mp4 --save-path output_path.json --spine-only
Python API
import cv2
from spinepose import SpinePoseEstimator
estimator = SpinePoseEstimator(device='cuda')
image = cv2.imread('path/to/image.jpg')
keypoints, scores = estimator(image)
visualized = estimator.visualize(image, keypoints, scores)
cv2.imwrite('output.jpg', visualized)
Simplified helper API:
from spinepose.inference import infer_image, infer_video
results = infer_image('path/to/image.jpg', vis_path='output.jpg')
results = infer_video('path/to/video.mp4', vis_path='output_video.mp4', use_smoothing=True)
Model Availability
- SpinePose models: available now.
- SimSpine models: planned for the next release.