Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,7 @@ import torch
|
|
6 |
import json
|
7 |
from gradio import ChatMessage
|
8 |
import os
|
|
|
9 |
|
10 |
IN_SPACE = bool(os.environ.get("SPACE_AUTHOR_NAME", False))
|
11 |
|
@@ -279,6 +280,13 @@ def show_chats(idx, df, file, all_check):
|
|
279 |
btn = gr.Button("Clear")
|
280 |
btn.click(lambda: gr.Textbox(value=""), None, text)
|
281 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
282 |
|
283 |
|
284 |
|
@@ -326,6 +334,9 @@ with gr.Blocks() as demo:
|
|
326 |
with gr.Column():
|
327 |
chat_b = gr.Chatbot(label="Model B", type="messages", height=1000)
|
328 |
|
|
|
|
|
|
|
329 |
lower_limit.change(
|
330 |
filter_df,
|
331 |
inputs=[lower_limit, upper_limit, file, all_check],
|
@@ -337,6 +348,8 @@ with gr.Blocks() as demo:
|
|
337 |
outputs=[idx, hidden_df],
|
338 |
)
|
339 |
|
|
|
|
|
340 |
idx.change(
|
341 |
show_chats,
|
342 |
inputs=[idx, hidden_df, file, all_check],
|
@@ -345,6 +358,8 @@ with gr.Blocks() as demo:
|
|
345 |
prev_btn.click(lambda x: max(0, x - 1), inputs=idx, outputs=idx)
|
346 |
next_btn.click(lambda x: x + 1, inputs=idx, outputs=idx)
|
347 |
|
|
|
|
|
348 |
|
349 |
if __name__ == "__main__":
|
350 |
demo.launch(debug=True)
|
|
|
6 |
import json
|
7 |
from gradio import ChatMessage
|
8 |
import os
|
9 |
+
import matplotlib.pyplot as plt
|
10 |
|
11 |
IN_SPACE = bool(os.environ.get("SPACE_AUTHOR_NAME", False))
|
12 |
|
|
|
280 |
btn = gr.Button("Clear")
|
281 |
btn.click(lambda: gr.Textbox(value=""), None, text)
|
282 |
|
283 |
+
def update_plot(df, file, all_check):
|
284 |
+
if all_check or file is None or file == "":
|
285 |
+
loss_col = "avg_loss"
|
286 |
+
else:
|
287 |
+
loss_col = f"loss_{exps[file]}"
|
288 |
+
|
289 |
+
return plt.hist(df[loss_col], bins=50)
|
290 |
|
291 |
|
292 |
|
|
|
334 |
with gr.Column():
|
335 |
chat_b = gr.Chatbot(label="Model B", type="messages", height=1000)
|
336 |
|
337 |
+
with gr.Row():
|
338 |
+
plot = gr.Plot()
|
339 |
+
|
340 |
lower_limit.change(
|
341 |
filter_df,
|
342 |
inputs=[lower_limit, upper_limit, file, all_check],
|
|
|
348 |
outputs=[idx, hidden_df],
|
349 |
)
|
350 |
|
351 |
+
hidden_df.change(update_plot, [hidden_df, file, all_check], plot)
|
352 |
+
|
353 |
idx.change(
|
354 |
show_chats,
|
355 |
inputs=[idx, hidden_df, file, all_check],
|
|
|
358 |
prev_btn.click(lambda x: max(0, x - 1), inputs=idx, outputs=idx)
|
359 |
next_btn.click(lambda x: x + 1, inputs=idx, outputs=idx)
|
360 |
|
361 |
+
|
362 |
+
|
363 |
|
364 |
if __name__ == "__main__":
|
365 |
demo.launch(debug=True)
|