akhaliq HF staff commited on
Commit
d3d2e9e
1 Parent(s): 42cc5db

Create new file

Browse files
Files changed (1) hide show
  1. app.py +39 -0
app.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import requests
3
+ import pandas as pd
4
+ import gradio as gr
5
+ from huggingface_hub.hf_api import SpaceInfo
6
+ from pathlib import Path
7
+
8
+
9
+ path = f"https://huggingface.co/api/spaces"
10
+
11
+
12
+ def get_SIGGRAPH_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] == 'SIGGRAPH2022' and hasattr(spaces[i], 'likes') and spaces[i].id != 'SIGGRAPH2022/Leaderboard' and spaces[i].id != 'SIGGRAPH2022/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 SIGGRAPH 2022 Spaces. To learn more and join, see <a href="https://huggingface.co/SIGGRAPH2022" target="_blank" style="text-decoration: underline">SIGGRAPH 2022 Event</a>""")
30
+ with gr.Tabs():
31
+ with gr.TabItem("SIGGRAPH 2022 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_SIGGRAPH_spaces, inputs=None, outputs=data)
37
+
38
+ block.load(get_SIGGRAPH_spaces, inputs=None, outputs=data)
39
+ block.launch()