Update README.md
Browse files
README.md
CHANGED
@@ -6,48 +6,41 @@ tags:
|
|
6 |
- sentence-similarity
|
7 |
---
|
8 |
|
9 |
-
#
|
10 |
|
11 |
-
This is
|
12 |
|
13 |
-
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:
|
18 |
-
|
19 |
-
```
|
20 |
-
pip install -U sentence-transformers
|
21 |
-
```
|
22 |
-
|
23 |
-
Then you can use the model like this:
|
24 |
|
|
|
25 |
```python
|
26 |
-
from sentence_transformers import SentenceTransformer
|
27 |
-
|
28 |
-
|
29 |
-
model = SentenceTransformer('{MODEL_NAME}')
|
30 |
-
embeddings = model.encode(sentences)
|
31 |
-
print(embeddings)
|
32 |
-
```
|
33 |
-
|
34 |
-
|
35 |
|
36 |
-
|
|
|
37 |
|
38 |
-
|
|
|
39 |
|
40 |
-
|
|
|
41 |
|
|
|
|
|
|
|
|
|
42 |
|
|
|
43 |
|
44 |
-
##
|
45 |
-
```
|
46 |
-
SentenceTransformer(
|
47 |
-
(0): CLIPModel()
|
48 |
-
)
|
49 |
-
```
|
50 |
|
51 |
-
|
52 |
|
53 |
-
|
|
|
|
|
|
|
|
|
|
6 |
- sentence-similarity
|
7 |
---
|
8 |
|
9 |
+
# clip-ViT-B-32
|
10 |
|
11 |
+
This is the Image & Text model [CLIP](https://arxiv.org/abs/2103.00020), which maps text and images to a shared vector space. For applications of the models, have a look in our documentation [SBERT.net - Image Search](https://www.sbert.net/examples/applications/image-search/README.html)
|
12 |
|
13 |
+
## Usage
|
14 |
|
15 |
+
After installing [sentence-transformers](https://sbert.net) (`pip install sentence-transformers`), the usage of this model is easy:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
+
|
18 |
```python
|
19 |
+
from sentence_transformers import SentenceTransformer, util
|
20 |
+
from PIL import Image
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
+
#Load CLIP model
|
23 |
+
model = SentenceTransformer('clip-ViT-B-32')
|
24 |
|
25 |
+
#Encode an image:
|
26 |
+
img_emb = model.encode(Image.open('two_dogs_in_snow.jpg'))
|
27 |
|
28 |
+
#Encode text descriptions
|
29 |
+
text_emb = model.encode(['Two dogs in the snow', 'A cat on a table', 'A picture of London at night'])
|
30 |
|
31 |
+
#Compute cosine similarities
|
32 |
+
cos_scores = util.cos_sim(img_emb, text_emb)
|
33 |
+
print(cos_scores)
|
34 |
+
```
|
35 |
|
36 |
+
See our [SBERT.net - Image Search](https://www.sbert.net/examples/applications/image-search/README.html) documentation for more examples how the model can be used for image search, zero-shot image classification, image clustering and image deduplication.
|
37 |
|
38 |
+
## Performance
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
+
In the following table we find the zero-shot ImageNet validation set accuracy:
|
41 |
|
42 |
+
| Model | Top 1 Performance |
|
43 |
+
| --- | :---: |
|
44 |
+
| clip-ViT-B-32 | 63.3 |
|
45 |
+
| clip-ViT-B-16 | 68.1 |
|
46 |
+
| clip-ViT-L-14 | 75.4 |
|