Upload handler.py
Browse files- handler.py +5 -6
handler.py
CHANGED
@@ -78,17 +78,16 @@ def predict(text):
|
|
78 |
class EndpointHandler:
|
79 |
def __init__(self, path=""):
|
80 |
# load model and tokenizer from path
|
81 |
-
tokenizer = AutoTokenizer.from_pretrained("Lin0He/text-summary-gpt2-short")
|
82 |
-
model = AutoModel.from_pretrained("Lin0He/text-summary-gpt2-short")
|
83 |
-
|
84 |
|
85 |
def __call__(self, data: Dict[str, Any]) -> Dict[str, str]:
|
86 |
# process input
|
87 |
inputs = data.pop("inputs", data)
|
88 |
-
|
89 |
-
|
90 |
result = predict(inputs)
|
91 |
-
return result
|
92 |
|
93 |
|
94 |
|
|
|
78 |
class EndpointHandler:
|
79 |
def __init__(self, path=""):
|
80 |
# load model and tokenizer from path
|
81 |
+
self.tokenizer = AutoTokenizer.from_pretrained("Lin0He/text-summary-gpt2-short")
|
82 |
+
self.model = AutoModel.from_pretrained("Lin0He/text-summary-gpt2-short")
|
83 |
+
|
84 |
|
85 |
def __call__(self, data: Dict[str, Any]) -> Dict[str, str]:
|
86 |
# process input
|
87 |
inputs = data.pop("inputs", data)
|
88 |
+
# process input text
|
|
|
89 |
result = predict(inputs)
|
90 |
+
return {"text":result}
|
91 |
|
92 |
|
93 |
|