Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 (
|
| 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 |
-
#
|
| 36 |
-
idx2label = {0: "negative", 1: "neutral", 2: "positive"}
|
| 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):
|