wenhu commited on
Commit
7403b63
·
verified ·
1 Parent(s): 58a5cc2

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +6 -3
README.md CHANGED
@@ -53,7 +53,7 @@ from PIL import Image
53
  import numpy as np
54
 
55
  model_args = ModelArguments(
56
- model_name='microsoft/Phi-3.5-vision-instruct',
57
  pooling='last',
58
  normalize=True,
59
  lora=True,
@@ -74,17 +74,19 @@ inputs = processor('<|image_1|> Represent the given image with the following que
74
  inputs = {key: value.to('cuda') for key, value in inputs.items()}
75
  qry_output = model(qry=inputs)["qry_reps"]
76
 
77
- ## Compute the similarity;
78
  string = 'A cat and a dog'
79
  inputs = processor(string)
80
  inputs = {key: value.to('cuda') for key, value in inputs.items()}
81
  tgt_output = model(tgt=inputs)["tgt_reps"]
82
  print(string, '=', model.compute_similarity(qry_output, tgt_output))
 
83
 
 
84
  inputs = processor(string)
85
  inputs = {key: value.to('cuda') for key, value in inputs.items()}
86
  tgt_output = model(tgt=inputs)["tgt_reps"]
87
  print(string, '=', model.compute_similarity(qry_output, tgt_output))
 
88
 
89
  # Text -> Image
90
  inputs = processor('Find me an everyday image that matches the given caption: A cat and a dog.',)
@@ -92,10 +94,11 @@ inputs = {key: value.to('cuda') for key, value in inputs.items()}
92
  qry_output = model(qry=inputs)["qry_reps"]
93
 
94
  string = '<|image_1|> Represent the given image.'
95
- inputs = processor(string, [Image.open('figures/example.jpg')]])
96
  inputs = {key: value.to('cuda') for key, value in inputs.items()}
97
  tgt_output = model(tgt=inputs)["tgt_reps"]
98
  print(string, '=', model.compute_similarity(qry_output, tgt_output))
 
99
  ```
100
 
101
  ## Citation
 
53
  import numpy as np
54
 
55
  model_args = ModelArguments(
56
+ model_name='microsoft/Phi-3.5-vision-instruct',
57
  pooling='last',
58
  normalize=True,
59
  lora=True,
 
74
  inputs = {key: value.to('cuda') for key, value in inputs.items()}
75
  qry_output = model(qry=inputs)["qry_reps"]
76
 
 
77
  string = 'A cat and a dog'
78
  inputs = processor(string)
79
  inputs = {key: value.to('cuda') for key, value in inputs.items()}
80
  tgt_output = model(tgt=inputs)["tgt_reps"]
81
  print(string, '=', model.compute_similarity(qry_output, tgt_output))
82
+ ## A cat and a dog = tensor([[0.2969]], device='cuda:0', dtype=torch.bfloat16)
83
 
84
+ string = 'A cat and a tiger'
85
  inputs = processor(string)
86
  inputs = {key: value.to('cuda') for key, value in inputs.items()}
87
  tgt_output = model(tgt=inputs)["tgt_reps"]
88
  print(string, '=', model.compute_similarity(qry_output, tgt_output))
89
+ ## A cat and a tiger = tensor([[0.2080]], device='cuda:0', dtype=torch.bfloat16)
90
 
91
  # Text -> Image
92
  inputs = processor('Find me an everyday image that matches the given caption: A cat and a dog.',)
 
94
  qry_output = model(qry=inputs)["qry_reps"]
95
 
96
  string = '<|image_1|> Represent the given image.'
97
+ inputs = processor(string, [Image.open('figures/example.jpg')])
98
  inputs = {key: value.to('cuda') for key, value in inputs.items()}
99
  tgt_output = model(tgt=inputs)["tgt_reps"]
100
  print(string, '=', model.compute_similarity(qry_output, tgt_output))
101
+ ## <|image_1|> Represent the given image. = tensor([[0.3105]], device='cuda:0', dtype=torch.bfloat16)
102
  ```
103
 
104
  ## Citation