File size: 5,280 Bytes
88d91f4
383512a
059d8f0
a1f3b5b
3850b6d
383512a
 
88d91f4
 
 
e653f9c
b774671
 
383512a
fb67b80
88d91f4
 
 
e9f37ce
383512a
88d91f4
383512a
 
a51fb44
 
 
 
 
 
 
 
383512a
 
f6931eb
383512a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
da681e8
 
 
 
 
 
383512a
 
 
 
 
 
 
 
 
 
 
 
e653f9c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
383512a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7216d20
 
9681540
 
 
 
17ddb08
9681540
a9fec77
 
 
 
 
 
7216d20
 
 
 
 
383512a
 
88d91f4
 
f6931eb
1347af3
 
88d91f4
f6931eb
88d91f4
 
f6931eb
88d91f4
f6931eb
88d91f4
 
 
0496749
3850b6d
 
 
 
 
 
 
 
 
 
 
65e3d4b
3850b6d
 
059d8f0
6b1339b
3850b6d
 
1c34187
 
 
 
 
 
3850b6d
 
 
383512a
 
f6931eb
383512a
f6931eb
 
383512a
f6931eb
 
383512a
58a3f61
 
f6931eb
 
 
 
 
 
 
 
f6889a3
 
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
import os
import json
import requests

import datetime
import gradio as gr
import pandas as pd
from huggingface_hub import HfApi, hf_hub_download, snapshot_download
from huggingface_hub.repocard import metadata_load
from apscheduler.schedulers.background import BackgroundScheduler

from tqdm.contrib.concurrent import thread_map

from utils import *

DATASET_REPO_URL = "https://huggingface.co/datasets/huggingface-projects/drlc-leaderboard-data"
DATASET_REPO_ID = "huggingface-projects/drlc-leaderboard-data"
HF_TOKEN = os.environ.get("HF_TOKEN")

block = gr.Blocks()
api = HfApi(token=HF_TOKEN)

# Containing the data
rl_envs = [
{
"rl_env_beautiful": "LunarLander-v2 πŸš€",
"rl_env": "LunarLander-v2",
"video_link": "",
"global": None
},    
{
"rl_env_beautiful": "CartPole-v1",
"rl_env": "CartPole-v1",
"video_link": "",
"global": None
},
{
"rl_env_beautiful": "FrozenLake-v1-4x4-no_slippery ❄️",
"rl_env": "FrozenLake-v1-4x4-no_slippery",
"video_link": "",
"global": None
},
{
"rl_env_beautiful": "FrozenLake-v1-8x8-no_slippery ❄️",
"rl_env": "FrozenLake-v1-8x8-no_slippery",
"video_link": "",
"global": None
},
{
"rl_env_beautiful": "FrozenLake-v1-4x4 ❄️",
"rl_env": "FrozenLake-v1-4x4",
"video_link": "",
"global": None
},
{
"rl_env_beautiful": "FrozenLake-v1-8x8 ❄️",
"rl_env": "FrozenLake-v1-8x8",
"video_link": "",
"global": None
},
{
"rl_env_beautiful": "Taxi-v3 πŸš–",
"rl_env": "Taxi-v3",
"video_link": "",
"global": None
},
{
"rl_env_beautiful": "CarRacing-v0 🏎️",
"rl_env": "CarRacing-v0",
"video_link": "",
"global": None
},
{
"rl_env_beautiful": "CarRacing-v2 🏎️",
"rl_env": "CarRacing-v2",
"video_link": "",
"global": None
},
{
"rl_env_beautiful": "MountainCar-v0 ⛰️",
"rl_env": "MountainCar-v0",
"video_link": "",
"global": None
},
{
"rl_env_beautiful": "SpaceInvadersNoFrameskip-v4 πŸ‘Ύ",
"rl_env": "SpaceInvadersNoFrameskip-v4",
"video_link": "",
"global": None
},
{
"rl_env_beautiful": "PongNoFrameskip-v4 🎾",
"rl_env": "PongNoFrameskip-v4",
"video_link": "",
"global": None
},
{
"rl_env_beautiful": "BreakoutNoFrameskip-v4 🧱",
"rl_env": "BreakoutNoFrameskip-v4",
"video_link": "",
"global": None
},
{
"rl_env_beautiful": "QbertNoFrameskip-v4 🐦",
"rl_env": "QbertNoFrameskip-v4",
"video_link": "",
"global": None
},
{
"rl_env_beautiful": "BipedalWalker-v3",
"rl_env": "BipedalWalker-v3",
"video_link": "",
"global": None
},
{
"rl_env_beautiful": "Walker2DBulletEnv-v0",
"rl_env": "Walker2DBulletEnv-v0",
"video_link": "",
"global": None
},
{
"rl_env_beautiful": "AntBulletEnv-v0",
"rl_env": "AntBulletEnv-v0",
"video_link": "",
"global": None
},
{
"rl_env_beautiful": "HalfCheetahBulletEnv-v0",
"rl_env": "HalfCheetahBulletEnv-v0",
"video_link": "",
"global": None
},
{
"rl_env_beautiful": "PandaReachDense-v2",
"rl_env": "PandaReachDense-v2",
"video_link": "",
"global": None
},  
{
"rl_env_beautiful": "PandaReachDense-v3",
"rl_env": "PandaReachDense-v3",
"video_link": "",
"global": None
},  
{
"rl_env_beautiful": "Pixelcopter-PLE-v0",
"rl_env": "Pixelcopter-PLE-v0",
"video_link": "",
"global": None
}
]


def download_leaderboard_dataset():
    # Download the dataset from the Hugging Face Hub
    path = snapshot_download(repo_id=DATASET_REPO_ID, repo_type="dataset")
    return path


def get_data(rl_env, path) -> pd.DataFrame:
    """
    Get data from rl_env CSV file and return as DataFrame
    """
    csv_path = os.path.join(path, rl_env + ".csv")
    data = pd.read_csv(csv_path)
    return data


def get_last_refresh_time(path) -> str:
    """
    Get the latest modification time of any CSV file in the dataset path
    """
    # Get list of all CSV files in the dataset path
    csv_files = [os.path.join(path, f) for f in os.listdir(path) if f.endswith('.csv')]
    
    # Get the latest modification time
    latest_time = max([os.path.getmtime(f) for f in csv_files])
    
    # Convert to human-readable format
    return datetime.datetime.fromtimestamp(latest_time).strftime('%Y-%m-%d %H:%M:%S')


with block:
    path_ = download_leaderboard_dataset()
    # Get the last refresh time
    last_refresh_time = get_last_refresh_time(path_)

    gr.Markdown(f"""
    # πŸ† Deep Reinforcement Learning Course Leaderboard πŸ† 
    
    Presenting the latest leaderboard from the Hugging Face Deep RL Course - refresh ({last_refresh_time}).
    """)
    
    gr.Markdown(f"**Last Data Refresh:** {last_refresh_time}")
    
    for i in range(0, len(rl_envs)):
        rl_env = rl_envs[i]
        with gr.TabItem(rl_env["rl_env_beautiful"]):
            with gr.Row():
                markdown = f"""
                    # {rl_env['rl_env_beautiful']}
                    
                    ### Leaderboard for {rl_env['rl_env_beautiful']}
                    """
                gr.Markdown(markdown)

            with gr.Row():
                # Display the data for this RL environment
                data = get_data(rl_env["rl_env"], path_)
                gr.Dataframe(
                    value=data,
                    headers=["Ranking πŸ†", "User πŸ€—", "Model id πŸ€–", "Results", "Mean Reward", "Std Reward"],
                    datatype=["number", "markdown", "markdown", "number", "number", "number"],
                    row_count=(100, 'fixed')
                )

block.launch()