Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +9,7 @@ import gradio as gr
|
|
9 |
|
10 |
api = HfApi()
|
11 |
|
12 |
-
def
|
13 |
all_list = []
|
14 |
if which_one == "models":
|
15 |
things = api.list_models(author=org_name)
|
@@ -73,15 +73,49 @@ def get_ranking(model_list, target_org):
|
|
73 |
return [index+1, model]
|
74 |
return "Not Found"
|
75 |
|
76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
data_rows = []
|
78 |
open_llm_leaderboard = get_openllm_leaderboard() if which_one == "models" else None
|
79 |
|
80 |
trend = get_trending_list(1, which_one)
|
81 |
|
82 |
-
for org in tqdm(orgs, desc=f"
|
83 |
rank = get_ranking_trend(trend, org)
|
84 |
-
|
|
|
|
|
85 |
if len(df) == 0:
|
86 |
continue
|
87 |
num_things = len(df)
|
@@ -144,9 +178,6 @@ def make_leaderboard(orgs, which_one):
|
|
144 |
leaderboard.insert(0, "Serial Number", range(1, len(leaderboard) + 1))
|
145 |
return leaderboard
|
146 |
|
147 |
-
"""# Gradio başlasın
|
148 |
-
|
149 |
-
"""
|
150 |
|
151 |
with open("org_names.txt", "r") as f:
|
152 |
org_names_in_list = [i.rstrip("\n") for i in f.readlines()]
|
@@ -154,6 +185,7 @@ with open("org_names.txt", "r") as f:
|
|
154 |
|
155 |
INTRODUCTION_TEXT = f"""
|
156 |
🎯 The Organization Leaderboard aims to track organization rankings. This space is inspired by the [Open LLM Leaderboard](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard).
|
|
|
157 |
## Available Dataframes:
|
158 |
|
159 |
- 🏛️ Models
|
@@ -226,10 +258,14 @@ with gr.Blocks() as demo:
|
|
226 |
gr.Markdown("""<h1 align="center" id="space-title">🤗 Organization Leaderboard</h1>""")
|
227 |
gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
|
228 |
|
229 |
-
|
|
|
|
|
|
|
230 |
|
|
|
231 |
columns_to_convert = ["Organization Name", "Best Model On Open LLM Leaderboard", "Most Downloaded Model", "Most Liked Model", "Trending Model"]
|
232 |
-
models_df = make_leaderboard(org_names_in_list, "models")
|
233 |
models_df = models_df_to_clickable(models_df, columns_to_convert, "models")
|
234 |
|
235 |
headers = ["🔢 Serial Number", "🏢 Organization Name", "📥 Total Downloads", "👍 Total Likes", "🤖 Number of Models", "🏆 Best Model On Open LLM Leaderboard", "🥇 Best Rank On Open LLM Leaderboard", "📊 Average Downloads per Model", "📈 Average Likes per Model", "🚀 Most Downloaded Model", "📈 Most Download Count", "❤️ Most Liked Model", "👍 Most Like Count", "🔥 Trending Model", "👑 Best Rank at Trending Models"]
|
@@ -237,7 +273,7 @@ with gr.Blocks() as demo:
|
|
237 |
|
238 |
with gr.TabItem("📊 Datasets", id=2):
|
239 |
columns_to_convert = ["Organization Name", "Most Downloaded Dataset", "Most Liked Dataset", "Trending Dataset"]
|
240 |
-
dataset_df = make_leaderboard(org_names_in_list, "datasets")
|
241 |
dataset_df = models_df_to_clickable(dataset_df, columns_to_convert, "datasets")
|
242 |
|
243 |
headers = ["🔢 Serial Number", "🏢 Organization Name", "📥 Total Downloads", "👍 Total Likes", "📊 Number of Datasets", "📊 Average Downloads per Dataset", "📈 Average Likes per Dataset", "🚀 Most Downloaded Dataset", "📈 Most Download Count", "❤️ Most Liked Dataset", "👍 Most Like Count", "🔥 Trending Dataset", "👑 Best Rank at Trending Datasets"]
|
@@ -246,11 +282,10 @@ with gr.Blocks() as demo:
|
|
246 |
with gr.TabItem("🚀 Spaces", id=3):
|
247 |
columns_to_convert = ["Organization Name", "Most Liked Space", "Trending Space"]
|
248 |
|
249 |
-
spaces_df = make_leaderboard(org_names_in_list, "spaces")
|
250 |
spaces_df = models_df_to_clickable(spaces_df, columns_to_convert, "spaces")
|
251 |
|
252 |
headers = ["🔢 Serial Number", "🏢 Organization Name", "👍 Total Likes", "🚀 Number of Spaces", "📈 Average Likes per Space", "❤️ Most Liked Space", "👍 Most Like Count", "🔥 Trending Space", "👑 Best Rank at Trending Spaces"]
|
253 |
gr.Dataframe(spaces_df.head(150), headers=headers, interactive=False, datatype=["str", "markdown", "str", "str", "str", "markdown", "str", "markdown", "str"])
|
254 |
|
255 |
demo.launch()
|
256 |
-
|
|
|
9 |
|
10 |
api = HfApi()
|
11 |
|
12 |
+
def get_models_old(org_name, which_one):
|
13 |
all_list = []
|
14 |
if which_one == "models":
|
15 |
things = api.list_models(author=org_name)
|
|
|
73 |
return [index+1, model]
|
74 |
return "Not Found"
|
75 |
|
76 |
+
|
77 |
+
def get_models(which_one):
|
78 |
+
if which_one == "models":
|
79 |
+
data = api.list_models()
|
80 |
+
elif which_one == "datasets":
|
81 |
+
data = api.list_datasets()
|
82 |
+
elif which_one == "spaces":
|
83 |
+
data = api.list_spaces()
|
84 |
+
|
85 |
+
all_list = []
|
86 |
+
for i in tqdm(data, desc=f"Scraping {which_one}", position=0, leave=True):
|
87 |
+
i = i.__dict__
|
88 |
+
|
89 |
+
id = i["id"].split("/")
|
90 |
+
if len(id) != 1:
|
91 |
+
json_format_data = {"author": id[0] ,"id": "/".join(id), "downloads": i['downloads'], "likes": i['likes']} if which_one != "spaces" else {"author": id[0] ,"id": "/".join(id), "downloads": 0, "likes": i['likes']}
|
92 |
+
|
93 |
+
|
94 |
+
all_list.append(json_format_data)
|
95 |
+
return all_list
|
96 |
+
|
97 |
+
|
98 |
+
def search(data, author_name):
|
99 |
+
matching_authors = []
|
100 |
+
for entry in data:
|
101 |
+
if entry['author'] == author_name:
|
102 |
+
matching_authors.append(entry)
|
103 |
+
|
104 |
+
data_frame = pd.DataFrame(matching_authors)
|
105 |
+
return data_frame
|
106 |
+
|
107 |
+
|
108 |
+
def make_leaderboard(orgs, which_one, data):
|
109 |
data_rows = []
|
110 |
open_llm_leaderboard = get_openllm_leaderboard() if which_one == "models" else None
|
111 |
|
112 |
trend = get_trending_list(1, which_one)
|
113 |
|
114 |
+
for org in tqdm(orgs, desc=f"Proccesing Organizations ({which_one})", position=0, leave=True):
|
115 |
rank = get_ranking_trend(trend, org)
|
116 |
+
|
117 |
+
df = search(data, org)
|
118 |
+
|
119 |
if len(df) == 0:
|
120 |
continue
|
121 |
num_things = len(df)
|
|
|
178 |
leaderboard.insert(0, "Serial Number", range(1, len(leaderboard) + 1))
|
179 |
return leaderboard
|
180 |
|
|
|
|
|
|
|
181 |
|
182 |
with open("org_names.txt", "r") as f:
|
183 |
org_names_in_list = [i.rstrip("\n") for i in f.readlines()]
|
|
|
185 |
|
186 |
INTRODUCTION_TEXT = f"""
|
187 |
🎯 The Organization Leaderboard aims to track organization rankings. This space is inspired by the [Open LLM Leaderboard](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard).
|
188 |
+
|
189 |
## Available Dataframes:
|
190 |
|
191 |
- 🏛️ Models
|
|
|
258 |
gr.Markdown("""<h1 align="center" id="space-title">🤗 Organization Leaderboard</h1>""")
|
259 |
gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
|
260 |
|
261 |
+
all_models = get_models("models")
|
262 |
+
all_datasets = get_models("datasets")
|
263 |
+
all_spaces = get_models("spaces")
|
264 |
+
|
265 |
|
266 |
+
with gr.TabItem("🏛️ Models", id=1):
|
267 |
columns_to_convert = ["Organization Name", "Best Model On Open LLM Leaderboard", "Most Downloaded Model", "Most Liked Model", "Trending Model"]
|
268 |
+
models_df = make_leaderboard(org_names_in_list, "models", all_models)
|
269 |
models_df = models_df_to_clickable(models_df, columns_to_convert, "models")
|
270 |
|
271 |
headers = ["🔢 Serial Number", "🏢 Organization Name", "📥 Total Downloads", "👍 Total Likes", "🤖 Number of Models", "🏆 Best Model On Open LLM Leaderboard", "🥇 Best Rank On Open LLM Leaderboard", "📊 Average Downloads per Model", "📈 Average Likes per Model", "🚀 Most Downloaded Model", "📈 Most Download Count", "❤️ Most Liked Model", "👍 Most Like Count", "🔥 Trending Model", "👑 Best Rank at Trending Models"]
|
|
|
273 |
|
274 |
with gr.TabItem("📊 Datasets", id=2):
|
275 |
columns_to_convert = ["Organization Name", "Most Downloaded Dataset", "Most Liked Dataset", "Trending Dataset"]
|
276 |
+
dataset_df = make_leaderboard(org_names_in_list, "datasets", all_datasets)
|
277 |
dataset_df = models_df_to_clickable(dataset_df, columns_to_convert, "datasets")
|
278 |
|
279 |
headers = ["🔢 Serial Number", "🏢 Organization Name", "📥 Total Downloads", "👍 Total Likes", "📊 Number of Datasets", "📊 Average Downloads per Dataset", "📈 Average Likes per Dataset", "🚀 Most Downloaded Dataset", "📈 Most Download Count", "❤️ Most Liked Dataset", "👍 Most Like Count", "🔥 Trending Dataset", "👑 Best Rank at Trending Datasets"]
|
|
|
282 |
with gr.TabItem("🚀 Spaces", id=3):
|
283 |
columns_to_convert = ["Organization Name", "Most Liked Space", "Trending Space"]
|
284 |
|
285 |
+
spaces_df = make_leaderboard(org_names_in_list, "spaces", all_spaces)
|
286 |
spaces_df = models_df_to_clickable(spaces_df, columns_to_convert, "spaces")
|
287 |
|
288 |
headers = ["🔢 Serial Number", "🏢 Organization Name", "👍 Total Likes", "🚀 Number of Spaces", "📈 Average Likes per Space", "❤️ Most Liked Space", "👍 Most Like Count", "🔥 Trending Space", "👑 Best Rank at Trending Spaces"]
|
289 |
gr.Dataframe(spaces_df.head(150), headers=headers, interactive=False, datatype=["str", "markdown", "str", "str", "str", "markdown", "str", "markdown", "str"])
|
290 |
|
291 |
demo.launch()
|
|