File size: 672 Bytes
637bd8b 1391d90 22a70b4 1391d90 637bd8b 1391d90 22a70b4 1391d90 637bd8b 1391d90 637bd8b 1391d90 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # app/model_loader.py
import os
import tensorflow as tf
from huggingface_hub import hf_hub_download
MODEL_PATH = "app/model/efficientnetv2s.h5"
REPO_ID = "Miguel764/efficientnetv2s-skin-cancer-classifier"
FILENAME = "efficientnetv2s.h5"
def load_model():
if not os.path.exists(MODEL_PATH):
print("Model not found locally. Downloading from Hugging Face...")
os.makedirs(os.path.dirname(MODEL_PATH), exist_ok=True)
hf_hub_download(
repo_id=REPO_ID,
filename=FILENAME,
local_dir="app/model"
)
else:
print("Model already exists locally.")
return tf.keras.models.load_model(MODEL_PATH)
|