File size: 1,681 Bytes
212696e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
from pathlib import Path

import pandas as pd
import requests
import streamlit as st
from dotenv import load_dotenv

if Path(".env").is_file():
    load_dotenv(".env")


def download_submissions():
    auth_token = os.getenv("HF_HUB_TOKEN")
    header = {"Authorization": "Bearer " + auth_token}
    response = requests.get("http://huggingface.co/api/datasets", headers=header)
    all_datasets = response.json()

    submissions = []

    for dataset in all_datasets:
        is_benchmark = any([t for t in dataset["tags"] if t.split(":")[1] == "neelalex/raft-test"])
        if is_benchmark:
            submissions.append(dataset)

    for submission in submissions:
        submission_id = submission["id"]
        response = requests.get(
            f"http://huggingface.co/api/datasets/{submission_id}?full=true",
            headers=header,
        )
        data = response.json()
        submission_data = {"Team Name": [data["card_data"]["submission_dataset"].split("/")[0]]}
        for task in data["card_data"]["model-index"]:
            for task_name, splits in task.items():
                for split in splits:
                    if split["split"] == "test":
                        for metric in split["metrics"]:
                            if metric["name"] == "f1":
                                submission_data[task_name] = [metric["value"]]

    return pd.DataFrame(submission_data)


###########
### APP ###
###########
st.set_page_config(layout="wide")
st.title("RAFT Leaderboard")
df = download_submissions()
# hack to remove index column from https://github.com/streamlit/streamlit/issues/641
st.table(df.assign(hack="").set_index("hack"))