ma4389 commited on
Commit
e8d47b0
·
verified ·
1 Parent(s): 81385ba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -7,7 +7,7 @@ from nltk.tokenize import word_tokenize
7
  from nltk.corpus import stopwords
8
  from nltk.stem import WordNetLemmatizer
9
 
10
- # Download NLTK resources (optional if already available)
11
  nltk.download('punkt_tab')
12
  nltk.download('stopwords')
13
  nltk.download('wordnet')
@@ -32,8 +32,8 @@ model = DistilBertForSequenceClassification.from_pretrained("distilbert-base-unc
32
  model.load_state_dict(torch.load("sent_model.pth", map_location=torch.device("cpu")))
33
  model.eval()
34
 
35
- # Label mapping
36
- idx2label = {0: "negative", 1: "neutral", 2: "positive"} # Update if needed
37
 
38
  # Prediction function
39
  def predict(text):
 
7
  from nltk.corpus import stopwords
8
  from nltk.stem import WordNetLemmatizer
9
 
10
+ # Download NLTK resources (if not already available)
11
  nltk.download('punkt_tab')
12
  nltk.download('stopwords')
13
  nltk.download('wordnet')
 
32
  model.load_state_dict(torch.load("sent_model.pth", map_location=torch.device("cpu")))
33
  model.eval()
34
 
35
+ # Correct label mapping based on LabelEncoder
36
+ idx2label = {0: "negative", 1: "neutral", 2: "positive"}
37
 
38
  # Prediction function
39
  def predict(text):