File size: 825 Bytes
e63ac97 a85dd96 e63ac97 a85dd96 0ff6669 a85dd96 e63ac97 |
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 |
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} |