ML4RS-Anonymous commited on
Commit
e7e838f
·
verified ·
1 Parent(s): 17f0e8d

fix: load tokenizer from HFTokenizer and hf_hub_download

Browse files
Files changed (1) hide show
  1. models/siglip_model.py +6 -8
models/siglip_model.py CHANGED
@@ -39,16 +39,14 @@ class SigLIPModel:
39
  if not os.path.exists(self.ckpt_path):
40
  print(f"Warning: Checkpoint not found at {self.ckpt_path}")
41
 
42
- # if 'hf' in self.ckpt_path:
43
- from open_clip import create_model_from_pretrained, get_tokenizer # works on open-clip-torch>=2.23.0, timm>=0.9.8
44
 
45
- model, preprocess = create_model_from_pretrained('hf-hub:timm/ViT-SO400M-14-SigLIP-384')
46
- tokenizer = get_tokenizer('hf-hub:timm/ViT-SO400M-14-SigLIP-384')
 
 
 
47
 
48
- # model, preprocess = create_model_from_pretrained('hf-hub:timm/ViT-SO400M-14-SigLIP-384')
49
- # from huggingface_hub import hf_hub_download
50
- # tokenizer = get_tokenizer('hf-hub:timm/ViT-SO400M-14-SigLIP-384')
51
-
52
  self.model = self.model.to(self.device)
53
  self.model.eval()
54
 
 
39
  if not os.path.exists(self.ckpt_path):
40
  print(f"Warning: Checkpoint not found at {self.ckpt_path}")
41
 
42
+ self.tokenizer = HFTokenizer(hf_hub_download("timm/ViT-SO400M-14-SigLIP-384"))
 
43
 
44
+ self.ckpt_path = hf_hub_download("timm/ViT-SO400M-14-SigLIP-384", "open_clip_pytorch_model.bin")
45
+ self.model, _, self.preprocess = open_clip.create_model_and_transforms(
46
+ self.model_name,
47
+ pretrained=self.ckpt_path
48
+ )
49
 
 
 
 
 
50
  self.model = self.model.to(self.device)
51
  self.model.eval()
52