Spaces:
Sleeping
Sleeping
File size: 923 Bytes
5f644bb 1628cf8 5f644bb 80f48e5 5f644bb 1628cf8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
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()
|