Spaces:
Sleeping
Sleeping
Upload api.py with huggingface_hub
Browse files
api.py
CHANGED
|
@@ -40,12 +40,13 @@ def _ensure_weights():
|
|
| 40 |
continue
|
| 41 |
try:
|
| 42 |
from huggingface_hub import hf_hub_download
|
| 43 |
-
print(f" Downloading {fname} from HF...", flush=True)
|
|
|
|
| 44 |
dest = hf_hub_download(
|
| 45 |
-
repo_id="mahmoud611/cardioscreen-
|
| 46 |
-
filename=
|
| 47 |
-
repo_type="
|
| 48 |
-
local_dir=
|
| 49 |
)
|
| 50 |
# Ensure it landed in the right place
|
| 51 |
if dest != fpath and os.path.exists(dest):
|
|
@@ -100,13 +101,21 @@ app.add_middleware(
|
|
| 100 |
async def health_check():
|
| 101 |
"""Health check — confirms the API is running."""
|
| 102 |
import inference
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
return {
|
| 104 |
"status": "ok",
|
| 105 |
"service": "CardioScreen AI",
|
| 106 |
-
"version": "
|
| 107 |
-
"
|
| 108 |
-
|
| 109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
"startup_errors": _startup_errors,
|
| 111 |
}
|
| 112 |
|
|
|
|
| 40 |
continue
|
| 41 |
try:
|
| 42 |
from huggingface_hub import hf_hub_download
|
| 43 |
+
print(f" Downloading {fname} from HF model repo...", flush=True)
|
| 44 |
+
# Download from public model repo (not Space — Space requires auth)
|
| 45 |
dest = hf_hub_download(
|
| 46 |
+
repo_id="mahmoud611/cardioscreen-weights",
|
| 47 |
+
filename=fname,
|
| 48 |
+
repo_type="model",
|
| 49 |
+
local_dir=WEIGHTS_DIR,
|
| 50 |
)
|
| 51 |
# Ensure it landed in the right place
|
| 52 |
if dest != fpath and os.path.exists(dest):
|
|
|
|
| 101 |
async def health_check():
|
| 102 |
"""Health check — confirms the API is running."""
|
| 103 |
import inference
|
| 104 |
+
weights_status = {
|
| 105 |
+
f: os.path.exists(os.path.join(WEIGHTS_DIR, f))
|
| 106 |
+
for f in WEIGHT_FILES if f.endswith(".pt")
|
| 107 |
+
}
|
| 108 |
return {
|
| 109 |
"status": "ok",
|
| 110 |
"service": "CardioScreen AI",
|
| 111 |
+
"version": "3.0",
|
| 112 |
+
"models": {
|
| 113 |
+
"joint_cnn": inference._cnn_available,
|
| 114 |
+
"finetuned_cnn": inference._finetuned_available,
|
| 115 |
+
"resnet18": inference._resnet_available,
|
| 116 |
+
"bigru": inference._gru_available,
|
| 117 |
+
},
|
| 118 |
+
"weights": weights_status,
|
| 119 |
"startup_errors": _startup_errors,
|
| 120 |
}
|
| 121 |
|