Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -303,7 +303,7 @@ def get_models_data(progress=gr.Progress()):
|
|
303 |
progress(0, desc="Fetching models data...")
|
304 |
params = {
|
305 |
'full': 'true',
|
306 |
-
'limit':
|
307 |
'sort': 'downloads',
|
308 |
'direction': -1
|
309 |
}
|
@@ -320,21 +320,30 @@ def get_models_data(progress=gr.Progress()):
|
|
320 |
|
321 |
# ์ ์ฒด ์์ ์ ๋ณด ์ ์ฅ (๋ค์ด๋ก๋ ์ ๊ธฐ์ค)
|
322 |
model_ranks = {}
|
|
|
|
|
323 |
for idx, model in enumerate(models, 1):
|
324 |
model_id = normalize_model_id(model.get('id', ''))
|
325 |
-
|
326 |
'rank': idx,
|
327 |
'downloads': model.get('downloads', 0),
|
328 |
-
'likes': model.get('likes', 0)
|
|
|
329 |
}
|
330 |
|
331 |
# target_models ์ค ์์๊ถ ๋ด ๋ชจ๋ธ ํํฐ๋ง
|
332 |
filtered_models = []
|
333 |
-
for
|
334 |
-
|
335 |
-
if
|
336 |
-
|
337 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
338 |
|
339 |
# ์์๋ก ์ ๋ ฌ
|
340 |
filtered_models.sort(key=lambda x: x['rank'])
|
@@ -350,11 +359,11 @@ def get_models_data(progress=gr.Progress()):
|
|
350 |
# ๋ฐ์ดํฐ ์ค๋น
|
351 |
ids = [model['id'] for model in filtered_models]
|
352 |
ranks = [model['rank'] for model in filtered_models]
|
353 |
-
likes = [model
|
354 |
-
downloads = [model
|
355 |
|
356 |
# Y์ถ ๊ฐ์ ๋ฐ์
|
357 |
-
y_values = [
|
358 |
|
359 |
# ๋ง๋ ๊ทธ๋ํ ์์ฑ
|
360 |
fig.add_trace(go.Bar(
|
@@ -369,7 +378,7 @@ def get_models_data(progress=gr.Progress()):
|
|
369 |
|
370 |
fig.update_layout(
|
371 |
title={
|
372 |
-
'text': 'Hugging Face Models Global Download Rankings (Top
|
373 |
'y':0.95,
|
374 |
'x':0.5,
|
375 |
'xanchor': 'center',
|
@@ -378,9 +387,9 @@ def get_models_data(progress=gr.Progress()):
|
|
378 |
xaxis_title='Model ID',
|
379 |
yaxis_title='Global Rank',
|
380 |
yaxis=dict(
|
381 |
-
ticktext=[str(i) for i in range(1,
|
382 |
-
tickvals=[
|
383 |
-
range=[0,
|
384 |
),
|
385 |
height=800,
|
386 |
showlegend=False,
|
@@ -393,7 +402,7 @@ def get_models_data(progress=gr.Progress()):
|
|
393 |
# HTML ์นด๋ ์์ฑ
|
394 |
html_content = """
|
395 |
<div style='padding: 20px; background: #f5f5f5;'>
|
396 |
-
<h2 style='color: #2c3e50;'>Models Global Download Rankings</h2>
|
397 |
<div style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;'>
|
398 |
"""
|
399 |
|
@@ -401,8 +410,9 @@ def get_models_data(progress=gr.Progress()):
|
|
401 |
for model in filtered_models:
|
402 |
model_id = model['id']
|
403 |
rank = model['rank']
|
404 |
-
likes = model
|
405 |
-
downloads = model
|
|
|
406 |
|
407 |
html_content += f"""
|
408 |
<div style='
|
@@ -413,6 +423,7 @@ def get_models_data(progress=gr.Progress()):
|
|
413 |
transition: transform 0.2s;
|
414 |
'>
|
415 |
<h3 style='color: #34495e;'>Global Rank #{rank} - {model_id}</h3>
|
|
|
416 |
<p style='color: #7f8c8d;'>๐ Likes: {likes:,}</p>
|
417 |
<p style='color: #7f8c8d;'>โฌ๏ธ Downloads: {downloads:,}</p>
|
418 |
<a href='{target_models[model_id]}'
|
@@ -442,7 +453,7 @@ def get_models_data(progress=gr.Progress()):
|
|
442 |
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
443 |
'>
|
444 |
<h3 style='color: #34495e;'>{model_id}</h3>
|
445 |
-
<p style='color: #7f8c8d;'>Not in top
|
446 |
<a href='{target_models[model_id]}'
|
447 |
target='_blank'
|
448 |
style='
|
@@ -467,16 +478,18 @@ def get_models_data(progress=gr.Progress()):
|
|
467 |
df_data.append({
|
468 |
'Global Rank': model['rank'],
|
469 |
'Model ID': model['id'],
|
470 |
-
'
|
471 |
-
'
|
|
|
472 |
'URL': target_models[model['id']]
|
473 |
})
|
474 |
# ์์๊ถ ๋ฐ ๋ชจ๋ธ
|
475 |
for model_id in target_models:
|
476 |
if model_id not in [m['id'] for m in filtered_models]:
|
477 |
df_data.append({
|
478 |
-
'Global Rank': 'Not in top
|
479 |
'Model ID': model_id,
|
|
|
480 |
'Likes': 'N/A',
|
481 |
'Downloads': 'N/A',
|
482 |
'URL': target_models[model_id]
|
|
|
303 |
progress(0, desc="Fetching models data...")
|
304 |
params = {
|
305 |
'full': 'true',
|
306 |
+
'limit': 3000, # 3000๊ฐ๋ก ์ฆ๊ฐ
|
307 |
'sort': 'downloads',
|
308 |
'direction': -1
|
309 |
}
|
|
|
320 |
|
321 |
# ์ ์ฒด ์์ ์ ๋ณด ์ ์ฅ (๋ค์ด๋ก๋ ์ ๊ธฐ์ค)
|
322 |
model_ranks = {}
|
323 |
+
model_data = {} # ๋ชจ๋ ๋ชจ๋ธ์ ์์ธ ๋ฐ์ดํฐ ์ ์ฅ
|
324 |
+
|
325 |
for idx, model in enumerate(models, 1):
|
326 |
model_id = normalize_model_id(model.get('id', ''))
|
327 |
+
model_data[model_id] = {
|
328 |
'rank': idx,
|
329 |
'downloads': model.get('downloads', 0),
|
330 |
+
'likes': model.get('likes', 0),
|
331 |
+
'title': model.get('title', 'No Title')
|
332 |
}
|
333 |
|
334 |
# target_models ์ค ์์๊ถ ๋ด ๋ชจ๋ธ ํํฐ๋ง
|
335 |
filtered_models = []
|
336 |
+
for target_id in target_models.keys():
|
337 |
+
normalized_target_id = normalize_model_id(target_id)
|
338 |
+
if normalized_target_id in model_data:
|
339 |
+
model_info = {
|
340 |
+
'id': target_id,
|
341 |
+
'rank': model_data[normalized_target_id]['rank'],
|
342 |
+
'downloads': model_data[normalized_target_id]['downloads'],
|
343 |
+
'likes': model_data[normalized_target_id]['likes'],
|
344 |
+
'title': model_data[normalized_target_id]['title']
|
345 |
+
}
|
346 |
+
filtered_models.append(model_info)
|
347 |
|
348 |
# ์์๋ก ์ ๋ ฌ
|
349 |
filtered_models.sort(key=lambda x: x['rank'])
|
|
|
359 |
# ๋ฐ์ดํฐ ์ค๋น
|
360 |
ids = [model['id'] for model in filtered_models]
|
361 |
ranks = [model['rank'] for model in filtered_models]
|
362 |
+
likes = [model['likes'] for model in filtered_models]
|
363 |
+
downloads = [model['downloads'] for model in filtered_models]
|
364 |
|
365 |
# Y์ถ ๊ฐ์ ๋ฐ์
|
366 |
+
y_values = [3001 - r for r in ranks] # 3000์ผ๋ก ๋ณ๊ฒฝ
|
367 |
|
368 |
# ๋ง๋ ๊ทธ๋ํ ์์ฑ
|
369 |
fig.add_trace(go.Bar(
|
|
|
378 |
|
379 |
fig.update_layout(
|
380 |
title={
|
381 |
+
'text': 'Hugging Face Models Global Download Rankings (Top 3000)',
|
382 |
'y':0.95,
|
383 |
'x':0.5,
|
384 |
'xanchor': 'center',
|
|
|
387 |
xaxis_title='Model ID',
|
388 |
yaxis_title='Global Rank',
|
389 |
yaxis=dict(
|
390 |
+
ticktext=[str(i) for i in range(1, 3001, 150)], # ๊ฐ๊ฒฉ ์กฐ์
|
391 |
+
tickvals=[3001 - i for i in range(1, 3001, 150)],
|
392 |
+
range=[0, 3000]
|
393 |
),
|
394 |
height=800,
|
395 |
showlegend=False,
|
|
|
402 |
# HTML ์นด๋ ์์ฑ
|
403 |
html_content = """
|
404 |
<div style='padding: 20px; background: #f5f5f5;'>
|
405 |
+
<h2 style='color: #2c3e50;'>Models Global Download Rankings (Top 3000)</h2>
|
406 |
<div style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;'>
|
407 |
"""
|
408 |
|
|
|
410 |
for model in filtered_models:
|
411 |
model_id = model['id']
|
412 |
rank = model['rank']
|
413 |
+
likes = model['likes']
|
414 |
+
downloads = model['downloads']
|
415 |
+
title = model.get('title', 'No Title')
|
416 |
|
417 |
html_content += f"""
|
418 |
<div style='
|
|
|
423 |
transition: transform 0.2s;
|
424 |
'>
|
425 |
<h3 style='color: #34495e;'>Global Rank #{rank} - {model_id}</h3>
|
426 |
+
<p style='color: #2c3e50;'>{title}</p>
|
427 |
<p style='color: #7f8c8d;'>๐ Likes: {likes:,}</p>
|
428 |
<p style='color: #7f8c8d;'>โฌ๏ธ Downloads: {downloads:,}</p>
|
429 |
<a href='{target_models[model_id]}'
|
|
|
453 |
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
454 |
'>
|
455 |
<h3 style='color: #34495e;'>{model_id}</h3>
|
456 |
+
<p style='color: #7f8c8d;'>Not in top 3000 by downloads</p>
|
457 |
<a href='{target_models[model_id]}'
|
458 |
target='_blank'
|
459 |
style='
|
|
|
478 |
df_data.append({
|
479 |
'Global Rank': model['rank'],
|
480 |
'Model ID': model['id'],
|
481 |
+
'Title': model.get('title', 'No Title'),
|
482 |
+
'Likes': f"{model['likes']:,}",
|
483 |
+
'Downloads': f"{model['downloads']:,}",
|
484 |
'URL': target_models[model['id']]
|
485 |
})
|
486 |
# ์์๊ถ ๋ฐ ๋ชจ๋ธ
|
487 |
for model_id in target_models:
|
488 |
if model_id not in [m['id'] for m in filtered_models]:
|
489 |
df_data.append({
|
490 |
+
'Global Rank': 'Not in top 3000',
|
491 |
'Model ID': model_id,
|
492 |
+
'Title': 'N/A',
|
493 |
'Likes': 'N/A',
|
494 |
'Downloads': 'N/A',
|
495 |
'URL': target_models[model_id]
|