douglasgoodwin commited on
Commit
4504b89
·
verified ·
1 Parent(s): b19ac64

bar plot emptyy

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -20,8 +20,10 @@ def classify_emotion(text):
20
  emotion_scores[item["label"]] = item["score"]
21
 
22
  # Create a dataframe for the bar plot
23
- df = pd.DataFrame.from_dict(emotion_scores, orient="index").reset_index()
24
- df.columns = ["Emotion", "Score"]
 
 
25
 
26
  # Prepare a text-based table for display
27
  table = "Emotion Scores:\n"
@@ -40,8 +42,8 @@ gr.Interface(
40
  ),
41
  outputs=[
42
  gr.BarPlot(
43
- x="Emotion",
44
- y="Score",
45
  label="Emotion Scores Bar Plot",
46
  title="Emotion Probabilities",
47
  color="#2563eb", # Color for the bars
@@ -50,10 +52,10 @@ gr.Interface(
50
  ),
51
  gr.Textbox(label="Emotion Scores Table") # Text-based table output
52
  ],
53
- title="CMACHINES25 | Emotion Detection with DistilBERT",
54
  description="This app uses the DistilBERT model fine-tuned for emotion detection. Enter a piece of text to analyze its emotional content! Both a bar plot and a text table of the scores will be displayed.",
55
  examples=[
56
- "I like you. I love you. Sometimes I hate you.",
57
  "I'm really angry about what happened.",
58
  "The sunset was absolutely beautiful today.",
59
  "I'm worried about the upcoming exam.",
 
20
  emotion_scores[item["label"]] = item["score"]
21
 
22
  # Create a dataframe for the bar plot
23
+ df = pd.DataFrame({
24
+ "Emotion": list(emotion_scores.keys()),
25
+ "Score": list(emotion_scores.values())
26
+ })
27
 
28
  # Prepare a text-based table for display
29
  table = "Emotion Scores:\n"
 
42
  ),
43
  outputs=[
44
  gr.BarPlot(
45
+ x="Emotion", # Correct column for x-axis
46
+ y="Score", # Correct column for y-axis
47
  label="Emotion Scores Bar Plot",
48
  title="Emotion Probabilities",
49
  color="#2563eb", # Color for the bars
 
52
  ),
53
  gr.Textbox(label="Emotion Scores Table") # Text-based table output
54
  ],
55
+ title="Emotion Detection with DistilBERT",
56
  description="This app uses the DistilBERT model fine-tuned for emotion detection. Enter a piece of text to analyze its emotional content! Both a bar plot and a text table of the scores will be displayed.",
57
  examples=[
58
+ "I am so happy to see you!",
59
  "I'm really angry about what happened.",
60
  "The sunset was absolutely beautiful today.",
61
  "I'm worried about the upcoming exam.",