espejelomar commited on
Commit
eaff765
1 Parent(s): 0273525

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -19
app.py CHANGED
@@ -1,41 +1,56 @@
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_hugging_learners_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] == 'hugginglearners' and hasattr(spaces[i], 'likes') and spaces[i].id != 'hugginglearners/Hearts_Leaderboard' and spaces[i].id != 'hugginglearners/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 of the most popular **fastai X Hugging Face Group** (the Hugging Learners) Spaces""")
30
- gr.Markdown("""Learn more, join and become a Hugging Learner. The instructions are <a href="https://huggingface.co/hugginglearners" target="_blank" style="text-decoration: underline">here.</a>""")
 
 
 
 
31
 
32
  with gr.Tabs():
33
- with gr.TabItem("Leaderboard of spaces with the most hearts"):
34
  with gr.Row():
35
  data = gr.outputs.Dataframe(type="pandas")
36
  with gr.Row():
37
- data_run = gr.Button("Refresh")
38
- data_run.click(get_hugging_learners_spaces, inputs=None, outputs=data)
39
 
40
- block.load(get_hugging_learners_spaces, inputs=None, outputs=data)
41
- block.launch()
 
 
 
1
  import gradio as gr
2
+ import pandas as pd
3
+ import requests
4
  from huggingface_hub.hf_api import SpaceInfo
5
 
 
 
6
  path = f"https://huggingface.co/api/spaces"
7
 
8
 
9
+ def get_platzi_spaces():
 
10
  r = requests.get(path)
11
  d = r.json()
12
  spaces = [SpaceInfo(**x) for x in d]
13
  blocks_spaces = {}
14
+ for i in range(0, len(spaces)):
15
+ if (
16
+ spaces[i].id.split("/")[0] == "platzi"
17
+ and hasattr(spaces[i], "likes")
18
+ and spaces[i].id != "platzi/platzi-leaderboard"
19
+ and spaces[i].id != "platzi/README"
20
+ and spaces[i].id != "platzi/platzi-curso-streamlit-segmentacion-imagenes"
21
+ and spaces[i].id != "platzi/platzi-curso-gradio-asr"
22
+ and spaces[i].id != "platzi/platzi-curso-gradio-blocks"
23
+ and spaces[i].id != "platzi/platzi-curso-gradio-tf-clasificacion-imagenes"
24
+ and spaces[i].id != "platzi/platzi-curso-gradio-clasificacion-imagenes"
25
+ ):
26
+ blocks_spaces[spaces[i].id] = spaces[i].likes
27
  df = pd.DataFrame(
28
+ [
29
+ {"Spaces_Name": Spaces, "likes": likes}
30
+ for Spaces, likes in blocks_spaces.items()
31
+ ]
32
+ )
33
+ df = df.sort_values(by=["likes"], ascending=False)
34
  return df
35
 
36
 
37
  block = gr.Blocks()
38
 
39
+ with block:
40
+ gr.Markdown(
41
+ """### Leaderboard de los Spaces (demos) más populares creados por estudiantes del curso de **creación de demos de Platzi**."""
42
+ )
43
+ gr.Markdown(
44
+ """Aprende más sobre el curso aquí y comparte para obtener más corazones 🤗.</a>"""
45
+ )
46
 
47
  with gr.Tabs():
48
+ with gr.TabItem("Leaderboard de los Spaces con más corazones"):
49
  with gr.Row():
50
  data = gr.outputs.Dataframe(type="pandas")
51
  with gr.Row():
52
+ data_run = gr.Button("Refrescar")
53
+ data_run.click(get_platzi_spaces, inputs=None, outputs=data)
54
 
55
+ block.load(get_platzi_spaces, inputs=None, outputs=data)
56
+ block.launch()