Rakibul
commited on
Commit
·
e138277
1
Parent(s):
5a5588f
better ordering
Browse files
app.py
CHANGED
|
@@ -44,9 +44,9 @@ def ci_plot(mean: float, low: float, upp: float):
|
|
| 44 |
fig.tight_layout()
|
| 45 |
return fig
|
| 46 |
|
| 47 |
-
def predict_with_ci(
|
| 48 |
_warmup()
|
| 49 |
-
mean, var = predict(essay, article)
|
| 50 |
# scores were originally in [1, 7]
|
| 51 |
# lets scale them to [0, 100]
|
| 52 |
scale = 100 / 6
|
|
@@ -63,16 +63,16 @@ with gr.Blocks(title="UPLME", theme=Soft(primary_hue="blue")) as demo:
|
|
| 63 |
gr.Markdown("# Empathy Prediction with Uncertainty Estimation")
|
| 64 |
with gr.Row():
|
| 65 |
with gr.Column():
|
| 66 |
-
essay_input = gr.Textbox(label="Response (E.g., Essay) towards the stimulus", lines=6)
|
| 67 |
article_input = gr.Textbox(label="Stimulus (E.g., News Article)", lines=6)
|
|
|
|
| 68 |
button = gr.Button("Predict")
|
| 69 |
|
| 70 |
gr.Examples(
|
| 71 |
examples=[
|
| 72 |
-
["
|
| 73 |
-
["
|
| 74 |
],
|
| 75 |
-
inputs=[
|
| 76 |
)
|
| 77 |
|
| 78 |
with gr.Column():
|
|
@@ -82,7 +82,7 @@ with gr.Blocks(title="UPLME", theme=Soft(primary_hue="blue")) as demo:
|
|
| 82 |
|
| 83 |
fig = gr.Plot(show_label=False)
|
| 84 |
|
| 85 |
-
button.click(fn=predict_with_ci, inputs=[
|
| 86 |
|
| 87 |
gr.Markdown("## About")
|
| 88 |
gr.Markdown("""
|
|
|
|
| 44 |
fig.tight_layout()
|
| 45 |
return fig
|
| 46 |
|
| 47 |
+
def predict_with_ci(article: str, essay: str) -> tuple[float, float, float, plt.Figure]:
|
| 48 |
_warmup()
|
| 49 |
+
mean, var = predict(essay, article) # the order is essay-article in UPLME model
|
| 50 |
# scores were originally in [1, 7]
|
| 51 |
# lets scale them to [0, 100]
|
| 52 |
scale = 100 / 6
|
|
|
|
| 63 |
gr.Markdown("# Empathy Prediction with Uncertainty Estimation")
|
| 64 |
with gr.Row():
|
| 65 |
with gr.Column():
|
|
|
|
| 66 |
article_input = gr.Textbox(label="Stimulus (E.g., News Article)", lines=6)
|
| 67 |
+
essay_input = gr.Textbox(label="Response (E.g., Essay) towards the stimulus", lines=6)
|
| 68 |
button = gr.Button("Predict")
|
| 69 |
|
| 70 |
gr.Examples(
|
| 71 |
examples=[
|
| 72 |
+
["A month after Hurricane Matthew, 800,000 Haitians urgently need food.", "My heart just breaks for the people who are suffering."],
|
| 73 |
+
["A month after Hurricane Matthew, 800,000 Haitians urgently need food.", "I see, but this doesn't sound too worrisome to me."],
|
| 74 |
],
|
| 75 |
+
inputs=[article_input, essay_input]
|
| 76 |
)
|
| 77 |
|
| 78 |
with gr.Column():
|
|
|
|
| 82 |
|
| 83 |
fig = gr.Plot(show_label=False)
|
| 84 |
|
| 85 |
+
button.click(fn=predict_with_ci, inputs=[article_input, essay_input], outputs=[output_mean, ci_low, ci_upp, fig])
|
| 86 |
|
| 87 |
gr.Markdown("## About")
|
| 88 |
gr.Markdown("""
|