akhaliq HF staff commited on
Commit
5d74973
1 Parent(s): 3778ca3

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -0
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()