tensorflow/models · error · ImportError
The 'sam3' package is not installed or available in python…
Error message
The 'sam3' package is not installed or available in python path. Cannot construct SAM3Detector from checkpoint.
What it means
Import guard in SAM3Detector.from_checkpoint: the sam3 package failed to import at module load time, leaving the sam3_model_builder symbol None. SAM3 is not published on PyPI and must be provided separately; rather than crashing at import time, the module defers the failure to this explicit error only when a checkpoint is actually requested.
Solutions
- Install or vendor the sam3 package and ensure it is on PYTHONPATH
- If SAM3 detection is not needed, configure the pipeline to skip from_checkpoint (DINOv3-only path)
- Verify the import works in the pipeline's environment: python -c 'import sam3'
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at official/projects/waste_identification_ml/model_inference_with_tracking/sam3_dinov3_tracking_pipeline/sam3_detector.py:103 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of tensorflow/models@e006f5f0d5 (2026-08-24).
Data as JSON: /api/errors/e59542a5ee05071c.
Report an issue: GitHub.
Appendix: source
Thrown at official/projects/waste_identification_ml/model_inference_with_tracking/sam3_dinov3_tracking_pipeline/sam3_detector.py:103
device: str,
prompt_config: config_loader.PromptConfig,
) -> Self:
"""Constructs a SAM3Detector by loading a model from a checkpoint.
Args:
checkpoint_path: Path to the SAM3 model checkpoint.
device: Requested device string (e.g., 'cuda', 'cpu', 'mps').
prompt_config: Detection and post-processing thresholds for the active
prompt.
Returns:
An initialized `SAM3Detector` instance on the resolved device.
Raises:
ImportError: If the 'sam3' package is not installed or available.
"""
if sam3_model_builder is None or sam3_image_processor is None:
raise ImportError(
"The 'sam3' package is not installed or available in python path. "
"Cannot construct SAM3Detector from checkpoint."
)
resolved_device = _resolve_device(device)
model = sam3_model_builder.build_sam3_image_model(
checkpoint_path=str(checkpoint_path)
)
model.to(device=resolved_device)
processor = sam3_image_processor.Sam3Processor(
model,
confidence_threshold=prompt_config.confidence_threshold,
)
return cls(
model=model,
processor=processor,
device=resolved_device,
prompt_config=prompt_config,View on GitHub (pinned to e006f5f0d5)