← all repositories
rwightman/posenet-python

PoseNet escapes the browser: a Python port with a numpy speed hack

Google's real-time pose estimation model, originally TensorFlow.js, got dragged into Python-land and then partially rescued from JavaScript's performance sins.

posenet-python
Velocity · 7d
+0.2
★ / day
Trend
steady
star history

What it does

This repo ports Google’s PoseNet — the real-time human pose estimation model from TensorFlow.js — into pure Python. It downloads the original model weights, converts them on the fly, and runs multi-pose detection through a set of demo scripts for images, webcams, or benchmarking. You’ll get back body keypoints and skeleton overlays.

The interesting bit

The author started with a literal translation of the JavaScript post-processing code and watched performance crater to ~30 fps on a GTX 1080+. The fix: vectorized numpy/scipy rewrites of the hot paths, suffixed _fast, which clawed back roughly 3× the throughput. It’s a small case study in why “just port it” often isn’t enough — the boring post-processing can swallow your GPU gains whole.

Key highlights

  • Pure Python implementation, multi-pose only; single-pose not included
  • Base MobileNet inference hits 200–300 fps on a GTX 1080 Ti; fast post-processing keeps 90–110 fps
  • Three demos: image batch processing, webcam live overlay, minimal benchmark
  • Model weights auto-downloaded from TensorFlow.js and converted on first run
  • Supports four model variants (depth multipliers 50, 75, 100, 101)

Caveats

  • Requires specific OpenCV version (3.4.x pip release); conda opencv and 4.x break video capture or drawing bindings
  • Development environment is dated: TensorFlow 1.12.0, Python 3.6, last tested 2019
  • Post-processing still has edge loops the author flags for further optimization; a C/Cython rewrite would go faster
  • No batch inference yet; demos are “very basic and could definitely be improved”

Verdict

Worth a look if you need PoseNet in a Python pipeline and can tolerate some 2019-era dependency friction. Skip it if you want maintained, modern code — the PyTorch successor repo or newer frameworks have likely lapped this.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.