bwang0911 commited on
Commit
aac6f27
1 Parent(s): 6507fd6

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +4 -10
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
- text_inputs = tokenizer(
63
- ['How is the weather today?', 'What is the current weather like today?'],
64
- return_tensors='pt',
65
- padding='longest',
66
- )
67
- image_inputs = image_processor([Image.open('raindrop.png').load()])
68
 
69
- text_embeddings = model.get_text_features(text_inputs)
70
- image_embeddings = model.get_image_features(image_inputs)
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