Instructions to use Yale-BIDS-Chen/medpmc-clip-l-14_jun24_v1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- OpenCLIP
How to use Yale-BIDS-Chen/medpmc-clip-l-14_jun24_v1 with OpenCLIP:
import open_clip model, preprocess_train, preprocess_val = open_clip.create_model_and_transforms('hf-hub:Yale-BIDS-Chen/medpmc-clip-l-14_jun24_v1') tokenizer = open_clip.get_tokenizer('hf-hub:Yale-BIDS-Chen/medpmc-clip-l-14_jun24_v1') - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -34,6 +34,7 @@ tokenizer = open_clip.get_tokenizer("ViT-L-14")
|
|
| 34 |
import torch
|
| 35 |
import open_clip
|
| 36 |
from safetensors.torch import load_file
|
|
|
|
| 37 |
from PIL import Image
|
| 38 |
|
| 39 |
model_name = "ViT-L-14"
|
|
@@ -44,7 +45,14 @@ model, _, preprocess = open_clip.create_model_and_transforms(
|
|
| 44 |
pretrained=None,
|
| 45 |
)
|
| 46 |
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
model.load_state_dict(state_dict, strict=True)
|
| 49 |
model = model.to(device)
|
| 50 |
model.eval()
|
|
|
|
| 34 |
import torch
|
| 35 |
import open_clip
|
| 36 |
from safetensors.torch import load_file
|
| 37 |
+
from huggingface_hub import hf_hub_download
|
| 38 |
from PIL import Image
|
| 39 |
|
| 40 |
model_name = "ViT-L-14"
|
|
|
|
| 45 |
pretrained=None,
|
| 46 |
)
|
| 47 |
|
| 48 |
+
repo_id = "Yale-BIDS-Chen/medpmc-clip-l-14_jun24_v1"
|
| 49 |
+
|
| 50 |
+
ckpt_path = hf_hub_download(
|
| 51 |
+
repo_id=repo_id,
|
| 52 |
+
filename="open_clip_pytorch_model.safetensors",
|
| 53 |
+
)
|
| 54 |
+
|
| 55 |
+
state_dict = load_file(ckpt_path, device="cpu")
|
| 56 |
model.load_state_dict(state_dict, strict=True)
|
| 57 |
model = model.to(device)
|
| 58 |
model.eval()
|