Samuel Stevens commited on
Commit
2e74323
1 Parent(s): 6a994e0

use pretrained clip

Browse files
Files changed (2) hide show
  1. .gitignore +2 -0
  2. app.py +5 -4
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ .venv/
2
+ __pycache__/
app.py CHANGED
@@ -6,8 +6,9 @@ from torchvision import transforms
6
  from open_clip import create_model, get_tokenizer
7
  from templates import openai_imagenet_template
8
 
9
- model_str = "ViT-B-16"
10
- pretrained = "/fs/ess/PAS2136/foundation_model/model/10m/2023_09_22-21_14_04-model_ViT-B-16-lr_0.0001-b_4096-j_8-p_amp/checkpoints/epoch_99.pt"
 
11
 
12
  preprocess_img = transforms.Compose(
13
  [
@@ -50,13 +51,13 @@ def predict(img, cls_str: str) -> dict[str, float]:
50
 
51
  if __name__ == "__main__":
52
  print("Starting.")
53
- model = create_model(model_str, pretrained, output_dict=True)
54
  print("Created model.")
55
 
56
  model = torch.compile(model)
57
  print("Compiled model.")
58
 
59
- tokenizer = get_tokenizer(model_str)
60
 
61
  demo = gr.Interface(
62
  fn=predict,
 
6
  from open_clip import create_model, get_tokenizer
7
  from templates import openai_imagenet_template
8
 
9
+ model_str = "hf-hub:imageomics/bioclip"
10
+ tokenizer_str = "ViT-B-16"
11
+
12
 
13
  preprocess_img = transforms.Compose(
14
  [
 
51
 
52
  if __name__ == "__main__":
53
  print("Starting.")
54
+ model = create_model(model_str, output_dict=True, require_pretrained=True)
55
  print("Created model.")
56
 
57
  model = torch.compile(model)
58
  print("Compiled model.")
59
 
60
+ tokenizer = get_tokenizer(tokenizer_str)
61
 
62
  demo = gr.Interface(
63
  fn=predict,