Rakibul
commited on
Commit
·
3763495
1
Parent(s):
71f6562
fixed plot
Browse files- .gitignore +2 -0
- app.py +7 -7
.gitignore
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.gradio/
|
| 2 |
+
__pycache__/
|
app.py
CHANGED
|
@@ -27,13 +27,13 @@ def _warmup():
|
|
| 27 |
return f"Model loaded in {time.time() - t0:.1f} seconds."
|
| 28 |
|
| 29 |
def ci_plot(mean: float, low: float, upp: float):
|
| 30 |
-
fig, ax = plt.subplots(figsize=(6, 1))
|
| 31 |
-
ax.
|
| 32 |
-
ax.
|
| 33 |
-
ax.plot([mean], [
|
| 34 |
ax.set_xlim(0, 100)
|
| 35 |
ax.set_yticks([])
|
| 36 |
-
ax.set_xlabel("Empathy Score (0-100)")
|
| 37 |
fig.tight_layout()
|
| 38 |
return fig
|
| 39 |
|
|
@@ -63,7 +63,7 @@ with gr.Blocks(title="UPLME", theme=Soft(primary_hue="blue")) as demo:
|
|
| 63 |
ci_low = gr.Number(label="95% CI Lower Bound", precision=2)
|
| 64 |
ci_upp = gr.Number(label="95% CI Upper Bound", precision=2)
|
| 65 |
|
| 66 |
-
fig = gr.Plot(
|
| 67 |
|
| 68 |
button.click(fn=predict_with_ci, inputs=[essay_input, article_input], outputs=[output_mean, ci_low, ci_upp, fig])
|
| 69 |
|
|
@@ -75,4 +75,4 @@ with gr.Blocks(title="UPLME", theme=Soft(primary_hue="blue")) as demo:
|
|
| 75 |
""")
|
| 76 |
|
| 77 |
if __name__ == "__main__":
|
| 78 |
-
demo.launch()
|
|
|
|
| 27 |
return f"Model loaded in {time.time() - t0:.1f} seconds."
|
| 28 |
|
| 29 |
def ci_plot(mean: float, low: float, upp: float):
|
| 30 |
+
fig, ax = plt.subplots(figsize=(6, 1.6))
|
| 31 |
+
ax.barh(y=0, width=100, linewidth=2, alpha=0.15)
|
| 32 |
+
ax.barh(y=0, width=max(0, upp-low), height=0.5)
|
| 33 |
+
ax.plot([mean], [0], "o")
|
| 34 |
ax.set_xlim(0, 100)
|
| 35 |
ax.set_yticks([])
|
| 36 |
+
ax.set_xlabel("Empathy Score (0-100) +/- 95% CI")
|
| 37 |
fig.tight_layout()
|
| 38 |
return fig
|
| 39 |
|
|
|
|
| 63 |
ci_low = gr.Number(label="95% CI Lower Bound", precision=2)
|
| 64 |
ci_upp = gr.Number(label="95% CI Upper Bound", precision=2)
|
| 65 |
|
| 66 |
+
fig = gr.Plot(show_label=False)
|
| 67 |
|
| 68 |
button.click(fn=predict_with_ci, inputs=[essay_input, article_input], outputs=[output_mean, ci_low, ci_upp, fig])
|
| 69 |
|
|
|
|
| 75 |
""")
|
| 76 |
|
| 77 |
if __name__ == "__main__":
|
| 78 |
+
demo.launch(share=True)
|