Spaces:
Sleeping
Sleeping
File size: 762 Bytes
5f644bb |
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 |
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'])
|