Spaces:
Runtime error
Runtime error
Amit Kumar commited on
Commit ·
fc9a6cd
1
Parent(s): 726e612
working initial data, test subsequent data
Browse files
app.py
CHANGED
|
@@ -41,35 +41,34 @@ with gr.Blocks() as demo:
|
|
| 41 |
columns_variable = [i for i in all_columns if i not in columns_fixed]
|
| 42 |
|
| 43 |
shot_options = ["0 shot", "1 shot", "5 shots"]
|
| 44 |
-
|
| 45 |
|
| 46 |
def get_columns_for_shots(selected_shots):
|
| 47 |
if not selected_shots:
|
| 48 |
-
return
|
| 49 |
-
return
|
| 50 |
|
| 51 |
def get_columns_for_data(selected_data):
|
| 52 |
if not selected_data:
|
| 53 |
-
return
|
| 54 |
-
return
|
| 55 |
|
| 56 |
# data_types = sorted(df["data_type"].dropna().unique())
|
| 57 |
parameter_options = sorted(df["Parameters"].dropna().unique())
|
| 58 |
|
| 59 |
def filter_leaderboard(selected_params, selected_shots, selected_data):
|
| 60 |
filtered = df.copy()
|
| 61 |
-
|
| 62 |
if selected_params:
|
| 63 |
filtered = filtered[filtered["Parameters"].isin(selected_params)]
|
| 64 |
|
| 65 |
-
# Determine which columns to show
|
| 66 |
columns_by_shot = get_columns_for_shots(selected_shots)
|
| 67 |
columns_by_data = get_columns_for_data(selected_data)
|
| 68 |
-
additional_columns = [col for col in columns_by_shot + columns_by_data if col in
|
| 69 |
-
|
| 70 |
-
# Always include fixed columns
|
| 71 |
cols_to_show = list(dict.fromkeys(columns_fixed + additional_columns))
|
| 72 |
-
|
|
|
|
|
|
|
| 73 |
return filtered[cols_to_show]
|
| 74 |
|
| 75 |
|
|
@@ -88,10 +87,10 @@ with gr.Blocks() as demo:
|
|
| 88 |
# data_type_filter = gr.CheckboxGroup(choices=data_types, label="Filter by Data Type")
|
| 89 |
|
| 90 |
|
| 91 |
-
|
| 92 |
-
leaderboard_table = gr.Dataframe(label="🏅 Leaderboard", interactive=False)
|
| 93 |
# Initialize table
|
| 94 |
-
|
| 95 |
# dataset_filter.change(
|
| 96 |
# fn=update_leaderboard,
|
| 97 |
# inputs=[column_selector, dataset_filter],
|
|
@@ -104,7 +103,7 @@ with gr.Blocks() as demo:
|
|
| 104 |
param_filter.change(fn=filter_leaderboard, inputs=[param_filter, shot_filter, column_selector_data,], outputs=leaderboard_table)
|
| 105 |
shot_filter.change(fn=filter_leaderboard, inputs=[param_filter, shot_filter, column_selector_data,], outputs=leaderboard_table)
|
| 106 |
|
| 107 |
-
|
| 108 |
print(leaderboard_table.value)
|
| 109 |
|
| 110 |
demo.launch()
|
|
|
|
| 41 |
columns_variable = [i for i in all_columns if i not in columns_fixed]
|
| 42 |
|
| 43 |
shot_options = ["0 shot", "1 shot", "5 shots"]
|
| 44 |
+
|
| 45 |
|
| 46 |
def get_columns_for_shots(selected_shots):
|
| 47 |
if not selected_shots:
|
| 48 |
+
return []
|
| 49 |
+
return [col for col in all_columns if any(shot in col for shot in selected_shots)]
|
| 50 |
|
| 51 |
def get_columns_for_data(selected_data):
|
| 52 |
if not selected_data:
|
| 53 |
+
return []
|
| 54 |
+
return [col for col in all_columns if any(data in col for data in selected_data)]
|
| 55 |
|
| 56 |
# data_types = sorted(df["data_type"].dropna().unique())
|
| 57 |
parameter_options = sorted(df["Parameters"].dropna().unique())
|
| 58 |
|
| 59 |
def filter_leaderboard(selected_params, selected_shots, selected_data):
|
| 60 |
filtered = df.copy()
|
| 61 |
+
print("Selected Shots:", selected_shots)
|
| 62 |
if selected_params:
|
| 63 |
filtered = filtered[filtered["Parameters"].isin(selected_params)]
|
| 64 |
|
|
|
|
| 65 |
columns_by_shot = get_columns_for_shots(selected_shots)
|
| 66 |
columns_by_data = get_columns_for_data(selected_data)
|
| 67 |
+
additional_columns = [col for col in columns_by_shot + columns_by_data if col in df.columns]
|
|
|
|
|
|
|
| 68 |
cols_to_show = list(dict.fromkeys(columns_fixed + additional_columns))
|
| 69 |
+
|
| 70 |
+
print("COLUMNS TO SHOW:", cols_to_show)
|
| 71 |
+
|
| 72 |
return filtered[cols_to_show]
|
| 73 |
|
| 74 |
|
|
|
|
| 87 |
# data_type_filter = gr.CheckboxGroup(choices=data_types, label="Filter by Data Type")
|
| 88 |
|
| 89 |
|
| 90 |
+
initial_data = filter_leaderboard(parameter_options, shot_options, ["Chexpert Plus", "CT Rate"])
|
| 91 |
+
leaderboard_table = gr.Dataframe(value=initial_data, label="🏅 Leaderboard", interactive=False)
|
| 92 |
# Initialize table
|
| 93 |
+
|
| 94 |
# dataset_filter.change(
|
| 95 |
# fn=update_leaderboard,
|
| 96 |
# inputs=[column_selector, dataset_filter],
|
|
|
|
| 103 |
param_filter.change(fn=filter_leaderboard, inputs=[param_filter, shot_filter, column_selector_data,], outputs=leaderboard_table)
|
| 104 |
shot_filter.change(fn=filter_leaderboard, inputs=[param_filter, shot_filter, column_selector_data,], outputs=leaderboard_table)
|
| 105 |
|
| 106 |
+
# leaderboard_table.value = filter_leaderboard(parameter_options, shot_options, ["Chexpert Plus", "CT Rate"])
|
| 107 |
print(leaderboard_table.value)
|
| 108 |
|
| 109 |
demo.launch()
|