Spaces:
Running
Running
Samuel Stevens
commited on
Commit
•
216fbaf
1
Parent(s):
8fa75cc
use pretrained clip
Browse files- .gitignore +2 -0
- 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 = "
|
10 |
-
|
|
|
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,
|
54 |
print("Created model.")
|
55 |
|
56 |
model = torch.compile(model)
|
57 |
print("Compiled model.")
|
58 |
|
59 |
-
tokenizer = get_tokenizer(
|
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,
|