Soptq commited on
Commit
97e4cd0
·
verified ·
1 Parent(s): be4b0eb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -7
app.py CHANGED
@@ -21,6 +21,9 @@ def get_data(verified, dataset, ipc, label_type, metric_weights=None):
21
  data = data[data["ipc"] == ipc]
22
  data = data[data["label_type"].apply(lambda x: x in label_type)]
23
 
 
 
 
24
  # create a new column for the score
25
  data["score"] = data[METRICS[0].lower()] * 0.0
26
  for i, metric in enumerate(METRICS):
@@ -45,6 +48,7 @@ def get_data(verified, dataset, ipc, label_type, metric_weights=None):
45
 
46
 
47
  with gr.Blocks() as leaderboard:
 
48
  gr.Markdown(LEADERBOARD_INTRODUCTION)
49
 
50
  verified = gr.Checkbox(
@@ -61,8 +65,8 @@ with gr.Blocks() as leaderboard:
61
  )
62
  ipc = gr.Radio(
63
  label="IPC",
64
- choices=IPC_LIST,
65
- value=IPC_LIST[0],
66
  interactive=True,
67
  info=IPC_INFO
68
  )
@@ -82,12 +86,15 @@ with gr.Blocks() as leaderboard:
82
  {'left': '\\[', 'right': '\\]', 'display': True}
83
  ])
84
  metric_sliders = []
85
- for metric in METRICS:
86
- metric_sliders.append(gr.Slider(label=f"Weight for {metric}", minimum=0.0, maximum=1.0, value=0.5, interactive=True))
 
 
87
  adjust_btn = gr.Button("Adjust Weights")
88
 
89
 
90
- metric_weights = [s.value for s in metric_sliders]
 
91
  board = gr.components.Dataframe(
92
  value=get_data(verified.value, dataset.value, ipc.value, label.value, metric_weights),
93
  headers=COLUMN_NAMES,
@@ -100,7 +107,7 @@ with gr.Blocks() as leaderboard:
100
 
101
  for component in [verified, dataset, ipc, label]:
102
  component.change(lambda v, d, i, l, *m: gr.components.Dataframe(
103
- value=get_data(v, d, i, l, [s for s in m]),
104
  headers=COLUMN_NAMES,
105
  type="pandas",
106
  datatype=DATA_TITLE_TYPE,
@@ -109,8 +116,16 @@ with gr.Blocks() as leaderboard:
109
  max_height=500,
110
  ), inputs=[verified, dataset, ipc, label] + metric_sliders, outputs=board)
111
 
 
 
 
 
 
 
 
 
112
  adjust_btn.click(fn=lambda v, d, i, l, *m: gr.components.Dataframe(
113
- value=get_data(v, d, i, l, [s for s in m]),
114
  headers=COLUMN_NAMES,
115
  type="pandas",
116
  datatype=DATA_TITLE_TYPE,
 
21
  data = data[data["ipc"] == ipc]
22
  data = data[data["label_type"].apply(lambda x: x in label_type)]
23
 
24
+ if len(data) == 0:
25
+ return pd.DataFrame(columns=COLUMN_NAMES)
26
+
27
  # create a new column for the score
28
  data["score"] = data[METRICS[0].lower()] * 0.0
29
  for i, metric in enumerate(METRICS):
 
48
 
49
 
50
  with gr.Blocks() as leaderboard:
51
+ gr.HTML(LEADERBOARD_HEADER)
52
  gr.Markdown(LEADERBOARD_INTRODUCTION)
53
 
54
  verified = gr.Checkbox(
 
65
  )
66
  ipc = gr.Radio(
67
  label="IPC",
68
+ choices=DATASET_IPC_LIST[dataset.value],
69
+ value=DATASET_IPC_LIST[dataset.value][0],
70
  interactive=True,
71
  info=IPC_INFO
72
  )
 
86
  {'left': '\\[', 'right': '\\]', 'display': True}
87
  ])
88
  metric_sliders = []
89
+ # for metric in METRICS:
90
+ # metric_sliders.append(gr.Slider(label=f"Weight for {metric}", minimum=0.0, maximum=1.0, value=0.5, interactive=True))
91
+ metric_sliders.append(
92
+ gr.Slider(label=f"Weight for HLR", minimum=0.0, maximum=1.0, value=0.5, interactive=True))
93
  adjust_btn = gr.Button("Adjust Weights")
94
 
95
 
96
+ # metric_weights = [s.value for s in metric_sliders]
97
+ metric_weights = [metric_sliders[0].value, 1.0 - metric_sliders[0].value]
98
  board = gr.components.Dataframe(
99
  value=get_data(verified.value, dataset.value, ipc.value, label.value, metric_weights),
100
  headers=COLUMN_NAMES,
 
107
 
108
  for component in [verified, dataset, ipc, label]:
109
  component.change(lambda v, d, i, l, *m: gr.components.Dataframe(
110
+ value=get_data(v, d, i, l, [m[0], 1.0 - m[0]]),
111
  headers=COLUMN_NAMES,
112
  type="pandas",
113
  datatype=DATA_TITLE_TYPE,
 
116
  max_height=500,
117
  ), inputs=[verified, dataset, ipc, label] + metric_sliders, outputs=board)
118
 
119
+ dataset.change(lambda d, i: gr.Radio(
120
+ label="IPC",
121
+ choices=DATASET_IPC_LIST[d],
122
+ value=i if i in DATASET_IPC_LIST[d] else DATASET_IPC_LIST[d][0],
123
+ interactive=True,
124
+ info=IPC_INFO
125
+ ), inputs=[dataset, ipc], outputs=ipc)
126
+
127
  adjust_btn.click(fn=lambda v, d, i, l, *m: gr.components.Dataframe(
128
+ value=get_data(v, d, i, l, [m[0], 1.0 - m[0]]),
129
  headers=COLUMN_NAMES,
130
  type="pandas",
131
  datatype=DATA_TITLE_TYPE,