TheXeos's picture
Update process to run on a single space per env
513af34
raw history blame
No virus
2.29 kB
import json
import requests
from datasets import load_dataset
import gradio as gr
from huggingface_hub import HfApi, hf_hub_download
from huggingface_hub.repocard import metadata_load
import pandas as pd
from matchmaking import *
from background_task import init_matchmaking
from apscheduler.schedulers.background import BackgroundScheduler
block = gr.Blocks()
env = [
{
"name": "Soccer",
"global": None,
},
]
matchmaking = Matchmaking()
scheduler = BackgroundScheduler()
scheduler.add_job(func=init_matchmaking, trigger="interval", seconds=60)
scheduler.start()
def update_elos():
matchmaking.read_history()
matchmaking.compute_elo()
matchmaking.save_elo_data()
def get_env_data() -> pd.DataFrame:
data = pd.read_csv(f"env_elos/elo.csv")
# data = pd.DataFrame(columns=["user", "model", "elo", "games_played"])
return data
with block:
gr.Markdown(f"""
# ๐Ÿ† The Deep Reinforcement Learning Course Leaderboard ๐Ÿ†
This is the leaderboard of trained agents during the Deep Reinforcement Learning Course. A free course from beginner to expert.
This is the Soccer environment leaderboard, use Ctrl+F to find your rank ๐Ÿ†
We use an ELO rating to sort the models.
You **can click on the model's name** to be redirected to its model card which includes documentation.
๐Ÿค– You want to try to train your agents? <a href="http://eepurl.com/ic5ZUD" target="_blank">Sign up to the Hugging Face free Deep Reinforcement Learning Course ๐Ÿค— </a>.
You want to compare two agents? <a href="https://huggingface.co/spaces/ThomasSimonini/Compare-Reinforcement-Learning-Agents" target="_blank">It's possible using this Spaces demo ๐Ÿ‘€ </a>.
๐Ÿ”ง There is an **environment missing?** Please open an issue.
""")
with gr.Row():
refresh_data = gr.Button("Refresh")
val = gr.Variable(value=[env["name"]])
refresh_data.click(get_env_data, inputs=[val], outputs=env["global"])
with gr.Row():
env["global"] = gr.components.DataFrame(
get_env_data(),
headers=["Ranking ๐Ÿ†", "User ๐Ÿค—", "Model id ๐Ÿค–", "ELO ๐Ÿš€", "Games played ๐ŸŽฎ"],
datatype=["number", "markdown", "markdown", "number", "number"]
)
block.launch()