sradc commited on
Commit
29033de
1 Parent(s): b9691bb

delete example.py

Browse files
Files changed (1) hide show
  1. example.py +0 -23
example.py DELETED
@@ -1,23 +0,0 @@
1
- import requests
2
- from PIL import Image
3
- from transformers import CLIPModel, CLIPProcessor
4
-
5
- model = CLIPModel.from_pretrained("openai/clip-vit-base-patch32")
6
- processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32")
7
-
8
- url = "http://images.cocodataset.org/val2017/000000039769.jpg"
9
- image = Image.open(requests.get(url, stream=True).raw)
10
-
11
- inputs = processor(
12
- text=["a photo of a cat", "a photo of a dog"],
13
- images=image,
14
- return_tensors="pt",
15
- padding=True,
16
- )
17
-
18
- outputs = model(**inputs)
19
- logits_per_image = outputs.logits_per_image # this is the image-text similarity score
20
- probs = logits_per_image.softmax(
21
- dim=1
22
- ) # we can take the softmax to get the label probabilities
23
- print(probs)