Skip to main content

SemanticKinematics

Video to flow physics: detect objects in video with a fine-tuned Mask R-CNN, track them across frames, calibrate pixel coordinates to the world, and measure Lagrangian flow features (vorticity, FTLE, LAVD, and more) from the tracked group using Lagrangian Gradient Regression (LGR).

This is the software behind Harms, Brunton & McKeon, Semantic kinematic analysis from groups of tracked objects (Physica D 496, 135335, 2026; doi:10.1016/j.physd.2026.135335; preprint arXiv:2408.16190).

video ──> detect (tiled Mask R-CNN) ──> track (cross-correlation) ──> calibrate
      ──> kinematics (LGR: velocity gradients + Lagrangian metrics) ──> render

The pipeline is config-driven (one YAML file per experiment), every stage is individually runnable and cached under content-hash keys, and detection/tracking schemes are pluggable registries — a custom detector is ~10 lines of code (see semantic_kinematics.detect.Detector).

Status

Modernized from the original research code (kept verbatim under legacy/ until the parity review completes). This is an alpha release: interfaces may still change.

Installation

Python >= 3.12. Install torch first so you control the CUDA/CPU choice:

# CUDA (pick the index matching your driver) ...
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu126
# ... or CPU-only
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu

pip install semantic-kinematics

This also installs Lagrangian Gradient Regression (lagrangian-gradient-regression on PyPI, imported as lgr).

The SAM-based render overlays are optional. They need Meta's Segment Anything, which Meta does not publish on PyPI, and a 2.45 GB checkpoint:

pip install "segment-anything @ git+https://github.com/facebookresearch/segment-anything.git@dca509fe793f601edb92606367a655c15ac00fdf"

To work on the package itself, clone the repository and run pip install -e ".[dev]".

Quickstart

semkin models fetch maskrcnn_lab_debris
semkin run configs/examples/alldebris_short.yaml

or python examples/quickstart.py. Useful commands: semkin validate <cfg> (schema + registry + model checks, no compute), semkin info <cfg> (stage keys and cache status), semkin registry (everything pluggable), semkin run -f track <cfg> (force one stage and downstream).

Model zoo

Weights are GitHub Release assets (tag models-v1), fetched on demand into a local cache and SHA256-verified. semkin models list shows cache status.

Name Architecture Domain Epochs
maskrcnn_pond_debris Mask R-CNN ResNet50-FPN v2 field pond debris (TurtlePonds, 35 mm) 150
maskrcnn_lab_debris Mask R-CNN ResNet50-FPN v2 lab debris (SplitFlow) 100
maskrcnn_sheep_flow Mask R-CNN ResNet50-FPN v2 sheep herds (aerial) 100
sam_vit_h SAM ViT-H stock upstream checkpoint (Meta CDN) —

Each registry entry pins the training-time inference settings (builder_kwargs) recovered from the original models — reproducing them is part of reproducing the paper. See docs/models.md and docs/specs/model_registry.md.

Data and outputs

  • Committed: two small fixture clips (data/videos/) and 44 hand-annotated training frames (data/annotations/turtle_ponds/). Nothing bigger enters git (enforced by a test).
  • Outputs: artifacts/<run>/<stage>/<key>/ with a manifest per stage; see docs/specs/pipeline_stages.md.
  • Model cache: platformdirs.user_cache_dir("semantic_kinematics") — %LOCALAPPDATA%\semantic_kinematics\semantic_kinematics\Cache on Windows, ~/.cache/semantic_kinematics on Linux; override SEMKIN_CACHE_DIR. SEMKIN_OFFLINE=1 forbids downloads.

Testing

pytest              # fast suite: unit tests + synthetic end-to-end pipeline
pytest --runslow    # adds real model inference (needs cached models)

See docs/specs/testing.md.

Development

# Windows: creates the venv OUTSIDE OneDrive, installs CUDA torch,
# this package editable, and the local lgr checkout editable.
scripts\dev_setup.ps1              # or -Torch cpu

Point your IDE at %LOCALAPPDATA%\venvs\semkin\Scripts\python.exe. Lint with ruff check src tests examples. House conventions mirror the lgr repo; see docs/specs/index.md.

Citation

See CITATION.cff.

License

MIT — see LICENSE.

Metadata

Release files for semantic-kinematics 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for semantic-kinematics 0.1.0
File Size Uploaded Provenance Actions
semantic_kinematics-0.1.0.tar.gz 109.9 kB With provenance Details for semantic_kinematics-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for semantic-kinematics 0.1.0
File Interpreter ABI Platform Actions
semantic_kinematics-0.1.0-py3-none-any.whl Python 3 none any Details for semantic_kinematics-0.1.0-py3-none-any.whl

Total release size: 209.4 kB

Release files / semantic_kinematics-0.1.0.tar.gz

Download URL semantic_kinematics-0.1.0.tar.gz
Size 109.9 kB
Tags Source
SHA-256 checksum
How to use checksums
aae2435042ef5051d828f63b319ceb0f217692448f0d29941408fa82f6f8d6ac
BLAKE2b-256 checksum
How to use checksums
4438fdc57eb5c107f125762dcbeaec1c7aba3b49dfabcc513597feb9542043c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Release files / semantic_kinematics-0.1.0-py3-none-any.whl

Download URL semantic_kinematics-0.1.0-py3-none-any.whl
Size 99.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
30bcdc521b03fc3458a31d3c3287a9cb0f5c0f3181ed96e594b251ea8ce40b3a
BLAKE2b-256 checksum
How to use checksums
1a1b4b056bd227735d146dd01cc4c42b4d8ad8eb6796081a481d28759f744614
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Security for semantic-kinematics 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for semantic_kinematics-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page