inference: prefer model.safetensors
Browse files- inference.py +12 -7
inference.py
CHANGED
|
@@ -164,14 +164,19 @@ class K3VisionEmbedder:
|
|
| 164 |
return cls(repo_or_path, device=device, **kw)
|
| 165 |
from huggingface_hub import hf_hub_download
|
| 166 |
from huggingface_hub.utils import EntryNotFoundError
|
| 167 |
-
try:
|
| 168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
try:
|
| 170 |
-
hf_hub_download(repo_or_path,
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
|
|
|
| 175 |
return cls(path, device=device, **kw)
|
| 176 |
|
| 177 |
@torch.no_grad()
|
|
|
|
| 164 |
return cls(repo_or_path, device=device, **kw)
|
| 165 |
from huggingface_hub import hf_hub_download
|
| 166 |
from huggingface_hub.utils import EntryNotFoundError
|
| 167 |
+
try:
|
| 168 |
+
hf_hub_download(repo_or_path, "config.json", revision=revision) # sibling config
|
| 169 |
+
except Exception: # noqa: BLE001
|
| 170 |
+
pass
|
| 171 |
+
path = None
|
| 172 |
+
for name in ("model.safetensors", "k3vit2fe2_proj.safetensors", "k3vit2fe2_proj.pt"):
|
| 173 |
try:
|
| 174 |
+
path = hf_hub_download(repo_or_path, name, revision=revision)
|
| 175 |
+
break
|
| 176 |
+
except EntryNotFoundError:
|
| 177 |
+
continue
|
| 178 |
+
if path is None:
|
| 179 |
+
raise FileNotFoundError(f"no projector checkpoint found in {repo_or_path}")
|
| 180 |
return cls(path, device=device, **kw)
|
| 181 |
|
| 182 |
@torch.no_grad()
|