From afee883a17ab039120783fd0cffe09ea979233cf Mon Sep 17 00:00:00 2001 From: Nils Reimers Date: Fri, 1 Oct 2021 10:33:41 +0200 Subject: [PATCH] update version to 2.1.0 --- examples/applications/image-search/example.py | 37 +++++++++++++++++-- sentence_transformers/__init__.py | 2 +- setup.py | 2 +- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/examples/applications/image-search/example.py b/examples/applications/image-search/example.py index d13eabb1b..ea10825bf 100644 --- a/examples/applications/image-search/example.py +++ b/examples/applications/image-search/example.py @@ -1,8 +1,39 @@ -from sentence_transformers import SentenceTransformer, util -from PIL import Image +from sentence_transformers import SentenceTransformer, util, models +from PIL import ImageFile, Image +import numpy as np +import requests + + + + +########### + +image = Image.open('two_dogs_in_snow.jpg') + +from transformers import CLIPProcessor, CLIPModel + +model = CLIPModel.from_pretrained("openai/clip-vit-base-patch32") +processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32") + + + +inputs = processor(texts=["a cat", "a dog"], images=[image], return_tensors="pt", padding=True) +output = model(**inputs) +#vision_outputs = model.vision_model(pixel_values=inputs['pixel_values']) +#image_embeds = model.visual_projection(vision_outputs[1]) + +#print(image_embeds.shape) +#exit() + + #Load CLIP model -model = SentenceTransformer('clip-ViT-B-32') +clip = models.CLIPModel() +model = SentenceTransformer(modules=[clip]) + +model.save('tmp-clip-model') + +model = SentenceTransformer('tmp-clip-model') #Encode an image: img_emb = model.encode(Image.open('two_dogs_in_snow.jpg')) diff --git a/sentence_transformers/__init__.py b/sentence_transformers/__init__.py index 72a76855c..04d6d7a2c 100644 --- a/sentence_transformers/__init__.py +++ b/sentence_transformers/__init__.py @@ -1,4 +1,4 @@ -__version__ = "2.0.0" +__version__ = "2.1.0" __MODEL_HUB_ORGANIZATION__ = 'sentence-transformers' from .datasets import SentencesDataset, ParallelSentencesDataset from .LoggingHandler import LoggingHandler diff --git a/setup.py b/setup.py index 2999d048f..67bb93806 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setup( name="sentence-transformers", - version="2.0.0", + version="2.1.0", author="Nils Reimers", author_email="info@nils-reimers.de", description="Sentence Embeddings using BERT / RoBERTa / XLM-R",