Update handler.py
Browse files- handler.py +6 -6
handler.py
CHANGED
|
@@ -43,14 +43,14 @@ class EndpointHandler:
|
|
| 43 |
hate_speech_logits = outputs.get('hate_speech')
|
| 44 |
|
| 45 |
# Decode predictions from logits using argmax and the label encoders
|
| 46 |
-
emotion_preds = torch.argmax(emotion_logits, dim=1).cpu().numpy()
|
| 47 |
-
polarity_preds = torch.argmax(polarity_logits, dim=1).cpu().numpy()
|
| 48 |
-
hate_speech_preds = torch.argmax(hate_speech_logits, dim=1).cpu().numpy()
|
| 49 |
|
| 50 |
# Inverse transform the predictions to get human-readable labels
|
| 51 |
-
decoded_emotions = self.emotion_encoder.inverse_transform(emotion_preds)
|
| 52 |
-
decoded_polarities = self.polarity_encoder.inverse_transform(polarity_preds)
|
| 53 |
-
decoded_hate_speech = self.hate_speech_encoder.inverse_transform(hate_speech_preds)
|
| 54 |
|
| 55 |
# Return the decoded results as a dictionary
|
| 56 |
return {
|
|
|
|
| 43 |
hate_speech_logits = outputs.get('hate_speech')
|
| 44 |
|
| 45 |
# Decode predictions from logits using argmax and the label encoders
|
| 46 |
+
emotion_preds = torch.argmax(emotion_logits, dim=1).cpu().numpy().tolist()
|
| 47 |
+
polarity_preds = torch.argmax(polarity_logits, dim=1).cpu().numpy().tolist()
|
| 48 |
+
hate_speech_preds = torch.argmax(hate_speech_logits, dim=1).cpu().numpy().tolist()
|
| 49 |
|
| 50 |
# Inverse transform the predictions to get human-readable labels
|
| 51 |
+
decoded_emotions = self.emotion_encoder.inverse_transform(emotion_preds).tolist()
|
| 52 |
+
decoded_polarities = self.polarity_encoder.inverse_transform(polarity_preds).tolist()
|
| 53 |
+
decoded_hate_speech = self.hate_speech_encoder.inverse_transform(hate_speech_preds).tolist()
|
| 54 |
|
| 55 |
# Return the decoded results as a dictionary
|
| 56 |
return {
|