elevator-maintenance / handler.py
shalev396's picture
Add elevator-maintenance model: weights, model.py, Inference Endpoint handler, card
897d513 unverified
Raw History Blame Contribute Delete
780 Bytes
"""Hugging Face Inference Endpoints entry point — deploy this repo as a CPU/GPU API.
Request body: {"inputs": <CSV text | list of row dicts | {column: [values]}>} with >= 60 minutely rows of
the 11 sensor columns (optional `timestamp` column). Response: {"failure": p, "healthy": 1 - p}.
"""
import sys
from pathlib import Path
HERE = Path(__file__).resolve().parent
sys.path.insert(0, str(HERE))
import model as M # noqa: E402
class EndpointHandler:
def __init__(self, path: str = ""):
self.predictor = M.load(path or HERE, "cuda" if M.cuda_available() else "cpu")
def __call__(self, data: dict):
inputs = data.pop("inputs", data)
parameters = data.pop("parameters", None) or {}
return self.predictor.predict(inputs, **parameters)