Update app.py
Browse files
app.py
CHANGED
|
@@ -14,16 +14,13 @@ os.makedirs(MODEL_DIR, exist_ok=True)
|
|
| 14 |
def download_from_hf(filename):
|
| 15 |
local_path = os.path.join(MODEL_DIR, filename)
|
| 16 |
if os.path.exists(local_path):
|
| 17 |
-
print(f"✅ {filename} already exists at {local_path}")
|
| 18 |
return local_path
|
| 19 |
url = f"https://huggingface.co/{HF_REPO}/resolve/main/{filename}"
|
| 20 |
-
print(f"⬇️ Downloading {filename} from {url} ...")
|
| 21 |
with requests.get(url, stream=True) as r:
|
| 22 |
r.raise_for_status()
|
| 23 |
with open(local_path, "wb") as f:
|
| 24 |
for chunk in r.iter_content(chunk_size=8192):
|
| 25 |
f.write(chunk)
|
| 26 |
-
print(f"✅ Downloaded {filename} to {local_path}")
|
| 27 |
return local_path
|
| 28 |
|
| 29 |
# ===============================
|
|
@@ -51,6 +48,7 @@ async def lifespan(app: FastAPI):
|
|
| 51 |
# ===============================
|
| 52 |
app = FastAPI(title="Health Monitoring API", lifespan=lifespan)
|
| 53 |
|
|
|
|
| 54 |
# ===============================
|
| 55 |
# Request schemas
|
| 56 |
# ===============================
|
|
|
|
| 14 |
def download_from_hf(filename):
|
| 15 |
local_path = os.path.join(MODEL_DIR, filename)
|
| 16 |
if os.path.exists(local_path):
|
|
|
|
| 17 |
return local_path
|
| 18 |
url = f"https://huggingface.co/{HF_REPO}/resolve/main/{filename}"
|
|
|
|
| 19 |
with requests.get(url, stream=True) as r:
|
| 20 |
r.raise_for_status()
|
| 21 |
with open(local_path, "wb") as f:
|
| 22 |
for chunk in r.iter_content(chunk_size=8192):
|
| 23 |
f.write(chunk)
|
|
|
|
| 24 |
return local_path
|
| 25 |
|
| 26 |
# ===============================
|
|
|
|
| 48 |
# ===============================
|
| 49 |
app = FastAPI(title="Health Monitoring API", lifespan=lifespan)
|
| 50 |
|
| 51 |
+
|
| 52 |
# ===============================
|
| 53 |
# Request schemas
|
| 54 |
# ===============================
|