gmastrapas commited on
Commit
b9d7d6e
1 Parent(s): 84b0419

docs: update usage in README

Browse files
Files changed (1) hide show
  1. README.md +8 -3
README.md CHANGED
@@ -48,14 +48,19 @@ Jina CLIP V1 [technical report]() coming soon.
48
  You can use Jina CLIP directly from transformers package.
49
 
50
  ```python
51
- !pip install transformers
52
- from transformers import AutoModel
53
  from numpy.linalg import norm
54
 
55
  cos_sim = lambda a,b: (a @ b.T) / (norm(a)*norm(b))
56
- model = AutoModel.from_pretrained('jinaai/jina-clip-v1')
 
 
 
 
57
  text_embeddings = model.encode_text(['How is the weather today?', 'What is the current weather like today?'])
58
  image_embeddings = model.encode_image(['raindrop.png'])
 
59
  print(cos_sim(text_embeddings[0], text_embeddings[1])) # text embedding similarity
60
  print(cos_sim(text_embeddings[0], image_embeddings[0])) # text-image cross-modal similarity
61
  ```
 
48
  You can use Jina CLIP directly from transformers package.
49
 
50
  ```python
51
+ !pip install transformers einops timm
52
+ from transformers import AutoModel, AutoTokenizer, AutoImageProcessor
53
  from numpy.linalg import norm
54
 
55
  cos_sim = lambda a,b: (a @ b.T) / (norm(a)*norm(b))
56
+
57
+ tokenizer = AutoTokenizer.from_pretrained('jinaai/jina-clip-v1', trust_remote_code=True)
58
+ image_processor = AutoImageProcessor.from_pretrained('jinaai/jina-clip-v1', trust_remote_code=True)
59
+ model = AutoModel.from_pretrained('jinaai/jina-clip-v1', trust_remote_code=True)
60
+
61
  text_embeddings = model.encode_text(['How is the weather today?', 'What is the current weather like today?'])
62
  image_embeddings = model.encode_image(['raindrop.png'])
63
+
64
  print(cos_sim(text_embeddings[0], text_embeddings[1])) # text embedding similarity
65
  print(cos_sim(text_embeddings[0], image_embeddings[0])) # text-image cross-modal similarity
66
  ```