AR04 commited on
Commit
cd4eb6d
·
verified ·
1 Parent(s): 92fbc97

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -19,17 +19,16 @@ def classify_and_visualize(text):
19
  outputs = classifier([text])[0] # list of dicts
20
  # Convert to DataFrame
21
  df = pd.DataFrame(outputs)
22
- df = df.sort_values("score", ascending=False)
23
 
24
- # Bar chart with plotly
25
- fig = px.bar(
26
  df,
27
- x="label",
28
- y="score",
29
- title="Emotion Scores",
30
- labels={"label": "Emotion", "score": "Probability"},
31
  )
32
- fig.update_layout(xaxis_tickangle=-45)
33
 
34
  return df.to_dict("records"), fig
35
 
@@ -46,4 +45,4 @@ with gr.Blocks() as demo:
46
  submit_btn.click(fn=classify_and_visualize, inputs=text_input, outputs=[result_json, result_plot])
47
 
48
  if __name__ == "__main__":
49
- demo.launch()
 
19
  outputs = classifier([text])[0] # list of dicts
20
  # Convert to DataFrame
21
  df = pd.DataFrame(outputs)
 
22
 
23
+ # Radar chart (polar plot)
24
+ fig = px.line_polar(
25
  df,
26
+ r="score",
27
+ theta="label",
28
+ line_close=True,
29
+ title="Emotion Radar",
30
  )
31
+ fig.update_traces(fill="toself", line=dict(color="blue"))
32
 
33
  return df.to_dict("records"), fig
34
 
 
45
  submit_btn.click(fn=classify_and_visualize, inputs=text_input, outputs=[result_json, result_plot])
46
 
47
  if __name__ == "__main__":
48
+ demo.launch()