Instructions to use apple/DFN2B-CLIP-ViT-L-14 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- OpenCLIP
How to use apple/DFN2B-CLIP-ViT-L-14 with OpenCLIP:
import open_clip model, preprocess_train, preprocess_val = open_clip.create_model_and_transforms('hf-hub:apple/DFN2B-CLIP-ViT-L-14') tokenizer = open_clip.get_tokenizer('hf-hub:apple/DFN2B-CLIP-ViT-L-14') - Notebooks
- Google Colab
- Kaggle
Update README.md
#4
by dotREADYus - opened
README.md
CHANGED
|
@@ -91,7 +91,8 @@ with torch.no_grad(), torch.cuda.amp.autocast():
|
|
| 91 |
image_features = F.normalize(image_features, dim=-1)
|
| 92 |
text_features = F.normalize(text_features, dim=-1)
|
| 93 |
|
| 94 |
-
|
|
|
|
| 95 |
|
| 96 |
zipped_list = list(zip(labels_list, [round(p.item(), 3) for p in text_probs[0]]))
|
| 97 |
print("Label probabilities: ", zipped_list)
|
|
|
|
| 91 |
image_features = F.normalize(image_features, dim=-1)
|
| 92 |
text_features = F.normalize(text_features, dim=-1)
|
| 93 |
|
| 94 |
+
logits = model.logit_scale.exp() * image_features @ text_features.T
|
| 95 |
+
probs = logits.softmax(dim=-1)
|
| 96 |
|
| 97 |
zipped_list = list(zip(labels_list, [round(p.item(), 3) for p in text_probs[0]]))
|
| 98 |
print("Label probabilities: ", zipped_list)
|