Update README.md
Browse files
README.md
CHANGED
@@ -55,19 +55,13 @@ from PIL import Image
|
|
55 |
|
56 |
cos_sim = lambda a,b: (a @ b.T) / (norm(a)*norm(b))
|
57 |
|
58 |
-
tokenizer = AutoTokenizer.from_pretrained('jinaai/jina-clip-v1', trust_remote_code=True)
|
59 |
-
image_processor = AutoImageProcessor.from_pretrained('jinaai/jina-clip-v1', trust_remote_code=True)
|
60 |
model = AutoModel.from_pretrained('jinaai/jina-clip-v1', trust_remote_code=True)
|
61 |
|
62 |
-
|
63 |
-
|
64 |
-
return_tensors='pt',
|
65 |
-
padding='longest',
|
66 |
-
)
|
67 |
-
image_inputs = image_processor([Image.open('raindrop.png').load()])
|
68 |
|
69 |
-
text_embeddings = model.
|
70 |
-
image_embeddings = model.
|
71 |
|
72 |
print(cos_sim(text_embeddings[0], text_embeddings[1])) # text embedding similarity
|
73 |
print(cos_sim(text_embeddings[0], image_embeddings[0])) # text-image cross-modal similarity
|
|
|
55 |
|
56 |
cos_sim = lambda a,b: (a @ b.T) / (norm(a)*norm(b))
|
57 |
|
|
|
|
|
58 |
model = AutoModel.from_pretrained('jinaai/jina-clip-v1', trust_remote_code=True)
|
59 |
|
60 |
+
sentences = ['How is the weather today?', 'What is the current weather like today?']
|
61 |
+
images = ['raindrop.jpg', 'sunny.jpg']
|
|
|
|
|
|
|
|
|
62 |
|
63 |
+
text_embeddings = model.encode_text(sentences)
|
64 |
+
image_embeddings = model.encode_image(images)
|
65 |
|
66 |
print(cos_sim(text_embeddings[0], text_embeddings[1])) # text embedding similarity
|
67 |
print(cos_sim(text_embeddings[0], image_embeddings[0])) # text-image cross-modal similarity
|