mantasb commited on
Commit
9fb6a3e
·
1 Parent(s): a516d55

adding handler

Browse files
Files changed (1) hide show
  1. handler.py +20 -0
handler.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Dict, List, Any
2
+ from transformers import pipeline
3
+
4
+ class EndpointHandler():
5
+ def __init__(self, path=""):
6
+ self.pipeline = pipeline("text-classification", model=path)
7
+
8
+ def __call__(self, data: str) -> List[str]]:
9
+ """
10
+ data args:
11
+ inputs (:obj: `str`)
12
+
13
+ Return:
14
+ A :obj:`list` | `dict`: will be serialized and returned
15
+ """
16
+ # get inputs
17
+ inputs = data.pop("inputs",data)
18
+ # run normal prediction
19
+ prediction = self.pipeline(inputs)
20
+ return prediction