|
import json |
|
import requests |
|
from datasets import load_dataset |
|
import gradio as gr |
|
from huggingface_hub import HfApi, hf_hub_download, Repository |
|
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 |
|
|
|
|
|
DATASET_REPO_URL = "https://huggingface.co/datasets/CarlCochet/BotFightData" |
|
ELO_FILENAME = "elo.csv" |
|
ELO_DIR = "soccer_elo" |
|
ELO_FILE = os.path.join(ELO_DIR, ELO_FILENAME) |
|
HF_TOKEN = os.environ.get("HF_TOKEN") |
|
|
|
block = gr.Blocks() |
|
matchmaking = Matchmaking() |
|
api = HfApi() |
|
|
|
scheduler = BackgroundScheduler() |
|
scheduler.add_job(func=init_matchmaking, trigger="interval", seconds=15000) |
|
scheduler.start() |
|
|
|
repo = Repository( |
|
local_dir=ELO_DIR, clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN |
|
) |
|
|
|
|
|
def update_elos(): |
|
matchmaking.read_history() |
|
matchmaking.compute_elo() |
|
matchmaking.save_elo_data() |
|
|
|
|
|
def get_elo_data() -> pd.DataFrame: |
|
hf_hub_download(repo_id="CarlCochet/BotFightData", filename=ELO_FILENAME, subfolder=ELO_DIR) |
|
with open(ELO_FILE, "r") as f: |
|
data = pd.read_csv(f) |
|
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.Blocks() as block: |
|
gr.components.Dataframe( |
|
value=get_elo_data(), |
|
headers=["Ranking ๐", "User ๐ค", "Model id ๐ค", "ELO ๐", "Games played ๐ฎ"], |
|
datatype=["number", "markdown", "markdown", "number", "number"] |
|
) |
|
|
|
block.launch() |
|
|