Spaces:
Runtime error
Runtime error
Quentin GallouΓ©dec
commited on
Commit
Β·
48ae20c
1
Parent(s):
0ef2585
winner name
Browse files
app.py
CHANGED
@@ -186,6 +186,27 @@ def refresh_videos():
|
|
186 |
return outputs
|
187 |
|
188 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
HEADING = """
|
190 |
# π₯ Open RL Leaderboard π₯
|
191 |
|
@@ -264,7 +285,20 @@ If you encounter any issue, please [open an issue](https://huggingface.co/spaces
|
|
264 |
```
|
265 |
"""
|
266 |
|
267 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
gr.Markdown(HEADING)
|
269 |
with gr.Tabs(elem_classes="tab-buttons") as tabs:
|
270 |
with gr.TabItem("π
Leaderboard"):
|
@@ -272,6 +306,7 @@ with gr.Blocks() as demo:
|
|
272 |
all_env_ids = []
|
273 |
all_gr_dfs = []
|
274 |
all_gr_videos = []
|
|
|
275 |
for env_domain, env_ids in ALL_ENV_IDS.items():
|
276 |
with gr.TabItem(env_domain):
|
277 |
for env_id in env_ids:
|
@@ -280,26 +315,28 @@ with gr.Blocks() as demo:
|
|
280 |
with gr.TabItem(tab_env_id):
|
281 |
logger.info(f"Creating tab for {env_id}")
|
282 |
with gr.Row(equal_height=False):
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
|
|
300 |
|
301 |
all_env_ids.append(env_id)
|
302 |
all_gr_dfs.append(gr_df)
|
|
|
303 |
all_gr_videos.append(gr_video)
|
304 |
|
305 |
with gr.TabItem("π About"):
|
@@ -307,6 +344,7 @@ with gr.Blocks() as demo:
|
|
307 |
|
308 |
demo.load(refresh_dataframes, outputs=all_gr_dfs, every=REFRESH_RATE)
|
309 |
demo.load(refresh_videos, outputs=all_gr_videos, every=REFRESH_RATE)
|
|
|
310 |
|
311 |
|
312 |
scheduler = BackgroundScheduler()
|
|
|
186 |
return outputs
|
187 |
|
188 |
|
189 |
+
def refresh_winners():
|
190 |
+
df = get_leaderboard_df()
|
191 |
+
outputs = []
|
192 |
+
for env_id in all_env_ids:
|
193 |
+
env_df = select_env(df, env_id)
|
194 |
+
if not env_df.empty:
|
195 |
+
winner = f'{env_df.iloc[0]["user_id"]}/{env_df.iloc[0]["model_id"]}'
|
196 |
+
outputs.append(
|
197 |
+
f"""## {env_id}
|
198 |
+
|
199 |
+
### π [{winner}](https://huggingface.co/{winner}) π"""
|
200 |
+
)
|
201 |
+
# # Or in HTML:
|
202 |
+
# outputs.append(f'<h3>π <a href="https://huggingface.co/{model}">{model}</a> π</h3>')
|
203 |
+
else:
|
204 |
+
outputs.append(f"""## {env_id}
|
205 |
+
|
206 |
+
### π€·ββοΈ No winner yet""")
|
207 |
+
return outputs
|
208 |
+
|
209 |
+
|
210 |
HEADING = """
|
211 |
# π₯ Open RL Leaderboard π₯
|
212 |
|
|
|
285 |
```
|
286 |
"""
|
287 |
|
288 |
+
css = """
|
289 |
+
.generating {
|
290 |
+
border: none;
|
291 |
+
}
|
292 |
+
h2 {
|
293 |
+
text-align: center;
|
294 |
+
}
|
295 |
+
h3 {
|
296 |
+
text-align: center;
|
297 |
+
}
|
298 |
+
|
299 |
+
"""
|
300 |
+
|
301 |
+
with gr.Blocks(css=css) as demo:
|
302 |
gr.Markdown(HEADING)
|
303 |
with gr.Tabs(elem_classes="tab-buttons") as tabs:
|
304 |
with gr.TabItem("π
Leaderboard"):
|
|
|
306 |
all_env_ids = []
|
307 |
all_gr_dfs = []
|
308 |
all_gr_videos = []
|
309 |
+
all_gr_winners = []
|
310 |
for env_domain, env_ids in ALL_ENV_IDS.items():
|
311 |
with gr.TabItem(env_domain):
|
312 |
for env_id in env_ids:
|
|
|
315 |
with gr.TabItem(tab_env_id):
|
316 |
logger.info(f"Creating tab for {env_id}")
|
317 |
with gr.Row(equal_height=False):
|
318 |
+
with gr.Column(scale=3):
|
319 |
+
# Display the leaderboard
|
320 |
+
gr_df = gr.components.Dataframe(
|
321 |
+
headers=["π", "π§ User", "π€ Model id", "π Mean episodic return"],
|
322 |
+
datatype=["number", "markdown", "markdown", "number"],
|
323 |
+
row_count=(20, "fixed"),
|
324 |
+
)
|
325 |
+
with gr.Column(scale=1):
|
326 |
+
with gr.Row(): # Display the env_id and the winner
|
327 |
+
gr_winner = gr.Markdown()
|
328 |
+
with gr.Row(): # Play the video of the best model
|
329 |
+
gr_video = gr.PlayableVideo( # Doesn't loop for the moment, see https://github.com/gradio-app/gradio/issues/7689
|
330 |
+
min_width=50,
|
331 |
+
autoplay=True,
|
332 |
+
show_download_button=False,
|
333 |
+
show_share_button=False,
|
334 |
+
show_label=False,
|
335 |
+
)
|
336 |
|
337 |
all_env_ids.append(env_id)
|
338 |
all_gr_dfs.append(gr_df)
|
339 |
+
all_gr_winners.append(gr_winner)
|
340 |
all_gr_videos.append(gr_video)
|
341 |
|
342 |
with gr.TabItem("π About"):
|
|
|
344 |
|
345 |
demo.load(refresh_dataframes, outputs=all_gr_dfs, every=REFRESH_RATE)
|
346 |
demo.load(refresh_videos, outputs=all_gr_videos, every=REFRESH_RATE)
|
347 |
+
demo.load(refresh_winners, outputs=all_gr_winners, every=REFRESH_RATE)
|
348 |
|
349 |
|
350 |
scheduler = BackgroundScheduler()
|