Skip to content

Commit afee883

Browse files
committed
update version to 2.1.0
1 parent ffd72ab commit afee883

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

examples/applications/image-search/example.py

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,39 @@
1-
from sentence_transformers import SentenceTransformer, util
2-
from PIL import Image
1+
from sentence_transformers import SentenceTransformer, util, models
2+
from PIL import ImageFile, Image
3+
import numpy as np
4+
import requests
5+
6+
7+
8+
9+
###########
10+
11+
image = Image.open('two_dogs_in_snow.jpg')
12+
13+
from transformers import CLIPProcessor, CLIPModel
14+
15+
model = CLIPModel.from_pretrained("openai/clip-vit-base-patch32")
16+
processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32")
17+
18+
19+
20+
inputs = processor(texts=["a cat", "a dog"], images=[image], return_tensors="pt", padding=True)
21+
output = model(**inputs)
22+
#vision_outputs = model.vision_model(pixel_values=inputs['pixel_values'])
23+
#image_embeds = model.visual_projection(vision_outputs[1])
24+
25+
#print(image_embeds.shape)
26+
#exit()
27+
28+
329

430
#Load CLIP model
5-
model = SentenceTransformer('clip-ViT-B-32')
31+
clip = models.CLIPModel()
32+
model = SentenceTransformer(modules=[clip])
33+
34+
model.save('tmp-clip-model')
35+
36+
model = SentenceTransformer('tmp-clip-model')
637

738
#Encode an image:
839
img_emb = model.encode(Image.open('two_dogs_in_snow.jpg'))

sentence_transformers/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "2.0.0"
1+
__version__ = "2.1.0"
22
__MODEL_HUB_ORGANIZATION__ = 'sentence-transformers'
33
from .datasets import SentencesDataset, ParallelSentencesDataset
44
from .LoggingHandler import LoggingHandler

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
setup(
99
name="sentence-transformers",
10-
version="2.0.0",
10+
version="2.1.0",
1111
author="Nils Reimers",
1212
author_email="[email protected]",
1313
description="Sentence Embeddings using BERT / RoBERTa / XLM-R",

0 commit comments

Comments
 (0)