Spaces:
Sleeping
Sleeping
Download src/inference.py from vorddd/GSLC-MLOps: direct link, hf CLI and curl.
- Browser
- Download file 324 Bytes
-
https://huggingface.co/spaces/vorddd/GSLC-MLOps/resolve/main/src/inference.py
- Command line
-
hf download hf://spaces/vorddd/GSLC-MLOps/src/inference.py
-
curl -L -o inference.py https://huggingface.co/spaces/vorddd/GSLC-MLOps/resolve/main/src/inference.py
324 Bytes
| import numpy as np | |
| from joblib import load | |
| from src.utils import MODEL_PATH | |
| _model = None | |
| def get_model(): | |
| global _model | |
| if _model is None: | |
| _model = load(MODEL_PATH) | |
| return _model | |
| def predict_one(x_row: np.ndarray) -> int: | |
| mdl = get_model() | |
| return int(mdl.predict(x_row.reshape(1, -1))[0]) | |