Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ import pytesseract
|
|
4 |
import yolov5
|
5 |
|
6 |
from transformers import CLIPProcessor, CLIPModel
|
7 |
-
|
8 |
processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32")
|
9 |
|
10 |
# load model
|
@@ -43,7 +43,7 @@ def zero_shot_classification(image, labels):
|
|
43 |
padding=True)
|
44 |
print(type(inputs))
|
45 |
print(inputs)
|
46 |
-
outputs =
|
47 |
logits_per_image = outputs.logits_per_image # this is the image-text similarity score
|
48 |
return logits_per_image.softmax(dim=1) # we can take the softmax to get the label probabilities
|
49 |
|
|
|
4 |
import yolov5
|
5 |
|
6 |
from transformers import CLIPProcessor, CLIPModel
|
7 |
+
vit_model = CLIPModel.from_pretrained("openai/clip-vit-base-patch32")
|
8 |
processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32")
|
9 |
|
10 |
# load model
|
|
|
43 |
padding=True)
|
44 |
print(type(inputs))
|
45 |
print(inputs)
|
46 |
+
outputs = vit_model(**inputs)
|
47 |
logits_per_image = outputs.logits_per_image # this is the image-text similarity score
|
48 |
return logits_per_image.softmax(dim=1) # we can take the softmax to get the label probabilities
|
49 |
|