Spaces:
Sleeping
Sleeping
from huggingface_hub import HfApi, ModelFilter | |
from collections import defaultdict | |
import pandas as pd | |
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 | |
# 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']) | |