Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
import pandas as pd
|
3 |
+
import gradio as gr
|
4 |
+
from huggingface_hub.hf_api import SpaceInfo
|
5 |
+
|
6 |
+
|
7 |
+
|
8 |
+
path = f"https://huggingface.co/api/spaces"
|
9 |
+
|
10 |
+
|
11 |
+
|
12 |
+
def get_blocks_party_spaces():
|
13 |
+
r = requests.get(path)
|
14 |
+
d = r.json()
|
15 |
+
spaces = [SpaceInfo(**x) for x in d]
|
16 |
+
blocks_spaces = {}
|
17 |
+
for i in range(0,len(spaces)):
|
18 |
+
if spaces[i].id.split('/')[0] == 'CVPR' and hasattr(spaces[i], 'likes') and spaces[i].id != 'CVPR/Leaderboard' and spaces[i].id != 'CVPR/README':
|
19 |
+
blocks_spaces[spaces[i].id]=spaces[i].likes
|
20 |
+
df = pd.DataFrame(
|
21 |
+
[{"Spaces_Name": Spaces, "likes": likes} for Spaces,likes in blocks_spaces.items()])
|
22 |
+
df = df.sort_values(by=['likes'],ascending=False)
|
23 |
+
return df
|
24 |
+
|
25 |
+
|
26 |
+
block = gr.Blocks()
|
27 |
+
|
28 |
+
with block:
|
29 |
+
gr.Markdown("""Leaderboard for the most popular CVPR Spaces. To learn more and join, see <a href="https://huggingface.co/CVPR" target="_blank" style="text-decoration: underline">CVPR Event</a>""")
|
30 |
+
with gr.Tabs():
|
31 |
+
with gr.TabItem("Blocks Party Leaderboard"):
|
32 |
+
with gr.Row():
|
33 |
+
data = gr.outputs.Dataframe(type="pandas")
|
34 |
+
with gr.Row():
|
35 |
+
data_run = gr.Button("Refresh")
|
36 |
+
data_run.click(get_blocks_party_spaces, inputs=None, outputs=data)
|
37 |
+
|
38 |
+
block.load(get_blocks_party_spaces, inputs=None, outputs=data)
|
39 |
+
block.launch()
|