Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,23 +3,45 @@ __all__ = ['block', 'make_clickable_model', 'make_clickable_user', 'get_submissi
|
|
3 |
import gradio as gr
|
4 |
import pandas as pd
|
5 |
import re
|
6 |
-
import pandas as pd
|
7 |
import os
|
8 |
import json
|
9 |
import yaml
|
|
|
10 |
|
11 |
from src.about import *
|
12 |
from src.bin.PROBE import run_probe
|
13 |
|
14 |
global data_component, filter_component
|
15 |
|
16 |
-
|
17 |
def get_baseline_df():
|
18 |
df = pd.read_csv(CSV_RESULT_PATH)
|
19 |
present_columns = ["Method"] + checkbox_group.value
|
20 |
df = df[present_columns]
|
21 |
return df
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
def add_new_eval(
|
25 |
human_file,
|
@@ -33,31 +55,43 @@ def add_new_eval(
|
|
33 |
family_prediction_dataset,
|
34 |
):
|
35 |
representation_name = model_name_textbox if revision_name_textbox == '' else revision_name_textbox
|
36 |
-
|
37 |
results = run_probe(benchmark_type, representation_name, human_file, skempi_file, similarity_tasks, function_prediction_aspect, function_prediction_dataset, family_prediction_dataset)
|
38 |
-
|
39 |
return None
|
40 |
|
41 |
block = gr.Blocks()
|
42 |
|
43 |
with block:
|
44 |
-
gr.Markdown(
|
45 |
-
|
46 |
-
)
|
47 |
with gr.Tabs(elem_classes="tab-buttons") as tabs:
|
48 |
# table jmmmu bench
|
49 |
with gr.TabItem("🏅 PROBE Benchmark", elem_id="probe-benchmark-tab-table", id=1):
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
checkbox_group = gr.CheckboxGroup(
|
52 |
choices=TASK_INFO,
|
53 |
label="Benchmark Type",
|
54 |
interactive=True,
|
55 |
-
)
|
56 |
-
|
57 |
baseline_value = get_baseline_df()
|
58 |
baseline_header = ["Method"] + checkbox_group.value
|
59 |
baseline_datatype = ['markdown'] + ['number'] * len(checkbox_group.value)
|
60 |
-
|
61 |
data_component = gr.components.Dataframe(
|
62 |
value=baseline_value,
|
63 |
headers=baseline_header,
|
@@ -65,7 +99,7 @@ with block:
|
|
65 |
datatype=baseline_datatype,
|
66 |
interactive=False,
|
67 |
visible=True,
|
68 |
-
|
69 |
|
70 |
# table 5
|
71 |
with gr.TabItem("📝 About", elem_id="probe-benchmark-tab-table", id=2):
|
@@ -83,11 +117,11 @@ with block:
|
|
83 |
with gr.Column():
|
84 |
model_name_textbox = gr.Textbox(
|
85 |
label="Model name",
|
86 |
-
|
87 |
revision_name_textbox = gr.Textbox(
|
88 |
label="Revision Model Name",
|
89 |
)
|
90 |
-
|
91 |
benchmark_type = gr.CheckboxGroup(
|
92 |
choices=TASK_INFO,
|
93 |
label="Benchmark Type",
|
@@ -99,21 +133,18 @@ with block:
|
|
99 |
interactive=True,
|
100 |
)
|
101 |
|
102 |
-
# Dropdown for function prediction aspect
|
103 |
function_prediction_aspect = gr.Radio(
|
104 |
choices=function_prediction_aspect_options,
|
105 |
label="Select Function Prediction Aspect",
|
106 |
interactive=True,
|
107 |
)
|
108 |
|
109 |
-
# Dropdown for function prediction dataset
|
110 |
function_prediction_dataset = gr.Radio(
|
111 |
choices=function_prediction_dataset_options,
|
112 |
label="Select Function Prediction Dataset",
|
113 |
interactive=True,
|
114 |
)
|
115 |
|
116 |
-
# Checkbox for family prediction dataset
|
117 |
family_prediction_dataset = gr.CheckboxGroup(
|
118 |
choices=family_prediction_dataset_options,
|
119 |
label="Select Family Prediction Dataset",
|
@@ -128,7 +159,7 @@ with block:
|
|
128 |
submission_result = gr.Markdown()
|
129 |
submit_button.click(
|
130 |
add_new_eval,
|
131 |
-
inputs
|
132 |
human_file,
|
133 |
skempi_file,
|
134 |
model_name_textbox,
|
@@ -143,14 +174,11 @@ with block:
|
|
143 |
|
144 |
def refresh_data():
|
145 |
value = get_baseline_df()
|
146 |
-
|
147 |
return value
|
148 |
|
149 |
with gr.Row():
|
150 |
data_run = gr.Button("Refresh")
|
151 |
-
data_run.click(
|
152 |
-
refresh_data, outputs=[data_component]
|
153 |
-
)
|
154 |
|
155 |
with gr.Accordion("Citation", open=False):
|
156 |
citation_button = gr.Textbox(
|
|
|
3 |
import gradio as gr
|
4 |
import pandas as pd
|
5 |
import re
|
|
|
6 |
import os
|
7 |
import json
|
8 |
import yaml
|
9 |
+
import matplotlib.pyplot as plt
|
10 |
|
11 |
from src.about import *
|
12 |
from src.bin.PROBE import run_probe
|
13 |
|
14 |
global data_component, filter_component
|
15 |
|
|
|
16 |
def get_baseline_df():
|
17 |
df = pd.read_csv(CSV_RESULT_PATH)
|
18 |
present_columns = ["Method"] + checkbox_group.value
|
19 |
df = df[present_columns]
|
20 |
return df
|
21 |
|
22 |
+
# Function to create the plot
|
23 |
+
def create_plot(methods_selected, x_metric, y_metric):
|
24 |
+
df = pd.read_csv(CSV_RESULT_PATH)
|
25 |
+
filtered_df = df[df['Method'].isin(methods_selected)]
|
26 |
+
|
27 |
+
# Create the plot
|
28 |
+
plt.figure(figsize=(8, 6))
|
29 |
+
for method in methods_selected:
|
30 |
+
method_data = filtered_df[filtered_df['Method'] == method]
|
31 |
+
plt.plot(method_data[x_metric], method_data[y_metric], label=method, marker='o')
|
32 |
+
|
33 |
+
plt.xlabel(x_metric)
|
34 |
+
plt.ylabel(y_metric)
|
35 |
+
plt.title(f'{y_metric} vs {x_metric} for selected methods')
|
36 |
+
plt.legend()
|
37 |
+
plt.grid(True)
|
38 |
+
|
39 |
+
# Save the plot to display it in Gradio
|
40 |
+
plot_path = "plot.png"
|
41 |
+
plt.savefig(plot_path)
|
42 |
+
plt.close()
|
43 |
+
|
44 |
+
return plot_path
|
45 |
|
46 |
def add_new_eval(
|
47 |
human_file,
|
|
|
55 |
family_prediction_dataset,
|
56 |
):
|
57 |
representation_name = model_name_textbox if revision_name_textbox == '' else revision_name_textbox
|
|
|
58 |
results = run_probe(benchmark_type, representation_name, human_file, skempi_file, similarity_tasks, function_prediction_aspect, function_prediction_dataset, family_prediction_dataset)
|
|
|
59 |
return None
|
60 |
|
61 |
block = gr.Blocks()
|
62 |
|
63 |
with block:
|
64 |
+
gr.Markdown(LEADERBOARD_INTRODUCTION)
|
65 |
+
|
|
|
66 |
with gr.Tabs(elem_classes="tab-buttons") as tabs:
|
67 |
# table jmmmu bench
|
68 |
with gr.TabItem("🏅 PROBE Benchmark", elem_id="probe-benchmark-tab-table", id=1):
|
69 |
+
|
70 |
+
# Add the visualizer components (Dropdown, Checkbox, Button, Image)
|
71 |
+
with gr.Row():
|
72 |
+
method_names = pd.read_csv(CSV_RESULT_PATH)['Method'].unique().tolist()
|
73 |
+
metric_names = pd.read_csv(CSV_RESULT_PATH).columns.tolist()
|
74 |
+
metric_names.remove('Method') # Remove Method from the metric options
|
75 |
+
|
76 |
+
method_selector = gr.CheckboxGroup(choices=method_names, label="Select Methods", interactive=True)
|
77 |
+
x_metric_selector = gr.Dropdown(choices=metric_names, label="Select X-axis Metric", interactive=True)
|
78 |
+
y_metric_selector = gr.Dropdown(choices=metric_names, label="Select Y-axis Metric", interactive=True)
|
79 |
+
plot_button = gr.Button("Plot")
|
80 |
+
output_plot = gr.Image(label="Plot")
|
81 |
+
|
82 |
+
plot_button.click(create_plot, inputs=[method_selector, x_metric_selector, y_metric_selector], outputs=output_plot)
|
83 |
+
|
84 |
+
# Now the rest of the UI elements as they were before
|
85 |
checkbox_group = gr.CheckboxGroup(
|
86 |
choices=TASK_INFO,
|
87 |
label="Benchmark Type",
|
88 |
interactive=True,
|
89 |
+
) # User can select the evaluation dimension
|
90 |
+
|
91 |
baseline_value = get_baseline_df()
|
92 |
baseline_header = ["Method"] + checkbox_group.value
|
93 |
baseline_datatype = ['markdown'] + ['number'] * len(checkbox_group.value)
|
94 |
+
|
95 |
data_component = gr.components.Dataframe(
|
96 |
value=baseline_value,
|
97 |
headers=baseline_header,
|
|
|
99 |
datatype=baseline_datatype,
|
100 |
interactive=False,
|
101 |
visible=True,
|
102 |
+
)
|
103 |
|
104 |
# table 5
|
105 |
with gr.TabItem("📝 About", elem_id="probe-benchmark-tab-table", id=2):
|
|
|
117 |
with gr.Column():
|
118 |
model_name_textbox = gr.Textbox(
|
119 |
label="Model name",
|
120 |
+
)
|
121 |
revision_name_textbox = gr.Textbox(
|
122 |
label="Revision Model Name",
|
123 |
)
|
124 |
+
|
125 |
benchmark_type = gr.CheckboxGroup(
|
126 |
choices=TASK_INFO,
|
127 |
label="Benchmark Type",
|
|
|
133 |
interactive=True,
|
134 |
)
|
135 |
|
|
|
136 |
function_prediction_aspect = gr.Radio(
|
137 |
choices=function_prediction_aspect_options,
|
138 |
label="Select Function Prediction Aspect",
|
139 |
interactive=True,
|
140 |
)
|
141 |
|
|
|
142 |
function_prediction_dataset = gr.Radio(
|
143 |
choices=function_prediction_dataset_options,
|
144 |
label="Select Function Prediction Dataset",
|
145 |
interactive=True,
|
146 |
)
|
147 |
|
|
|
148 |
family_prediction_dataset = gr.CheckboxGroup(
|
149 |
choices=family_prediction_dataset_options,
|
150 |
label="Select Family Prediction Dataset",
|
|
|
159 |
submission_result = gr.Markdown()
|
160 |
submit_button.click(
|
161 |
add_new_eval,
|
162 |
+
inputs=[
|
163 |
human_file,
|
164 |
skempi_file,
|
165 |
model_name_textbox,
|
|
|
174 |
|
175 |
def refresh_data():
|
176 |
value = get_baseline_df()
|
|
|
177 |
return value
|
178 |
|
179 |
with gr.Row():
|
180 |
data_run = gr.Button("Refresh")
|
181 |
+
data_run.click(refresh_data, outputs=[data_component])
|
|
|
|
|
182 |
|
183 |
with gr.Accordion("Citation", open=False):
|
184 |
citation_button = gr.Textbox(
|