syarulzaffi commited on
Commit
0a71e77
·
verified ·
1 Parent(s): fbbe43b

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +3 -3
handler.py CHANGED
@@ -5,7 +5,7 @@ class EndpointHandler:
5
  def __init__(self, path=""):
6
  # Load the optimized model
7
  tokenizer = AutoTokenizer.from_pretrained(path)
8
- # Create inference pipeline
9
  self.pipeline = pipeline("text-classification", model=path, tokenizer=tokenizer)
10
 
11
  def __call__(self, data: str) -> List[List[Dict[str, float]]]:
@@ -17,8 +17,8 @@ class EndpointHandler:
17
  A list containing the prediction results:
18
  A list of one list, e.g., [[{"label": "LABEL", "score": 0.99}]]
19
  """
20
- # Directly pass the input data to the pipeline without any type check
21
- prediction = self.pipeline(data)
22
 
23
  # Return the prediction result
24
  return prediction
 
5
  def __init__(self, path=""):
6
  # Load the optimized model
7
  tokenizer = AutoTokenizer.from_pretrained(path)
8
+ # Create inference pipeline for text classification
9
  self.pipeline = pipeline("text-classification", model=path, tokenizer=tokenizer)
10
 
11
  def __call__(self, data: str) -> List[List[Dict[str, float]]]:
 
17
  A list containing the prediction results:
18
  A list of one list, e.g., [[{"label": "LABEL", "score": 0.99}]]
19
  """
20
+ # Pass the data as `text` directly
21
+ prediction = self.pipeline(text=data)
22
 
23
  # Return the prediction result
24
  return prediction