File size: 2,303 Bytes
71ea432
 
 
 
b62b9e0
71ea432
 
 
513af34
 
71ea432
 
b62b9e0
 
 
 
 
 
71ea432
6ac0a0d
b62b9e0
6ac0a0d
513af34
6581f4d
513af34
 
b62b9e0
 
 
 
6ac0a0d
 
 
 
 
71ea432
24be325
4d948da
248df8c
24be325
 
 
 
 
 
 
 
 
513af34
24be325
 
 
 
 
 
 
 
 
 
4d948da
 
 
452ab22
 
 
24be325
 
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
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=60)
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:
    data = pd.read_csv(os.path.join(DATASET_REPO_URL, "resolve", "main", ELO_FILE))
    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()