Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -21,10 +21,14 @@ async def load_model():
|
|
| 21 |
cache_dir = "/tmp/hf_cache"
|
| 22 |
os.makedirs(cache_dir, exist_ok=True)
|
| 23 |
|
|
|
|
|
|
|
|
|
|
| 24 |
model_path = hf_hub_download(
|
| 25 |
repo_id="emp-admin/headache-predictor-xgboost",
|
| 26 |
filename="model.pkl",
|
| 27 |
-
cache_dir=cache_dir
|
|
|
|
| 28 |
)
|
| 29 |
with open(model_path, 'rb') as f:
|
| 30 |
model = pickle.load(f)
|
|
|
|
| 21 |
cache_dir = "/tmp/hf_cache"
|
| 22 |
os.makedirs(cache_dir, exist_ok=True)
|
| 23 |
|
| 24 |
+
# Get HF token from environment (set as Space secret)
|
| 25 |
+
hf_token = os.environ.get("HF_TOKEN")
|
| 26 |
+
|
| 27 |
model_path = hf_hub_download(
|
| 28 |
repo_id="emp-admin/headache-predictor-xgboost",
|
| 29 |
filename="model.pkl",
|
| 30 |
+
cache_dir=cache_dir,
|
| 31 |
+
token=hf_token # Use token for private repo access
|
| 32 |
)
|
| 33 |
with open(model_path, 'rb') as f:
|
| 34 |
model = pickle.load(f)
|