core/nn/vision/sam_loader library
Loader for HuggingFace / Facebook Research SAM safetensors.
Reads a .safetensors file dumped from a torch checkpoint (either
sam_vit_b_01ec64.pth via scripts/convert_sam_pt_to_safetensors.py
or the HF facebook/sam-vit-base bundle) and binds it to a triple
of SamImageEncoder + SamPromptEncoder + SamMaskDecoder.
Prefixes vary across sources:
- Original
sam_vit_b_01ec64.pthuses no prefix on the three submodels (keys start withimage_encoder.,prompt_encoder.,mask_decoder.). - The HF
facebook/sam-vit-basebundle uses the same top-level names; the wrapper module is calledsam.in the joint model but is dropped when the vision submodel is loaded alone.
The loader auto-detects the sam. prefix.