Jesse-marqo commited on
Commit
2ceeac4
1 Parent(s): 3406869

Update README.md

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