SCANSKY commited on
Commit
ff77f42
·
verified ·
1 Parent(s): 24bacd6

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +8 -3
handler.py CHANGED
@@ -6,11 +6,16 @@ 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"
 
6
 
7
  # Load the label encoder
8
 
9
+ from transformers import pipeline
10
+ from sklearn.preprocessing import LabelEncoder
11
+ import joblib
12
+ import torch
13
+ import os
14
+
15
  try:
16
  label_encoder = joblib.load('/repository/label_encoder.pkl')
17
+ except Exception as e:
18
+ raise FileNotFoundError("Label encoder file not found: /repository/label_encoder.pkl in cwd " os.getcwd()) #Raise a file not found error.
 
19
 
20
  # Load the model and tokenizer from Hugging Face
21
  model_name = "SCANSKY/distilbertTourism-multilingual-sentiment"