Update handler.py
Browse files- handler.py +7 -1
handler.py
CHANGED
|
@@ -2,9 +2,15 @@ from transformers import pipeline
|
|
| 2 |
from sklearn.preprocessing import LabelEncoder
|
| 3 |
import joblib
|
| 4 |
import torch
|
|
|
|
| 5 |
|
| 6 |
# Load the label encoder
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
# Load the model and tokenizer from Hugging Face
|
| 10 |
model_name = "SCANSKY/distilbertTourism-multilingual-sentiment"
|
|
|
|
| 2 |
from sklearn.preprocessing import LabelEncoder
|
| 3 |
import joblib
|
| 4 |
import torch
|
| 5 |
+
import os
|
| 6 |
|
| 7 |
# Load the label encoder
|
| 8 |
+
|
| 9 |
+
try:
|
| 10 |
+
label_encoder = joblib.load('/repository/label_encoder.pkl')
|
| 11 |
+
|
| 12 |
+
except error:
|
| 13 |
+
print("COULD NOT FIND LABEL_ENCODER. HERE'S THE CWD -->"+string(os.getcwd()))
|
| 14 |
|
| 15 |
# Load the model and tokenizer from Hugging Face
|
| 16 |
model_name = "SCANSKY/distilbertTourism-multilingual-sentiment"
|