MarkusWesterwald commited on
Commit
a50b214
·
1 Parent(s): 801c7cf

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +4 -4
handler.py CHANGED
@@ -84,7 +84,7 @@ class EndpointHandler:
84
  # run normal prediction
85
  scores = self.model.predict_proba(inputs)[0]
86
 
87
- return [
88
- {"label": self.id2label[i], "score": score.item()}
89
- for i, score in enumerate(scores)
90
- ]
 
84
  # run normal prediction
85
  scores = self.model.predict_proba(inputs)[0]
86
 
87
+ # get index of element with highest score
88
+ max_index = scores.argmax()
89
+
90
+ return {"label": self.id2label[max_index], "score": scores[max_index].item()}