Spaces:
Build error
Build error
File size: 1,163 Bytes
4c04f50 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
"""Load model_s."""
# pylint: disable=invalid-name
from pathlib import Path
import joblib
from huggingface_hub import hf_hub_url, cached_download # hf_hub_download,
from alive_progress import alive_bar
from logzero import logger
def load_model_s():
"""Load local model_s if present, else fetch from hf.co."""
file_loc = "radiobee/model_s"
if Path(file_loc).exists():
# raise Exception(f"File {file_loc} does not exist.")
with alive_bar(1, title=" Loading model_s, takes ~30 secs ...", length=3) as progress_bar:
model = joblib.load(file_loc)
# model_s = pickle.load(open(file_loc, "rb"))
progress_bar() # pylint: disable=not-callable
return model
logger.info(
"Fetching and caching model_s from huggingface.co... "
"The first time may take a while depending on your net."
)
with alive_bar(1, title=" Subsequent loading takes ~20 secs ...", length=3) as progress_bar:
model = joblib.load(cached_download(hf_hub_url("mikeee/model_s", "model_s")))
progress_bar() # pylint: disable=not-callable
return model
model_s = load_model_s()
|