pipeline_stats / app.py
patrickvonplaten's picture
add test
80f48e5
raw
history blame
923 Bytes
from huggingface_hub import HfApi, ModelFilter
from collections import defaultdict
import pandas as pd
import gradio as gr
api = HfApi()
filter = ModelFilter(library="diffusers")
models = api.list_models(filter=filter)
downloads = defaultdict(int)
for model in models:
is_counted = False
for tag in model.tags:
if tag.startswith("diffusers:"):
is_counted = True
downloads[tag[len("diffusers:"):]] += model.downloads
if not is_counted:
downloads["other"] += model.downloads
# Remove 0 downloads
downloads = {k: v for k,v in downloads.items() if v > 0}
# Sort the dictionary by keys
sorted_dict = dict(sorted(downloads.items(), key=lambda item: item[1], reverse=True))
# Convert the sorted dictionary to a DataFrame
df = pd.DataFrame(list(sorted_dict.items()), columns=['Pipeline class', 'Downloads'])
with gr.Blocks() as demo:
gr.DataFrame(df)
demo.launch()