File size: 2,439 Bytes
3b63679
 
 
 
f2ac14c
3b63679
2b90ce4
c72c94b
3b63679
 
 
 
 
 
f2ac14c
6bdaded
 
f2ac14c
6bdaded
 
 
f2ac14c
6bdaded
 
 
f2ac14c
6bdaded
 
f2ac14c
6bdaded
 
 
 
f2ac14c
3b63679
 
 
6bdaded
3b63679
 
 
 
 
 
 
 
 
54d7724
 
3a0e0e8
f2ac14c
 
3b63679
 
 
f2ac14c
c72c94b
f2ac14c
 
 
 
 
 
 
 
 
3b63679
 
 
f2ac14c
3b63679
 
 
 
 
 
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
import gradio as gr
import pandas as pd
import requests
import io
from datetime import datetime

# csv file
CSV_URL = "https://docs.google.com/spreadsheets/d/e/2PACX-1vQ4tA2l1VQKBwymhfjMj0IbVTzQbpMEhLpfwOqVSOeea7_wqRAJzSq9V37Z39kjSsY_2M4Ve2Q6wJ9F/pub?output=csv"
# fetch data from google sheets
def fetch_leaderboard_data():
    try:
        response = requests.get(CSV_URL)
        response.raise_for_status()
        data = pd.read_csv(io.StringIO(response.text))

        # Normalize column names (lowercase & strip spaces)
        data.columns = data.columns.str.strip().str.lower()

        # Ensure "Rank" is treated as a number for sorting
        if 'rank' in data.columns:
            data['rank'] = pd.to_numeric(data['rank'], errors='coerce')

        # Handle date parsing (optional)
        if 'date and time' in data.columns:
            data['date and time'] = pd.to_datetime(data['date and time'], errors='coerce')

        # Sort by rank (ascending order)
        data = data.sort_values(by='rank', ascending=True)

        # Capitalize column names before returning
        data.columns = data.columns.str.title()

        return data

    except Exception as e:
        print(f"Error fetching data: {e}")
        return pd.DataFrame({"Error": ["Unable to fetch data"]})


# title for the leaderboard
title = """
<center>
<h1> IEEE Low-Power Computer Vision Challenge </h1>
<b> 2025 CVPR WORKSHOP </b>
</center>
"""

description = """ 
<p><b>Important:</b> The leaderboard only shows results from <b>registered teams</b>. Only the <b>last submission</b> from each team in the <b>previous day</b> will be evaluated.</p>
<p>Can't find your submission? Check <a href="https://szz1-failed-jobs.hf.space">Failed Jobs</a>.</p>
"""

# gradio app
def create_gradio_app():
    with gr.Blocks(theme="gradio/soft") as app:
        # gr.HTML(title) 
        # gr.HTML(description)

        with gr.Column():
            refresh_button = gr.Button("Refresh Leaderboard")
            leaderboard = gr.DataFrame(
                value=fetch_leaderboard_data(),
                interactive=False,
                label="Leaderboard",
            )

        refresh_button.click(lambda: fetch_leaderboard_data(), outputs=leaderboard)
    return app

# launch gradio app
def run_gradio_app():
    app = create_gradio_app()
    app.launch(server_name="0.0.0.0", server_port=7860, share=True)

if __name__ == "__main__":
    run_gradio_app()