GMCTech commited on
Commit
4d02817
·
verified ·
1 Parent(s): 9399b88

Update app.py | Remove confidence

Browse files
Files changed (1) hide show
  1. app.py +4 -12
app.py CHANGED
@@ -16,18 +16,16 @@ def predict_sentiment(text):
16
  predicted_class = torch.argmax(predictions, dim=1).item()
17
 
18
  sentiment_map = {0: "NEGATIVE", 1: "NEUTRAL", 2: "POSITIVE"}
19
- confidence = predictions[0][predicted_class].item()
20
 
21
  # Format each output separately
22
  sentiment_output = f"{sentiment_map[predicted_class]}"
23
- confidence_output = f"{confidence:.3f}"
24
  probabilities_output = (
25
  f"Negative: {predictions[0][0]:.3f}\n"
26
  f"Neutral: {predictions[0][1]:.3f}\n"
27
  f"Positive: {predictions[0][2]:.3f}"
28
  )
29
 
30
- return sentiment_output, confidence_output, probabilities_output
31
 
32
  # Define Gradio Interface with 3 separate outputs
33
  with gr.Blocks(theme="soft") as demo:
@@ -58,12 +56,6 @@ with gr.Blocks(theme="soft") as demo:
58
  max_lines=5,
59
  interactive=False
60
  )
61
- confidence_box = gr.Textbox(
62
- label="Confidence",
63
- lines=3,
64
- max_lines=5,
65
- interactive=False
66
- )
67
  probabilities_box = gr.Textbox(
68
  label="Raw Probabilities",
69
  lines=6,
@@ -75,13 +67,13 @@ with gr.Blocks(theme="soft") as demo:
75
  submit_btn.click(
76
  fn=predict_sentiment,
77
  inputs=input_box,
78
- outputs=[sentiment_box, confidence_box, probabilities_box]
79
  )
80
 
81
  clear_btn.click(
82
  fn=lambda: ("", "", ""),
83
  inputs=None,
84
- outputs=[input_box, sentiment_box, confidence_box, probabilities_box]
85
  )
86
 
87
  # Add examples below
@@ -94,7 +86,7 @@ with gr.Blocks(theme="soft") as demo:
94
  ["Ganda legit, kumpleto... problema lang nainit ng sobra..."]
95
  ],
96
  inputs=input_box,
97
- outputs=[sentiment_box, confidence_box, probabilities_box],
98
  label="Example Sentences"
99
  )
100
 
 
16
  predicted_class = torch.argmax(predictions, dim=1).item()
17
 
18
  sentiment_map = {0: "NEGATIVE", 1: "NEUTRAL", 2: "POSITIVE"}
 
19
 
20
  # Format each output separately
21
  sentiment_output = f"{sentiment_map[predicted_class]}"
 
22
  probabilities_output = (
23
  f"Negative: {predictions[0][0]:.3f}\n"
24
  f"Neutral: {predictions[0][1]:.3f}\n"
25
  f"Positive: {predictions[0][2]:.3f}"
26
  )
27
 
28
+ return sentiment_output, probabilities_output
29
 
30
  # Define Gradio Interface with 3 separate outputs
31
  with gr.Blocks(theme="soft") as demo:
 
56
  max_lines=5,
57
  interactive=False
58
  )
 
 
 
 
 
 
59
  probabilities_box = gr.Textbox(
60
  label="Raw Probabilities",
61
  lines=6,
 
67
  submit_btn.click(
68
  fn=predict_sentiment,
69
  inputs=input_box,
70
+ outputs=[sentiment_box, probabilities_box]
71
  )
72
 
73
  clear_btn.click(
74
  fn=lambda: ("", "", ""),
75
  inputs=None,
76
+ outputs=[input_box, sentiment_box, probabilities_box]
77
  )
78
 
79
  # Add examples below
 
86
  ["Ganda legit, kumpleto... problema lang nainit ng sobra..."]
87
  ],
88
  inputs=input_box,
89
+ outputs=[sentiment_box, probabilities_box],
90
  label="Example Sentences"
91
  )
92