Update app.py
Browse files
app.py
CHANGED
@@ -20,6 +20,8 @@ def emotion(file_path):
|
|
20 |
if file_path:
|
21 |
# Classify the file
|
22 |
out_prob, score, index, text_lab = classifier.classify_file(file_path)
|
|
|
|
|
23 |
# Map the original labels to the desired categories
|
24 |
emotion_mapping = {
|
25 |
'neu': 'Neutral',
|
@@ -28,6 +30,8 @@ def emotion(file_path):
|
|
28 |
'sad': 'Sadness'
|
29 |
}
|
30 |
# Get the corresponding category from the mapping
|
|
|
|
|
31 |
emotion_category = emotion_mapping.get(text_lab, 'Unknown')
|
32 |
# Return the emotion category
|
33 |
st.write(emotion_category)
|
|
|
20 |
if file_path:
|
21 |
# Classify the file
|
22 |
out_prob, score, index, text_lab = classifier.classify_file(file_path)
|
23 |
+
if isinstance(text_lab, list):
|
24 |
+
text_lab = text_lab[0]
|
25 |
# Map the original labels to the desired categories
|
26 |
emotion_mapping = {
|
27 |
'neu': 'Neutral',
|
|
|
30 |
'sad': 'Sadness'
|
31 |
}
|
32 |
# Get the corresponding category from the mapping
|
33 |
+
emotion_category = emotion_mapping.get(text_lab, 'Unknown')
|
34 |
+
|
35 |
emotion_category = emotion_mapping.get(text_lab, 'Unknown')
|
36 |
# Return the emotion category
|
37 |
st.write(emotion_category)
|