AI Agent commited on
Commit
c1dd13e
·
1 Parent(s): b90ddcd

CRITICAL FIX: Pass ckpt_path to build_sam3_image_model() to prevent internal download hang without HF token

Browse files
Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -85,12 +85,10 @@ processor = None
85
 
86
  if model_installed:
87
  print(f"Loading SAM 3 onto {device}...")
88
- model = build_sam3_image_model()
89
- # NOTE: build_sam3_image_model() already loads checkpoint weights internally
90
- # via _load_checkpoint(). DO NOT load the checkpoint again manually—it corrupts
91
- # the weights with incorrect key mappings and causes zero masks!
92
- model.to(device)
93
- model.to(torch.float32) # Lossless 32-bit execution prevents BFloat16 exponent overflows (NaNs)
94
 
95
  processor = Sam3Processor(model)
96
  if not torch.cuda.is_available():
 
85
 
86
  if model_installed:
87
  print(f"Loading SAM 3 onto {device}...")
88
+ model = build_sam3_image_model(checkpoint_path=ckpt_path)
89
+ # NOTE: build_sam3_image_model() internally loads weights, remaps keys,
90
+ # and calls model.cuda().eval(). We just need to cast to float32 for T4.
91
+ model.to(torch.float32)
 
 
92
 
93
  processor = Sam3Processor(model)
94
  if not torch.cuda.is_available():