philschmid HF staff commited on
Commit
c694bb9
1 Parent(s): fce5a3d

Create new file

Browse files
Files changed (1) hide show
  1. endpoint.py +23 -0
endpoint.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Dict, List
2
+ import numpy as np
3
+
4
+ class EndpointHandler():
5
+ def __init__(self, path=""):
6
+ # IMPLEMENT_THIS
7
+ # Preload all the elements you are going to need at inference.
8
+ # For instance your model, processors, tokenizer that might be needed.
9
+ # This function is only called once, so do all the heavy processing I/O here"""
10
+ self.path = path
11
+
12
+ def __call__(self, inputs: str) -> List[List[Dict[str, float]]]:
13
+ """
14
+ Args:
15
+ inputs (:obj:`str`):
16
+ a string containing some text
17
+ Return:
18
+ A :obj:`list`:. The object returned should be a list of one list like [[{"label": 0.9939950108528137}]] containing :
19
+ - "label": A string representing what the label/class is. There can be multiple labels.
20
+ - "score": A score between 0 and 1 describing how confident the model is for this label/class.
21
+ """
22
+ # IMPLEMENT_THIS
23
+ return inputs