Spaces:
Build error
Build error
import gradio as gr | |
import pandas as pd | |
import requests | |
from huggingface_hub.hf_api import SpaceInfo | |
path = f"https://huggingface.co/api/spaces" | |
def get_platzi_spaces(): | |
r = requests.get(path) | |
d = r.json() | |
spaces = [SpaceInfo(**x) for x in d] | |
blocks_spaces = {} | |
for i in range(0, len(spaces)): | |
if ( | |
spaces[i].id.split("/")[0] == "platzi" | |
and hasattr(spaces[i], "likes") | |
and spaces[i].id != "platzi/platzi-leaderboard" | |
and spaces[i].id != "platzi/README" | |
and spaces[i].id != "platzi/platzi-curso-streamlit-segmentacion-imagenes" | |
and spaces[i].id != "platzi/platzi-curso-gradio-asr" | |
and spaces[i].id != "platzi/platzi-curso-gradio-blocks" | |
and spaces[i].id != "platzi/platzi-curso-gradio-tf-clasificacion-imagenes" | |
and spaces[i].id != "platzi/platzi-curso-gradio-clasificacion-imagenes" | |
# and spaces[i].id != "platzi/platzi-curso-streamlit-butterfly-gan" | |
): | |
blocks_spaces[spaces[i].id] = spaces[i].likes | |
df = pd.DataFrame( | |
[ | |
{"Spaces_Name": Spaces, "likes": likes} | |
for Spaces, likes in blocks_spaces.items() | |
] | |
) | |
df = df.sort_values(by=["likes"], ascending=False) | |
return df | |
block = gr.Blocks() | |
with block: | |
gr.Markdown( | |
"""### Leaderboard de los Spaces (demos) más populares creados por estudiantes del curso de **creación de demos de Platzi**.""" | |
) | |
gr.Markdown( | |
"""Aprende más sobre el curso aquí y comparte para obtener más corazones 🤗.</a>""" | |
) | |
with gr.Tabs(): | |
with gr.TabItem("Leaderboard de los Spaces con más corazones"): | |
with gr.Row(): | |
data = gr.outputs.Dataframe(type="pandas") | |
with gr.Row(): | |
data_run = gr.Button("Refrescar") | |
data_run.click(get_platzi_spaces, inputs=None, outputs=data) | |
block.load(get_platzi_spaces, inputs=None, outputs=data) | |
block.launch() | |