File size: 4,701 Bytes
0b1b527
 
 
 
 
 
9b27ece
 
 
 
 
 
0b1b527
 
 
 
 
 
 
 
 
9b27ece
 
 
 
 
 
0b1b527
9b27ece
0b1b527
 
 
 
9b27ece
 
0b1b527
9b27ece
0b1b527
9b27ece
0b1b527
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9b27ece
0b1b527
 
9b27ece
 
0b1b527
 
 
9b27ece
 
 
 
 
 
 
 
 
 
 
 
 
 
0b1b527
9b27ece
0b1b527
 
 
 
 
 
 
 
 
9b27ece
 
 
 
 
 
 
 
 
 
 
 
0b1b527
 
 
 
 
 
9b27ece
0b1b527
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import gradio as gr
import pandas as pd

from constants import *


def get_data(verified, dataset, ipc, label_type, metric_weights=None):
    if metric_weights is None:
        metric_weights = [1.0 / len(METRICS) for _ in METRICS]
    if not isinstance(label_type, list):
        label_type = [label_type]

    data = pd.read_csv("data.csv")
    data["verified"] = data["verified"].apply(lambda x: bool(x))
    data["dataset"] = data["dataset"].apply(lambda x: DATASET_LIST[x])
    data["ipc"] = data["ipc"].apply(lambda x: IPC_LIST[x])
    data["label_type"] = data["label_type"].apply(lambda x: LABEL_TYPE_LIST[x])
    if verified:
        data = data[data["verified"] == verified]
    data = data[data["dataset"] == dataset]
    data = data[data["ipc"] == ipc]
    data = data[data["label_type"].apply(lambda x: x in label_type)]

    # create a new column for the score
    data["score"] = data[METRICS[0].lower()] * 0.0
    for i, metric in enumerate(METRICS):
        data["score"] += data[metric.lower()] * metric_weights[i]
    data = data.sort_values(by="score", ascending=False)
    data["ranking"] = range(1, len(data) + 1)

    # formatting
    data["method"] = "[" + data["method"] + "](" + data["method_reference"] + ")"
    data["verified"] = data["verified"].apply(lambda x: "✅" if x else "")
    data = data.drop(columns=["method_reference", "dataset", "ipc"])
    data = data[['ranking', 'method', 'verified', 'date', 'label_type', 'hlr', 'ior', 'score']]
    if label_type == "Hard Label":
        data = data.rename(columns={"ranking": "Ranking", "method": "Method", "date": "Date", "label_type": "Label Type", "hlr": "HLR↓", "ior": "IOR↑", "score": "Score", "verified": "Verified"})
    else:
        data = data.rename(columns={"ranking": "Ranking", "method": "Method", "date": "Date", "label_type": "Label Type", "hlr": "HLR↓", "ior": "IOR↑", "score": "Score", "verified": "Verified"})
    return data


with gr.Blocks() as leaderboard:
    gr.Markdown(LEADERBOARD_INTRODUCTION)

    verified = gr.Checkbox(
        label="Verified by DD-Ranking Team (Uncheck to view all submissions)",
        value=True,
        interactive=True
    )

    dataset = gr.Radio(
        label="Dataset",
        choices=DATASET_LIST,
        value=DATASET_LIST[0],
        interactive=True,
    )
    ipc = gr.Radio(
        label="IPC",
        choices=IPC_LIST,
        value=IPC_LIST[0],
        interactive=True,
        info=IPC_INFO
    )
    label = gr.CheckboxGroup(
        label="Label Type",
        choices=LABEL_TYPE_LIST,
        value=LABEL_TYPE_LIST,
        info=LABEL_TYPE_INFO,
        interactive=True,
    )

    with gr.Accordion("Adjust Score Weights", open=False):
        gr.Markdown(WEIGHT_ADJUSTMENT_INTRODUCTION, latex_delimiters=[
              {'left': '$$', 'right': '$$', 'display': True},
              {'left': '$', 'right': '$', 'display': False},
              {'left': '\\(', 'right': '\\)', 'display': False},
              {'left': '\\[', 'right': '\\]', 'display': True}
          ])
        metric_sliders = []
        for metric in METRICS:
            metric_sliders.append(gr.Slider(label=f"Weight for {metric}", minimum=0.0, maximum=1.0, value=0.5, interactive=True))
        adjust_btn = gr.Button("Adjust Weights")


    metric_weights = [s.value for s in metric_sliders]
    board = gr.components.Dataframe(
        value=get_data(verified.value, dataset.value, ipc.value, label.value, metric_weights),
        headers=COLUMN_NAMES,
        type="pandas",
        datatype=DATA_TITLE_TYPE,
        interactive=False,
        visible=True,
        max_height=500,
    )

    for component in [verified, dataset, ipc, label]:
        component.change(lambda v, d, i, l, *m: gr.components.Dataframe(
            value=get_data(v, d, i, l, [s for s in m]),
            headers=COLUMN_NAMES,
            type="pandas",
            datatype=DATA_TITLE_TYPE,
            interactive=False,
            visible=True,
            max_height=500,
        ), inputs=[verified, dataset, ipc, label] + metric_sliders, outputs=board)

    adjust_btn.click(fn=lambda v, d, i, l, *m: gr.components.Dataframe(
            value=get_data(v, d, i, l, [s for s in m]),
            headers=COLUMN_NAMES,
            type="pandas",
            datatype=DATA_TITLE_TYPE,
            interactive=False,
            visible=True,
            max_height=500,
        ), inputs=[verified, dataset, ipc, label] + metric_sliders, outputs=board)

    citation_button = gr.Textbox(
        value=CITATION_BUTTON_TEXT,
        label=CITATION_BUTTON_LABEL,
        elem_id="citation-button",
        lines=6,
        show_copy_button=True,
    )

leaderboard.launch()