How oassal/sam2-labeling-tool works
This is a semi-automatic video/image segmentation labeling tool. Its principal workflow is CLI input → video frame splitting → interactive point annotation → SAM2 mask propagation → optional LabelMe export. The source excerpts establish the orchestration and data handoffs shown here; README-documented capabilities are included where their implementation was not sampled.
Main entry points: main.py Pipeline CLI · utils_labeling.py Point annotation · sam.py Video predictor · labelme_utils.py LabelMe export
Components 14
Labeling workflow
- Pipeline CLI
main.py - Frame splitting
utils_labeling.py - Point annotation
utils_labeling.py - Point label JSON
utils_labeling.py - Object ID mapping
utils_folders.py - Annotation reader
utils_labeling.py
SAM2 segmentation
- SAM2 dispatch
utils_labeling.py - Video predictor
sam.py - Object masks
sam.py
Dataset export
- LabelMe export
labelme_utils.py - Mask polygons
labelme_utils.py - LabelMe dataset
labelme_utils.py
Other components
- Annotator
- SAM2 model
Connections 16
- Annotator → Pipeline CLI: runs
- Pipeline CLI → Frame splitting: splits videos
- Frame splitting → Pipeline CLI: returns splits
- Pipeline CLI → Point annotation: labels each split
- Point annotation → Annotator: collects clicks
- Point annotation → Point label JSON: writes points
- Pipeline CLI → Annotation reader: reads annotations
- Annotation reader → Object ID mapping: maps objects
- Annotation reader → SAM2 dispatch: passes prompts
- SAM2 dispatch → Video predictor: generates masks
- Video predictor → SAM2 model: runs inference
- Video predictor → Object masks: writes masks
- Pipeline CLI → LabelMe export: optionally exports
- LabelMe export → Object masks: reads masks
- LabelMe export → Mask polygons: converts contours
- Mask polygons → LabelMe dataset: writes annotations