Spaces:
Sleeping
Sleeping
Commit
·
5f644bb
1
Parent(s):
5bf5a70
add test
Browse files
app.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from huggingface_hub import HfApi, ModelFilter
|
| 2 |
+
from collections import defaultdict
|
| 3 |
+
import pandas as pd
|
| 4 |
+
|
| 5 |
+
api = HfApi()
|
| 6 |
+
|
| 7 |
+
filter = ModelFilter(library="diffusers")
|
| 8 |
+
|
| 9 |
+
models = api.list_models(filter=filter)
|
| 10 |
+
|
| 11 |
+
downloads = defaultdict(int)
|
| 12 |
+
|
| 13 |
+
for model in models:
|
| 14 |
+
is_counted = False
|
| 15 |
+
for tag in model.tags:
|
| 16 |
+
if tag.startswith("diffusers:"):
|
| 17 |
+
is_counted = True
|
| 18 |
+
downloads[tag[len("diffusers:"):]] += model.downloads
|
| 19 |
+
|
| 20 |
+
if not is_counted:
|
| 21 |
+
downloads["other"] += model.downloads
|
| 22 |
+
|
| 23 |
+
# Sort the dictionary by keys
|
| 24 |
+
sorted_dict = dict(sorted(downloads.items(), key=lambda item: item[1], reverse=True))
|
| 25 |
+
|
| 26 |
+
# Convert the sorted dictionary to a DataFrame
|
| 27 |
+
df = pd.DataFrame(list(sorted_dict.items()), columns=['Pipeline class', 'Downloads'])
|