Upload folder using huggingface_hub
Browse files- example.py +0 -3
- modeling_sm_subgroup_classifier.py +10 -1
example.py
CHANGED
|
@@ -6,9 +6,6 @@ sm_classifier = AutoModel.from_pretrained(
|
|
| 6 |
"erikhenriksson/sm-subgroup-classifier", trust_remote_code=True
|
| 7 |
)
|
| 8 |
|
| 9 |
-
available = sm_classifier._get_available_models()
|
| 10 |
-
print(f"Available models on HF Hub: {available}")
|
| 11 |
-
|
| 12 |
# create a random 1024 dimensional embedding
|
| 13 |
|
| 14 |
embedding = np.random.rand(1024).astype(np.float32)
|
|
|
|
| 6 |
"erikhenriksson/sm-subgroup-classifier", trust_remote_code=True
|
| 7 |
)
|
| 8 |
|
|
|
|
|
|
|
|
|
|
| 9 |
# create a random 1024 dimensional embedding
|
| 10 |
|
| 11 |
embedding = np.random.rand(1024).astype(np.float32)
|
modeling_sm_subgroup_classifier.py
CHANGED
|
@@ -110,6 +110,15 @@ class SmSubgroupClassifier(PreTrainedModel):
|
|
| 110 |
|
| 111 |
# Create model instance (skip the pytorch weight loading)
|
| 112 |
model = cls(config)
|
| 113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
|
| 115 |
return model
|
|
|
|
| 110 |
|
| 111 |
# Create model instance (skip the pytorch weight loading)
|
| 112 |
model = cls(config)
|
| 113 |
+
|
| 114 |
+
# For HF Hub, we need to resolve to the actual cached directory
|
| 115 |
+
try:
|
| 116 |
+
from huggingface_hub import snapshot_download
|
| 117 |
+
|
| 118 |
+
# Download/get the cached directory path
|
| 119 |
+
model.model_dir = snapshot_download(pretrained_model_name_or_path)
|
| 120 |
+
except ImportError:
|
| 121 |
+
# Fallback if huggingface_hub not available
|
| 122 |
+
model.model_dir = pretrained_model_name_or_path
|
| 123 |
|
| 124 |
return model
|