mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-03 01:50:59 +08:00
597337dcb8
* added playground with 12 demos * change name to recipes, restyle navbar * add explanatory text to page * fix demo mapping * categorize demos, clean up design * styling * cateogry naming and emojis * refactor and add text demos * add view code button * remove opening slash in embed * styling * add image demos * adding plot demos * remove see code button * removed submodules * changes * add audio models * remove fun section * remove tests in image semgentation demo repo * requested changes * add outbreak_forecast * fix broken demos * remove images and models, add new demos * remove readmes, change to run.py, add description as comment * move to /demos folder, clean up dict * add upload_to_spaces script * fix script, clean repos, and add to docker file * fix python versioning issue * env variable * fix * env fixes * spaces instead of tabs * revert to original networking.py * fix rate limiting in asr and autocomplete * change name to demos * clean up navbar * move url and description, remove code comments * add tabs to demos * remove margins and footer from embedded demo * font consistency Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
37 lines
1.5 KiB
Python
37 lines
1.5 KiB
Python
import gradio as gr
|
|
import requests
|
|
import pandas as pd
|
|
from huggingface_hub.hf_api import SpaceInfo
|
|
path = f"https://huggingface.co/api/spaces"
|
|
|
|
|
|
def get_blocks_party_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] == 'Gradio-Blocks' and hasattr(spaces[i], 'likes') and spaces[i].id != 'Gradio-Blocks/Leaderboard' and spaces[i].id != 'Gradio-Blocks/README':
|
|
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 for the most popular Blocks Event Spaces. To learn more and join, see <a href="https://huggingface.co/Gradio-Blocks" target="_blank" style="text-decoration: underline">Blocks Party Event</a>""")
|
|
with gr.Tabs():
|
|
with gr.TabItem("Blocks Party Leaderboard"):
|
|
with gr.Row():
|
|
data = gr.outputs.Dataframe(type="pandas")
|
|
with gr.Row():
|
|
data_run = gr.Button("Refresh")
|
|
data_run.click(get_blocks_party_spaces, inputs=None, outputs=data)
|
|
# running the function on page load in addition to when the button is clicked
|
|
block.load(get_blocks_party_spaces, inputs=None, outputs=data)
|
|
|
|
block.launch()
|
|
|