Update app.py
Browse files
app.py
CHANGED
|
@@ -177,13 +177,14 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue")) as demo:
|
|
| 177 |
analyze_button = gr.Button("Analyze Tone", variant="primary")
|
| 178 |
|
| 179 |
with gr.Column(scale=2):
|
|
|
|
| 180 |
tone_dropdown = gr.Dropdown(
|
| 181 |
choices=sorted(df['label'].unique().tolist()),
|
| 182 |
label="Select a tone to view an example below."
|
| 183 |
)
|
| 184 |
|
| 185 |
gr.Markdown("<br>", elem_id="line-break-1")
|
| 186 |
-
|
| 187 |
with gr.Row():
|
| 188 |
with gr.Column(scale=1):
|
| 189 |
result_message = gr.Markdown()
|
|
@@ -191,22 +192,22 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue")) as demo:
|
|
| 191 |
with gr.Row():
|
| 192 |
with gr.Column(scale=2):
|
| 193 |
plot_output = gr.Plot(label="Tone Probabilities")
|
| 194 |
-
|
|
|
|
|
|
|
| 195 |
with gr.Row():
|
| 196 |
examples_output = gr.Dataframe(
|
| 197 |
headers=["Examples of similar texts"],
|
| 198 |
datatype=["str"],
|
| 199 |
label="Example texts with similar tone"
|
| 200 |
)
|
| 201 |
-
|
| 202 |
-
# Button callback
|
| 203 |
analyze_button.click(
|
| 204 |
fn=analyze_tone,
|
| 205 |
inputs=[text_input, tone_dropdown],
|
| 206 |
-
outputs=[result_message, plot_output, examples_output]
|
| 207 |
)
|
| 208 |
|
| 209 |
-
# Dropdown change
|
| 210 |
tone_dropdown.change(
|
| 211 |
fn=get_tone_examples,
|
| 212 |
inputs=tone_dropdown,
|
|
|
|
| 177 |
analyze_button = gr.Button("Analyze Tone", variant="primary")
|
| 178 |
|
| 179 |
with gr.Column(scale=2):
|
| 180 |
+
# Example Tones Dropdown
|
| 181 |
tone_dropdown = gr.Dropdown(
|
| 182 |
choices=sorted(df['label'].unique().tolist()),
|
| 183 |
label="Select a tone to view an example below."
|
| 184 |
)
|
| 185 |
|
| 186 |
gr.Markdown("<br>", elem_id="line-break-1")
|
| 187 |
+
|
| 188 |
with gr.Row():
|
| 189 |
with gr.Column(scale=1):
|
| 190 |
result_message = gr.Markdown()
|
|
|
|
| 192 |
with gr.Row():
|
| 193 |
with gr.Column(scale=2):
|
| 194 |
plot_output = gr.Plot(label="Tone Probabilities")
|
| 195 |
+
with gr.Column(scale=1):
|
| 196 |
+
all_probs_output = gr.JSON(label="All Probabilities")
|
| 197 |
+
|
| 198 |
with gr.Row():
|
| 199 |
examples_output = gr.Dataframe(
|
| 200 |
headers=["Examples of similar texts"],
|
| 201 |
datatype=["str"],
|
| 202 |
label="Example texts with similar tone"
|
| 203 |
)
|
| 204 |
+
|
|
|
|
| 205 |
analyze_button.click(
|
| 206 |
fn=analyze_tone,
|
| 207 |
inputs=[text_input, tone_dropdown],
|
| 208 |
+
outputs=[result_message, all_probs_output, plot_output, examples_output]
|
| 209 |
)
|
| 210 |
|
|
|
|
| 211 |
tone_dropdown.change(
|
| 212 |
fn=get_tone_examples,
|
| 213 |
inputs=tone_dropdown,
|