yolo / model_loader.py
rajtib's picture
Final clean deployment
4f1075f
Raw History Blame Contribute Delete
585 Bytes
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
)