Lin0He commited on
Commit
6af6941
·
1 Parent(s): 8cd2c8e

Upload handler.py

Browse files
Files changed (1) hide show
  1. 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
- self.device = "cuda" if torch.cuda.is_available() else "cpu"
84
 
85
  def __call__(self, data: Dict[str, Any]) -> Dict[str, str]:
86
  # process input
87
  inputs = data.pop("inputs", data)
88
- parameters = data.pop("parameters", None)
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