Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Muennighoff
commited on
Commit
•
78db81b
1
Parent(s):
a479746
v0001
Browse files
app.py
CHANGED
@@ -2,9 +2,19 @@ import gradio as gr
|
|
2 |
import requests
|
3 |
import pandas as pd
|
4 |
from huggingface_hub.hf_api import SpaceInfo
|
|
|
|
|
|
|
5 |
path = f"https://huggingface.co/api/spaces"
|
6 |
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
def get_blocks_party_spaces():
|
9 |
r = requests.get(path)
|
10 |
d = r.json()
|
@@ -18,6 +28,27 @@ def get_blocks_party_spaces():
|
|
18 |
df = df.sort_values(by=['likes'],ascending=False)
|
19 |
return df
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
block = gr.Blocks()
|
22 |
|
23 |
with block:
|
@@ -25,19 +56,21 @@ with block:
|
|
25 |
with gr.Tabs():
|
26 |
with gr.TabItem("Blocks Party Leaderboard"):
|
27 |
with gr.Row():
|
28 |
-
data = gr.
|
29 |
with gr.Row():
|
30 |
data_run = gr.Button("Refresh")
|
31 |
data_run.click(get_blocks_party_spaces, inputs=None, outputs=data)
|
32 |
-
with gr.TabItem("
|
33 |
with gr.Row():
|
34 |
-
|
|
|
|
|
35 |
with gr.Row():
|
36 |
data_run = gr.Button("Refresh")
|
37 |
-
data_run.click(
|
38 |
with gr.TabItem("Blocks Party Leaderboard2"):
|
39 |
with gr.Row():
|
40 |
-
data = gr.
|
41 |
with gr.Row():
|
42 |
data_run = gr.Button("Refresh")
|
43 |
data_run.click(get_blocks_party_spaces, inputs=None, outputs=data)
|
|
|
2 |
import requests
|
3 |
import pandas as pd
|
4 |
from huggingface_hub.hf_api import SpaceInfo
|
5 |
+
from huggingface_hub import HfApi, hf_hub_download
|
6 |
+
from huggingface_hub.repocard import metadata_load
|
7 |
+
|
8 |
path = f"https://huggingface.co/api/spaces"
|
9 |
|
10 |
|
11 |
+
#api = HfApi()
|
12 |
+
#models = api.list_models(filter="mteb")
|
13 |
+
#readme_path = hf_hub_download(models[0].modelId, filename="README.md")
|
14 |
+
#meta = metadata_load(readme_path)
|
15 |
+
#list(filter(lambda x: x["task"]["type"] == "Retrieval", meta["model-index"][0]["results"]))
|
16 |
+
|
17 |
+
|
18 |
def get_blocks_party_spaces():
|
19 |
r = requests.get(path)
|
20 |
d = r.json()
|
|
|
28 |
df = df.sort_values(by=['likes'],ascending=False)
|
29 |
return df
|
30 |
|
31 |
+
def get_clustering(task="Clustering", metric="v_measure"):
|
32 |
+
api = HfApi()
|
33 |
+
models = api.list_models(filter="mteb")
|
34 |
+
df_list = []
|
35 |
+
for model in models:
|
36 |
+
readme_path = hf_hub_download(model.modelId, filename="README.md")
|
37 |
+
meta = metadata_load(readme_path)
|
38 |
+
out = list(
|
39 |
+
map(
|
40 |
+
lambda x: {x["dataset"]["name"]: list(filter(lambda x: x["type"] == metric, x["metrics"]))[0]["value"]},
|
41 |
+
filter(lambda x: x["task"]["type"] == task, meta["model-index"][0]["results"])
|
42 |
+
)
|
43 |
+
)
|
44 |
+
out = {k: v for d in out for k, v in d.items()}
|
45 |
+
out["Model"] = model.modelId
|
46 |
+
df_list.append(out)
|
47 |
+
df = pd.DataFrame(df_list)
|
48 |
+
# Put Model in the beginning & sort the others
|
49 |
+
df = df[[df.columns[-1]] + sorted(df.columns[:-1])]
|
50 |
+
return df
|
51 |
+
|
52 |
block = gr.Blocks()
|
53 |
|
54 |
with block:
|
|
|
56 |
with gr.Tabs():
|
57 |
with gr.TabItem("Blocks Party Leaderboard"):
|
58 |
with gr.Row():
|
59 |
+
data = gr.components.Dataframe(type="pandas")
|
60 |
with gr.Row():
|
61 |
data_run = gr.Button("Refresh")
|
62 |
data_run.click(get_blocks_party_spaces, inputs=None, outputs=data)
|
63 |
+
with gr.TabItem("Clustering"):
|
64 |
with gr.Row():
|
65 |
+
gr.Markdown("""Leaderboard for Clustering""")
|
66 |
+
with gr.Row():
|
67 |
+
data = gr.components.Dataframe(type="pandas")
|
68 |
with gr.Row():
|
69 |
data_run = gr.Button("Refresh")
|
70 |
+
data_run.click(get_clustering, inputs=None, outputs=data)
|
71 |
with gr.TabItem("Blocks Party Leaderboard2"):
|
72 |
with gr.Row():
|
73 |
+
data = gr.components.Dataframe(type="pandas")
|
74 |
with gr.Row():
|
75 |
data_run = gr.Button("Refresh")
|
76 |
data_run.click(get_blocks_party_spaces, inputs=None, outputs=data)
|