Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,7 +2,7 @@ import torch
|
|
2 |
from PIL import Image
|
3 |
import gradio as gr
|
4 |
import spaces
|
5 |
-
from transformers import AutoProcessor,
|
6 |
import torch.nn.functional as F
|
7 |
|
8 |
#---------------------------------
|
@@ -13,7 +13,7 @@ def load_biomedclip_model():
|
|
13 |
"""Loads the BiomedCLIP model and tokenizer."""
|
14 |
biomedclip_model_name = 'microsoft/BiomedCLIP-PubMedBERT_256-vit_base_patch16_224'
|
15 |
processor = AutoProcessor.from_pretrained(biomedclip_model_name)
|
16 |
-
model =
|
17 |
return model, processor
|
18 |
|
19 |
def compute_similarity(image, text, biomedclip_model, biomedclip_processor):
|
|
|
2 |
from PIL import Image
|
3 |
import gradio as gr
|
4 |
import spaces
|
5 |
+
from transformers import AutoProcessor, AutoModelForImageTextRetrieval
|
6 |
import torch.nn.functional as F
|
7 |
|
8 |
#---------------------------------
|
|
|
13 |
"""Loads the BiomedCLIP model and tokenizer."""
|
14 |
biomedclip_model_name = 'microsoft/BiomedCLIP-PubMedBERT_256-vit_base_patch16_224'
|
15 |
processor = AutoProcessor.from_pretrained(biomedclip_model_name)
|
16 |
+
model = AutoModelForImageTextRetrieval.from_pretrained(biomedclip_model_name).cuda().eval()
|
17 |
return model, processor
|
18 |
|
19 |
def compute_similarity(image, text, biomedclip_model, biomedclip_processor):
|