Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Commit Β·
e653f9c
1
Parent(s): 659a76d
Add BackgroundScheduler()
Browse files2 unmodified lines3456789101112131415161762 unmodified lines808182838485868788899091929394959697989910010110210365 unmodified lines16917017114917217317417517617715517817918018116 unmodified lines19819920020120220320420520620718420820921021110 unmodified lines22222322420122522622722821 unmodified lines2502512522292532542552562572582592602612622632642652662672682692702712722732742752 unmodified linesimport requests
from datasets import load_dataset
import gradio as grfrom apscheduler.schedulers.background import BackgroundScheduler
from huggingface_hub import HfApi, hf_hub_downloadfrom huggingface_hub.repocard import metadata_loadimport pandas as pd
from utils import *
62 unmodified lines"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": "",65 unmodified lines api = HfApi() models = api.list_models(filter=rl_env) model_ids = [x.modelId for x in models] print(model_ids) #print(model_ids) return model_ids
def get_model_dataframe(rl_env): # Get model ids associated with rl_env model_ids = get_model_ids(rl_env) print(model_ids) #print(model_ids) data = [] for model_id in model_ids: """16 unmodified lines row["Mean Reward"] = mean_reward row["Std Reward"] = std_reward data.append(row) print("DATA", data) ranked_dataframe = rank_dataframe(pd.DataFrame.from_records(data)) print("RANKED", ranked_dataframe) return ranked_dataframe def rank_dataframe(dataframe): print("DATAFRAME", dataframe) #print("DATAFRAME", dataframe) dataframe = dataframe.sort_values(by=['Results'], ascending=False) if not 'Ranking' in dataframe.columns: dataframe.insert(0, 'Ranking', [i for i in range(1,len(dataframe)+1)])10 unmodified lines Just choose which environment you trained your agent on and with Ctrl+F find your rank π
**If you don't find your model, go to the bottom of the page and click on the refresh button** **The leaderboard is updated every hour. If you don't find your model, go to the bottom of the page and click on the refresh button** We use **lower bound result to sort the models: mean_reward - std_reward.**
21 unmodified lines rl_env["global"] = gr.components.Dataframe(value= get_model_dataframe(rl_env["rl_env"]), headers=["Ranking π", "User π€", "Model id π€", "Results", "Mean Reward", "Std Reward"], datatype=["number", "markdown", "markdown", "number", "number", "number"]) with gr.Row(): data_run = gr.Button("Refresh") print("rl_env", rl_env["rl_env"]) #print("rl_env", rl_env["rl_env"]) val = gr.Variable(value=[rl_env["rl_env"]]) data_run.click(get_model_dataframe, inputs=[val], outputs =rl_env["global"]) block.launch()
def refresh_leaderboard(): """ Here we refresh the leaderboard: we update the rl_env["global"] for each rl_envs in rl_env """ for i in range(0, len(rl_envs)): rl_env = rl_envs[i] temp = get_model_dataframe(rl_env) rl_env["global"] = temp print("The leaderboard has been updated")
scheduler = BackgroundScheduler()# Refresh every hourscheduler.add_job(func=refresh_leaderboard, trigger="interval", seconds=3600)scheduler.start()
app.py+45-5