CM2000112 / handler.py
jayparmr's picture
update : inference
35575bb verified
import os
import sys
path = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(1, os.path.join(path, "external"))
from pathlib import Path
from typing import Any, Dict, List
from inference import model_fn, predict_fn
from internals.util.config import set_hf_cache_dir, set_model_config
from internals.util.model_loader import load_model_from_config
class EndpointHandler:
def __init__(self, path=""):
set_hf_cache_dir(Path.home() / ".cache" / "hf_cache")
self.model_dir = path
return model_fn(self.model_dir)
def __call__(self, data: Any) -> List[List[Dict[str, float]]]:
return predict_fn(data, None)