How keejkrej/sam3 works
SAM 3 is a promptable image and video segmentation model: users provide text or visual prompts and receive object masks, boxes, and scores, with video sessions supporting tracking and interactive refinement. The model builder assembles image and tracking components; video inference coordinates frame propagation and detection/tracking updates. Other major branches provide an LLM-assisted agent, model training, and benchmark evaluation. Relationships are limited to README statements and SOURCE INDEX references or shown calls; unsampled internals are represented at subsystem level.
Main entry points: model_builder.py Model Builder · sam3_video_predictor.py Video Predictor · trainer.py Training Loop · sam3_image_processor.py Image Processor
Components 19
Prompted Inference
- Image Processor
sam3/model/sam3_image_processor.py - Video Predictor
sam3/model/sam3_video_predictor.py - Video Inference
sam3/model/sam3_video_inference.py
Model Architecture
- Model Builder
sam3/model_builder.py - Image Model
sam3/model/sam3_image.py - Geometry Encoding
sam3/model/geometry_encoders.py - Detection Decoder
sam3/model/decoder.py - Video Tracker
sam3/model/sam3_tracking_predictor.py - Video Coordination
sam3/model/sam3_video_base.py
Segmentation Agent
- Agent Inference
sam3/agent/inference.py - Agent Core
sam3/agent/agent_core.py - SAM3 Client
sam3/agent/client_sam3.py
Model Training
- Training Loop
sam3/train/trainer.py - Image Dataset
sam3/train/data/sam3_image_dataset.py - Training Losses
sam3/train/loss/loss_fns.py - Query Matcher
sam3/train/matcher.py
Benchmark Evaluation
- Evaluation Suite
sam3/eval - Video Evaluators
sam3/eval/saco_veval_evaluators.py
Other components
- User
Connections 19
- User → Image Processor: prompts image
README.md - Image Processor → Model Builder: uses model
README.md - Image Processor → User: returns masks
README.md - User → Video Predictor: starts session
README.md - Video Predictor → User: returns outputs
README.md - Model Builder → Image Model: builds
sam3/model_builder.py - Model Builder → Geometry Encoding: configures
sam3/model_builder.py - Model Builder → Detection Decoder: configures
sam3/model_builder.py - Model Builder → Video Tracker: builds
sam3/model_builder.py - Model Builder → Video Predictor: builds
sam3/model_builder.py - Video Predictor → Video Inference: dispatches
sam3/model_builder.py - Video Inference → Video Coordination: uses coordination
sam3/model/sam3_video_inference.py - Video Coordination → Video Tracker: updates tracker
sam3/model/sam3_video_base.py - Agent Inference → Agent Core: invokes
sam3/agent/inference.py - Agent Core → SAM3 Client: uses client
- Training Loop → Image Dataset: trains on
- Training Loop → Training Losses: computes loss
- Training Loop → Query Matcher: matches queries
- Video Evaluators → Evaluation Suite: uses evaluation tools
sam3/eval/saco_veval_evaluators.py