File size: 585 Bytes
4f1075f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | import os
from huggingface_hub import hf_hub_download
MODEL_DIR = "models"
def get_model(filename: str):
local_path = os.path.join(MODEL_DIR, filename)
# 🟢 Local dev: model exists
if os.path.exists(local_path):
print(f"[LOCAL] Using model: {local_path}")
return local_path
# 🔵 HF Space: download model
print(f"[HF] Downloading model: {filename}")
os.makedirs(MODEL_DIR, exist_ok=True)
return hf_hub_download(
repo_id="rajitb/geoai-models", # CHANGE IF NEEDED
filename=filename,
local_dir=MODEL_DIR
)
|