Skip to main content

TraceME Pipeline

TraceME is a video tracking pipeline that runs SAM2 on frame sequences, produces per-frame CSV summaries, and exports annotated videos.

What You Get

  • Annotated MP4 outputs per chunk (and a merged MP4).
  • Per-frame CSVs per chunk (and a merged CSV).
  • A CLI for running the pipeline over frame folders and prompt YAMLs.

Requirements

  • Python 3.12+
  • SAM2 (installed automatically via pip)
  • CUDA GPU recommended for speed (CPU is supported but slow)

Install (PyPI)

pip install traceme-pipeline

Checkpoints (Auto-Download)

TraceME automatically downloads the required SAM2 checkpoint on first run if it is missing. By default, checkpoints are stored in:

~/.cache/traceme/sam2/checkpoints

You can also pre-download all checkpoints:

traceme-download-checkpoints

To change the checkpoint location:

  • SAM2_CHECKPOINT_DIR=/path/to/checkpoints

To disable auto-download:

  • TRACEME_AUTO_DOWNLOAD=0

Dev Helper (SAM2 + Checkpoints)

If you prefer a local clone of SAM2 (for development), you can still use:

make install

This creates a venv, installs TraceME in editable mode, clones SAM2 into third_party/sam2, and downloads checkpoints.

Configure SAM2 (optional)

If SAM2 lives somewhere else, set:

  • SAM2_ROOT=/path/to/sam2 (should contain sam2/ and checkpoints/)
  • SAM2_MODEL=tiny|small|base_plus|large|sam3 (default: large)

SAM3 (optional)

The pipeline can also run Meta's SAM3 tracker with the same points/boxes prompt workflow:

pip install 'traceme-pipeline[sam3]'   # requires Python >= 3.12
traceme -i frames/ -o out/ -p prompts.yaml --model sam3

The sam3.pt checkpoint is resolved through the same logic as the SAM2 checkpoints (SAM2_CHECKPOINT, SAM2_CHECKPOINT_DIR, or the default cache dir), but it is not auto-downloaded: it is gated on Hugging Face, so log in with hf auth login, download it from the facebook/sam3 repo, and place it in your checkpoint directory as sam3.pt.

Usage

Run the pipeline:

traceme -i /path/to/frames -o /path/to/output -p /path/to/prompts.yaml

Generate a tasks file for batch runs:

traceme-gen-tasks /path/to/root -o tasks.tsv

Prompt YAML Format

Prompt files must contain a top-level prompts list. See src/traceme/prompts/parser.py for the exact schema and examples.

Outputs

Given frame_dir=/data/frames/clipA, outputs are:

  • /output/clipA.csv (merged CSV)
  • /output/clipA.mp4 (merged annotated video; one color and id: label per tracked object; exactly one video frame per input frame, so video frame N corresponds to global_frame_idx N)
  • /output/clipA_run_summary.json (run status, processed/resumed/failed chunk ids, totals)
  • /output/clipA_tmp/ (intermediate chunk files; removed if --del_tmp is set). Chunk folders contain symlinks to the original frames (falling back to copies on filesystems without symlink support), so chunking costs almost no disk space.

CSV columns: chunk_id, global_frame_idx, in_chunk_idx, obj_id, area_px, centroid_x, centroid_y, bbox_x, bbox_y, bbox_w, bbox_h. Frames with no tracked objects produce a single row with an empty obj_id and area_px=0. If an object is tracked but the model loses its mask for a given frame (empty prediction), every stat column for that row is -1.

Saving Masks (for shape analysis)

Pass --save-masks to persist every object's binary mask, bit-packed, into /output/clipA_masks.npz — one merged archive per video (per-chunk masks are written alongside each chunk's CSV/video during the run, then combined the same way the merged CSV/video are, so --del_tmp does not remove them). Only non-empty masks are stored.

Reload the mask archive:

import numpy as np
from traceme.sam2.io import _unpack_mask

data = np.load("clipA_masks.npz", allow_pickle=True)
for gidx, oid, packed, shp in zip(
    data["global_frame_idx"], data["obj_id"], data["packed"], data["shape"]
):
    mask = _unpack_mask(packed, tuple(shp))  # bool array, shape (H, W)
    # e.g. shape descriptors via skimage:
    # from skimage.measure import regionprops, label
    # props = regionprops(label(mask))[0]
    # props.eccentricity, props.perimeter, props.solidity, ...

Resume & Failures

  • Completed chunks are marked in the tmp folder; re-running the same command skips them and continues from the first incomplete chunk. Use --no-resume to reprocess everything.
  • If any chunk fails, the pipeline still merges what it has, marks the run "partial" in the run summary, keeps the tmp folder (even with --del_tmp), and exits with code 1. Re-run the same command to retry only the failed chunks.

Troubleshooting

  • If SAM2 configs or checkpoints are missing, TraceME will raise a clear error with the expected paths.
  • Set HYDRA_FULL_ERROR=1 for detailed SAM2 errors.

License

See LICENSE.

Download files

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

Source Distribution

traceme_pipeline-0.5.0.tar.gz (42.1 kB view details)

Uploaded Source

Built Distribution

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

traceme_pipeline-0.5.0-py3-none-any.whl (42.8 kB view details)

Uploaded Python 3

File details

Details for the file traceme_pipeline-0.5.0.tar.gz.

File metadata

  • Download URL: traceme_pipeline-0.5.0.tar.gz
  • Upload date:
  • Size: 42.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for traceme_pipeline-0.5.0.tar.gz
Algorithm Hash digest
SHA256 b95ad5ec28f99beee6c2fd2ec6f89473ae8162c08870de6db8421d5b7ea8b286
MD5 7c10ccf22aa1397efe068878dcaf5b60
BLAKE2b-256 51249373b8e72eaca1d85b64157593eed9ca3e226897e484f6e43ee32e8143a8

See more details on using hashes here.

Provenance

The following attestation bundles were made for traceme_pipeline-0.5.0.tar.gz:

Publisher: publish.yml on StevetheGreek97/TraceME

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

File details

Details for the file traceme_pipeline-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for traceme_pipeline-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 71c73d1ba448c6929132b813e7a85d0af8bcfd55bda54c43c5486b8175be887a
MD5 25140a8c81ddf3452a8d0cfa1b377ff7
BLAKE2b-256 2b83e4364dd00f903d3cebb95a700004b44c8abf0ad9de3d9bfb9e460131f9dd

See more details on using hashes here.

Provenance

The following attestation bundles were made for traceme_pipeline-0.5.0-py3-none-any.whl:

Publisher: publish.yml on StevetheGreek97/TraceME

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

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

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