from typing import Dict, List, Any import pipeline import gdown class EndpointHandler(): def __init__(self, path=""): # Preload all the elements you are going to need at inference. # pseudo: file_name = 'ckpt.pt' url = 'https://drive.google.com/file/d/1jt5zyFcyVUOd5kC_yMrcj3Wqk7kAzuPU' gdown.download(url, file_name, quiet=False) def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]: """ data args: inputs (:obj: `str` | `PIL.Image` | `np.array`) kwargs Return: A :obj:`list` | `dict`: will be serialized and returned """ inputs = data.pop("inputs", data) pipeline.start = inputs output = pipeline.infer() # isinstance(output,str) return {"image": output}