Jesse-marqo commited on
Commit
35a2c37
1 Parent(s): e47a5a0

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +16 -0
README.md CHANGED
@@ -39,6 +39,22 @@ The model can be seamlessly used with [OpenCLIP](https://github.com/mlfoundation
39
  import open_clip
40
  model, preprocess_train, preprocess_val = open_clip.create_model_and_transforms('hf-hub:Marqo/marqo-fashionSigLIP')
41
  tokenizer = open_clip.get_tokenizer('hf-hub:Marqo/marqo-fashionSigLIP')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  ```
43
 
44
  ## Benchmark Results
 
39
  import open_clip
40
  model, preprocess_train, preprocess_val = open_clip.create_model_and_transforms('hf-hub:Marqo/marqo-fashionSigLIP')
41
  tokenizer = open_clip.get_tokenizer('hf-hub:Marqo/marqo-fashionSigLIP')
42
+
43
+ import torch
44
+ from PIL import Image
45
+
46
+ image = preprocess_val(Image.open("docs/fashion-hippo.png")).unsqueeze(0)
47
+ text = tokenizer(["a hat", "a t-shirt", "shoes"])
48
+
49
+ with torch.no_grad(), torch.cuda.amp.autocast():
50
+ image_features = model.encode_image(image)
51
+ text_features = model.encode_text(text)
52
+ image_features /= image_features.norm(dim=-1, keepdim=True)
53
+ text_features /= text_features.norm(dim=-1, keepdim=True)
54
+
55
+ text_probs = (100.0 * image_features @ text_features.T).softmax(dim=-1)
56
+
57
+ print("Label probs:", text_probs)
58
  ```
59
 
60
  ## Benchmark Results