Update app-backup.py
Browse files- app-backup.py +149 -124
app-backup.py
CHANGED
|
@@ -18,6 +18,7 @@ target_models = {
|
|
| 18 |
|
| 19 |
"moreh/Llama-3-Motif-102B-Instruct": "https://huggingface.co/moreh/Llama-3-Motif-102B-Instruct",
|
| 20 |
"moreh/Llama-3-Motif-102B": "https://huggingface.co/moreh/Llama-3-Motif-102B",
|
|
|
|
| 21 |
|
| 22 |
"Saxo/Linkbricks-Horizon-AI-Korean-Gemma-2-sft-dpo-27B": "https://huggingface.co/Saxo/Linkbricks-Horizon-AI-Korean-Gemma-2-sft-dpo-27B",
|
| 23 |
"AALF/gemma-2-27b-it-SimPO-37K": "https://huggingface.co/AALF/gemma-2-27b-it-SimPO-37K",
|
|
@@ -291,7 +292,6 @@ target_models = {
|
|
| 291 |
"sel303/llama3-diverce-ver1.6": "https://huggingface.co/sel303/llama3-diverce-ver1.6"
|
| 292 |
}
|
| 293 |
|
| 294 |
-
# all_models ๊ด๋ จ ์ฝ๋ ์ ๊ฑฐํ๊ณ get_models_data ํจ์ ๋ด๋ถ์์ ์ฒ๋ฆฌํ๋๋ก ์์
|
| 295 |
|
| 296 |
def get_models_data(progress=gr.Progress()):
|
| 297 |
"""๋ชจ๋ธ ๋ฐ์ดํฐ ๊ฐ์ ธ์ค๊ธฐ"""
|
|
@@ -303,44 +303,83 @@ def get_models_data(progress=gr.Progress()):
|
|
| 303 |
|
| 304 |
try:
|
| 305 |
progress(0, desc="Fetching models data...")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 306 |
|
| 307 |
-
|
| 308 |
-
all_found_models = []
|
| 309 |
-
sort_options = [
|
| 310 |
-
{'sort': 'downloads', 'direction': -1},
|
| 311 |
-
{'sort': 'lastModified', 'direction': -1},
|
| 312 |
-
{'sort': 'likes', 'direction': -1}
|
| 313 |
-
]
|
| 314 |
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
}
|
| 321 |
-
|
| 322 |
-
headers = {'Accept': 'application/json'}
|
| 323 |
-
|
| 324 |
-
response = requests.get(url, params=params, headers=headers)
|
| 325 |
-
if response.status_code == 200:
|
| 326 |
-
models = response.json()
|
| 327 |
-
all_found_models.extend(models)
|
| 328 |
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
|
|
|
|
|
|
|
|
|
| 333 |
model_id = normalize_model_id(model.get('id', ''))
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
|
|
|
|
|
|
|
|
|
| 337 |
|
| 338 |
-
#
|
| 339 |
-
filtered_models
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 340 |
|
| 341 |
-
#
|
| 342 |
-
|
| 343 |
-
|
|
|
|
| 344 |
|
| 345 |
if not filtered_models:
|
| 346 |
return create_error_plot(), "<div>์ ํ๋ ๋ชจ๋ธ์ ๋ฐ์ดํฐ๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค.</div>", pd.DataFrame()
|
|
@@ -353,17 +392,17 @@ def get_models_data(progress=gr.Progress()):
|
|
| 353 |
# ๋ฐ์ดํฐ ์ค๋น
|
| 354 |
ids = [model['id'] for model in filtered_models]
|
| 355 |
ranks = [model['rank'] for model in filtered_models]
|
| 356 |
-
likes = [model
|
| 357 |
-
downloads = [model
|
| 358 |
|
| 359 |
-
# Y์ถ ๊ฐ์ ๋ฐ์
|
| 360 |
-
y_values = [
|
| 361 |
|
| 362 |
# ๋ง๋ ๊ทธ๋ํ ์์ฑ
|
| 363 |
fig.add_trace(go.Bar(
|
| 364 |
x=ids,
|
| 365 |
y=y_values,
|
| 366 |
-
text=[f"Rank: {r}<br>Likes: {l}<br>Downloads: {d}"
|
| 367 |
for r, l, d in zip(ranks, likes, downloads)],
|
| 368 |
textposition='auto',
|
| 369 |
marker_color='rgb(158,202,225)',
|
|
@@ -372,18 +411,18 @@ def get_models_data(progress=gr.Progress()):
|
|
| 372 |
|
| 373 |
fig.update_layout(
|
| 374 |
title={
|
| 375 |
-
'text': 'Hugging Face Models
|
| 376 |
'y':0.95,
|
| 377 |
'x':0.5,
|
| 378 |
'xanchor': 'center',
|
| 379 |
'yanchor': 'top'
|
| 380 |
},
|
| 381 |
xaxis_title='Model ID',
|
| 382 |
-
yaxis_title='Rank',
|
| 383 |
yaxis=dict(
|
| 384 |
-
ticktext=[str(i) for i in range(1,
|
| 385 |
-
tickvals=[
|
| 386 |
-
range=[0,
|
| 387 |
),
|
| 388 |
height=800,
|
| 389 |
showlegend=False,
|
|
@@ -396,7 +435,7 @@ def get_models_data(progress=gr.Progress()):
|
|
| 396 |
# HTML ์นด๋ ์์ฑ
|
| 397 |
html_content = """
|
| 398 |
<div style='padding: 20px; background: #f5f5f5;'>
|
| 399 |
-
<h2 style='color: #2c3e50;'>Models
|
| 400 |
<div style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;'>
|
| 401 |
"""
|
| 402 |
|
|
@@ -406,6 +445,7 @@ def get_models_data(progress=gr.Progress()):
|
|
| 406 |
rank = model['rank']
|
| 407 |
likes = model.get('likes', 0)
|
| 408 |
downloads = model.get('downloads', 0)
|
|
|
|
| 409 |
|
| 410 |
html_content += f"""
|
| 411 |
<div style='
|
|
@@ -416,8 +456,9 @@ def get_models_data(progress=gr.Progress()):
|
|
| 416 |
transition: transform 0.2s;
|
| 417 |
'>
|
| 418 |
<h3 style='color: #34495e;'>Rank #{rank} - {model_id}</h3>
|
| 419 |
-
<p style='color: #
|
| 420 |
-
<p style='color: #7f8c8d;'
|
|
|
|
| 421 |
<a href='{target_models[model_id]}'
|
| 422 |
target='_blank'
|
| 423 |
style='
|
|
@@ -434,56 +475,20 @@ def get_models_data(progress=gr.Progress()):
|
|
| 434 |
</div>
|
| 435 |
"""
|
| 436 |
|
| 437 |
-
# ์์๊ถ ๋ฐ ๋ชจ๋ธ ์นด๋ ์์ฑ
|
| 438 |
-
for model_id in target_models:
|
| 439 |
-
if model_id not in [m['id'] for m in filtered_models]:
|
| 440 |
-
html_content += f"""
|
| 441 |
-
<div style='
|
| 442 |
-
background: #f8f9fa;
|
| 443 |
-
padding: 20px;
|
| 444 |
-
border-radius: 10px;
|
| 445 |
-
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
| 446 |
-
'>
|
| 447 |
-
<h3 style='color: #34495e;'>{model_id}</h3>
|
| 448 |
-
<p style='color: #7f8c8d;'>Not in top 1000</p>
|
| 449 |
-
<a href='{target_models[model_id]}'
|
| 450 |
-
target='_blank'
|
| 451 |
-
style='
|
| 452 |
-
display: inline-block;
|
| 453 |
-
padding: 8px 16px;
|
| 454 |
-
background: #95a5a6;
|
| 455 |
-
color: white;
|
| 456 |
-
text-decoration: none;
|
| 457 |
-
border-radius: 5px;
|
| 458 |
-
'>
|
| 459 |
-
Visit Model ๐
|
| 460 |
-
</a>
|
| 461 |
-
</div>
|
| 462 |
-
"""
|
| 463 |
-
|
| 464 |
html_content += "</div></div>"
|
| 465 |
|
| 466 |
# ๋ฐ์ดํฐํ๋ ์ ์์ฑ
|
| 467 |
df_data = []
|
| 468 |
-
#
|
| 469 |
for model in filtered_models:
|
| 470 |
df_data.append({
|
| 471 |
-
'Rank': model['rank'],
|
| 472 |
'Model ID': model['id'],
|
| 473 |
-
'
|
| 474 |
-
'
|
|
|
|
| 475 |
'URL': target_models[model['id']]
|
| 476 |
})
|
| 477 |
-
# ์์๊ถ ๋ฐ ๋ชจ๋ธ
|
| 478 |
-
for model_id in target_models:
|
| 479 |
-
if model_id not in [m['id'] for m in filtered_models]:
|
| 480 |
-
df_data.append({
|
| 481 |
-
'Rank': 'Not in top 1000',
|
| 482 |
-
'Model ID': model_id,
|
| 483 |
-
'Likes': 'N/A',
|
| 484 |
-
'Downloads': 'N/A',
|
| 485 |
-
'URL': target_models[model_id]
|
| 486 |
-
})
|
| 487 |
|
| 488 |
df = pd.DataFrame(df_data)
|
| 489 |
|
|
@@ -528,19 +533,28 @@ target_spaces = {
|
|
| 528 |
"VIDraft/Mouse-Hackathon": "https://huggingface.co/spaces/VIDraft/Mouse-Hackathon",
|
| 529 |
"upstage/open-ko-llm-leaderboard": "https://huggingface.co/spaces/upstage/open-ko-llm-leaderboard",
|
| 530 |
"LGAI-EXAONE/EXAONE-3.5-Instruct-Demo": "https://huggingface.co/spaces/LGAI-EXAONE/EXAONE-3.5-Instruct-Demo",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 531 |
"NCSOFT/VARCO_Arena": "https://huggingface.co/spaces/NCSOFT/VARCO_Arena"
|
| 532 |
}
|
| 533 |
|
| 534 |
def get_spaces_data(sort_type="trending", progress=gr.Progress()):
|
| 535 |
"""์คํ์ด์ค ๋ฐ์ดํฐ ๊ฐ์ ธ์ค๊ธฐ (trending ๋๋ modes)"""
|
| 536 |
-
url =
|
| 537 |
params = {
|
| 538 |
'full': 'true',
|
| 539 |
'limit': 300
|
| 540 |
}
|
| 541 |
|
| 542 |
if sort_type == "modes":
|
| 543 |
-
params['sort'] = 'likes'
|
| 544 |
|
| 545 |
try:
|
| 546 |
progress(0, desc=f"Fetching {sort_type} spaces data...")
|
|
@@ -549,16 +563,14 @@ def get_spaces_data(sort_type="trending", progress=gr.Progress()):
|
|
| 549 |
all_spaces = response.json()
|
| 550 |
|
| 551 |
# ์์ ์ ๋ณด ์ ์ฅ
|
| 552 |
-
space_ranks = {
|
| 553 |
-
|
| 554 |
-
|
| 555 |
-
|
| 556 |
-
|
| 557 |
-
|
| 558 |
-
space['rank'] = space_ranks.get(space['id'], 'N/A')
|
| 559 |
-
spaces.append(space)
|
| 560 |
|
| 561 |
-
|
| 562 |
spaces.sort(key=lambda x: x['rank'])
|
| 563 |
|
| 564 |
progress(0.3, desc="Creating visualization...")
|
|
@@ -570,15 +582,17 @@ def get_spaces_data(sort_type="trending", progress=gr.Progress()):
|
|
| 570 |
ids = [space['id'] for space in spaces]
|
| 571 |
ranks = [space['rank'] for space in spaces]
|
| 572 |
likes = [space.get('likes', 0) for space in spaces]
|
|
|
|
| 573 |
|
| 574 |
-
# Y์ถ ๊ฐ์ ๋ฐ์
|
| 575 |
-
y_values = [301 - r for r in ranks]
|
| 576 |
|
| 577 |
# ๋ง๋ ๊ทธ๋ํ ์์ฑ
|
| 578 |
fig.add_trace(go.Bar(
|
| 579 |
x=ids,
|
| 580 |
y=y_values,
|
| 581 |
-
text=[f"Rank: {r}<br>Likes: {l}"
|
|
|
|
| 582 |
textposition='auto',
|
| 583 |
marker_color='rgb(158,202,225)',
|
| 584 |
opacity=0.8
|
|
@@ -595,9 +609,9 @@ def get_spaces_data(sort_type="trending", progress=gr.Progress()):
|
|
| 595 |
xaxis_title='Space ID',
|
| 596 |
yaxis_title='Rank',
|
| 597 |
yaxis=dict(
|
| 598 |
-
ticktext=[str(i) for i in range(1, 301, 20)],
|
| 599 |
-
tickvals=[301 - i for i in range(1, 301, 20)],
|
| 600 |
-
range=[0, 300]
|
| 601 |
),
|
| 602 |
height=800,
|
| 603 |
showlegend=False,
|
|
@@ -615,12 +629,12 @@ def get_spaces_data(sort_type="trending", progress=gr.Progress()):
|
|
| 615 |
"""
|
| 616 |
|
| 617 |
for space in spaces:
|
| 618 |
-
space_id = space
|
| 619 |
-
rank = space
|
|
|
|
| 620 |
likes = space.get('likes', 0)
|
| 621 |
-
|
| 622 |
-
|
| 623 |
-
|
| 624 |
html_content += f"""
|
| 625 |
<div style='
|
| 626 |
background: white;
|
|
@@ -630,9 +644,18 @@ def get_spaces_data(sort_type="trending", progress=gr.Progress()):
|
|
| 630 |
transition: transform 0.2s;
|
| 631 |
'>
|
| 632 |
<h3 style='color: #34495e;'>Rank #{rank} - {space_id}</h3>
|
| 633 |
-
<
|
| 634 |
-
|
| 635 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 636 |
<a href='{target_spaces[space_id]}'
|
| 637 |
target='_blank'
|
| 638 |
style='
|
|
@@ -648,29 +671,30 @@ def get_spaces_data(sort_type="trending", progress=gr.Progress()):
|
|
| 648 |
</a>
|
| 649 |
</div>
|
| 650 |
"""
|
|
|
|
|
|
|
| 651 |
|
| 652 |
html_content += "</div></div>"
|
| 653 |
|
| 654 |
# ๋ฐ์ดํฐํ๋ ์ ์์ฑ
|
| 655 |
df = pd.DataFrame([{
|
| 656 |
-
'Rank': space
|
| 657 |
-
'Space ID': space
|
| 658 |
-
'
|
| 659 |
-
'
|
| 660 |
-
'URL': target_spaces[space
|
| 661 |
} for space in spaces])
|
| 662 |
|
| 663 |
progress(1.0, desc="Complete!")
|
| 664 |
return fig, html_content, df
|
| 665 |
|
| 666 |
except Exception as e:
|
|
|
|
| 667 |
error_html = f'<div style="color: red; padding: 20px;">Error: {str(e)}</div>'
|
| 668 |
error_plot = create_error_plot()
|
| 669 |
return error_plot, error_html, pd.DataFrame()
|
| 670 |
|
| 671 |
|
| 672 |
-
|
| 673 |
-
|
| 674 |
def create_trend_visualization(spaces_data):
|
| 675 |
if not spaces_data:
|
| 676 |
return create_error_plot()
|
|
@@ -877,13 +901,15 @@ def refresh_data():
|
|
| 877 |
else:
|
| 878 |
return create_error_plot(), "<div>API ์ธ์ฆ์ด ํ์ํฉ๋๋ค.</div>", pd.DataFrame()
|
| 879 |
|
| 880 |
-
|
| 881 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 882 |
gr.Markdown("""
|
| 883 |
-
# ๐ค ํ๊น
ํ์ด์ค 'ํ๊ตญ ๋ฆฌ๋๋ณด๋'
|
| 884 |
-
์ค์๊ฐ์ผ๋ก Hugging Face์ Spaces์ Models ์ธ๊ธฐ ์์๋ฅผ ๋ถ์ํฉ๋๋ค. ์ ๊ท ๋ฑ๋ก ์์ฒญ: [email protected]
|
| 885 |
""")
|
| 886 |
|
|
|
|
|
|
|
|
|
|
| 887 |
with gr.Tab("Spaces Trending"):
|
| 888 |
trending_plot = gr.Plot()
|
| 889 |
trending_info = gr.HTML()
|
|
@@ -894,8 +920,6 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 894 |
models_info = gr.HTML()
|
| 895 |
models_df = gr.DataFrame()
|
| 896 |
|
| 897 |
-
refresh_btn = gr.Button("๐ Refresh Data", variant="primary")
|
| 898 |
-
|
| 899 |
def refresh_all_data():
|
| 900 |
spaces_results = get_spaces_data("trending")
|
| 901 |
models_results = get_models_data()
|
|
@@ -916,6 +940,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 916 |
trending_plot.value, trending_info.value, trending_df.value = spaces_results
|
| 917 |
models_plot.value, models_info.value, models_df.value = models_results
|
| 918 |
|
|
|
|
| 919 |
# Gradio ์ฑ ์คํ
|
| 920 |
demo.launch(
|
| 921 |
server_name="0.0.0.0",
|
|
|
|
| 18 |
|
| 19 |
"moreh/Llama-3-Motif-102B-Instruct": "https://huggingface.co/moreh/Llama-3-Motif-102B-Instruct",
|
| 20 |
"moreh/Llama-3-Motif-102B": "https://huggingface.co/moreh/Llama-3-Motif-102B",
|
| 21 |
+
"Samsung/TinyClick": "https://huggingface.co/Samsung/TinyClick",
|
| 22 |
|
| 23 |
"Saxo/Linkbricks-Horizon-AI-Korean-Gemma-2-sft-dpo-27B": "https://huggingface.co/Saxo/Linkbricks-Horizon-AI-Korean-Gemma-2-sft-dpo-27B",
|
| 24 |
"AALF/gemma-2-27b-it-SimPO-37K": "https://huggingface.co/AALF/gemma-2-27b-it-SimPO-37K",
|
|
|
|
| 292 |
"sel303/llama3-diverce-ver1.6": "https://huggingface.co/sel303/llama3-diverce-ver1.6"
|
| 293 |
}
|
| 294 |
|
|
|
|
| 295 |
|
| 296 |
def get_models_data(progress=gr.Progress()):
|
| 297 |
"""๋ชจ๋ธ ๋ฐ์ดํฐ ๊ฐ์ ธ์ค๊ธฐ"""
|
|
|
|
| 303 |
|
| 304 |
try:
|
| 305 |
progress(0, desc="Fetching models data...")
|
| 306 |
+
params = {
|
| 307 |
+
'full': 'true',
|
| 308 |
+
'limit': 3000, # 3000๊ฐ๋ก ์ฆ๊ฐ
|
| 309 |
+
'sort': 'likes',
|
| 310 |
+
'direction': -1
|
| 311 |
+
}
|
| 312 |
|
| 313 |
+
headers = {'Accept': 'application/json'}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 314 |
|
| 315 |
+
response = requests.get(url, params=params, headers=headers)
|
| 316 |
+
if response.status_code != 200:
|
| 317 |
+
print(f"API ์์ฒญ ์คํจ: {response.status_code}")
|
| 318 |
+
print(f"Response: {response.text}")
|
| 319 |
+
return create_error_plot(), "<div>๋ชจ๋ธ ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์ค๋๋ฐ ์คํจํ์ต๋๋ค.</div>", pd.DataFrame()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 320 |
|
| 321 |
+
models = response.json()
|
| 322 |
+
|
| 323 |
+
# ์ ์ฒด ์์ ์ ๋ณด ์ ์ฅ (๋ค์ด๋ก๋ ์ ๊ธฐ์ค)
|
| 324 |
+
model_ranks = {}
|
| 325 |
+
model_data = {} # ๋ชจ๋ ๋ชจ๋ธ์ ์์ธ ๋ฐ์ดํฐ ์ ์ฅ
|
| 326 |
+
|
| 327 |
+
for idx, model in enumerate(models, 1):
|
| 328 |
model_id = normalize_model_id(model.get('id', ''))
|
| 329 |
+
model_data[model_id] = {
|
| 330 |
+
'rank': idx,
|
| 331 |
+
'downloads': model.get('downloads', 0),
|
| 332 |
+
'likes': model.get('likes', 0),
|
| 333 |
+
'title': model.get('title', 'No Title')
|
| 334 |
+
}
|
| 335 |
|
| 336 |
+
# target_models ์ค ์์๊ถ ๋ด ๋ชจ๋ธ ํํฐ๋ง
|
| 337 |
+
filtered_models = []
|
| 338 |
+
for target_id in target_models.keys():
|
| 339 |
+
normalized_target_id = normalize_model_id(target_id)
|
| 340 |
+
|
| 341 |
+
# ๋จผ์ ์ ์ฒด ์์์์ ์ฐพ๊ธฐ
|
| 342 |
+
if normalized_target_id in model_data:
|
| 343 |
+
model_info = {
|
| 344 |
+
'id': target_id,
|
| 345 |
+
'rank': model_data[normalized_target_id]['rank'],
|
| 346 |
+
'downloads': model_data[normalized_target_id]['downloads'],
|
| 347 |
+
'likes': model_data[normalized_target_id]['likes'],
|
| 348 |
+
'title': model_data[normalized_target_id]['title']
|
| 349 |
+
}
|
| 350 |
+
else:
|
| 351 |
+
# ์์๊ถ ๋ฐ์ ๋ชจ๋ธ์ ๊ฐ๋ณ API ํธ์ถ๋ก ์ ๋ณด ๊ฐ์ ธ์ค๊ธฐ
|
| 352 |
+
try:
|
| 353 |
+
model_url = f"https://huggingface.co/api/models/{target_id}"
|
| 354 |
+
model_response = requests.get(model_url, headers=headers)
|
| 355 |
+
if model_response.status_code == 200:
|
| 356 |
+
model_info = model_response.json()
|
| 357 |
+
model_info['id'] = target_id
|
| 358 |
+
model_info['rank'] = 'Not in top 3000'
|
| 359 |
+
else:
|
| 360 |
+
model_info = {
|
| 361 |
+
'id': target_id,
|
| 362 |
+
'rank': 'Not in top 3000',
|
| 363 |
+
'downloads': 0,
|
| 364 |
+
'likes': 0,
|
| 365 |
+
'title': 'No Title'
|
| 366 |
+
}
|
| 367 |
+
except Exception as e:
|
| 368 |
+
print(f"Error fetching data for model {target_id}: {str(e)}")
|
| 369 |
+
model_info = {
|
| 370 |
+
'id': target_id,
|
| 371 |
+
'rank': 'Not in top 3000',
|
| 372 |
+
'downloads': 0,
|
| 373 |
+
'likes': 0,
|
| 374 |
+
'title': 'No Title'
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
filtered_models.append(model_info)
|
| 378 |
|
| 379 |
+
# ์์๋ก ์ ๋ ฌ (์์๊ฐ ์ซ์์ธ ๊ฒฝ์ฐ๋ง)
|
| 380 |
+
filtered_models.sort(key=lambda x: (
|
| 381 |
+
float('inf') if x['rank'] == 'Not in top 3000' else x['rank']
|
| 382 |
+
))
|
| 383 |
|
| 384 |
if not filtered_models:
|
| 385 |
return create_error_plot(), "<div>์ ํ๋ ๋ชจ๋ธ์ ๋ฐ์ดํฐ๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค.</div>", pd.DataFrame()
|
|
|
|
| 392 |
# ๋ฐ์ดํฐ ์ค๋น
|
| 393 |
ids = [model['id'] for model in filtered_models]
|
| 394 |
ranks = [model['rank'] for model in filtered_models]
|
| 395 |
+
likes = [model['likes'] for model in filtered_models]
|
| 396 |
+
downloads = [model['downloads'] for model in filtered_models]
|
| 397 |
|
| 398 |
+
# Y์ถ ๊ฐ์ ๋ฐ์ (์ซ์ ์์๋ง)
|
| 399 |
+
y_values = [3001 - r if isinstance(r, int) else 0 for r in ranks]
|
| 400 |
|
| 401 |
# ๋ง๋ ๊ทธ๋ํ ์์ฑ
|
| 402 |
fig.add_trace(go.Bar(
|
| 403 |
x=ids,
|
| 404 |
y=y_values,
|
| 405 |
+
text=[f"Rank: {r}<br>Likes: {l:,}<br>Downloads: {d:,}"
|
| 406 |
for r, l, d in zip(ranks, likes, downloads)],
|
| 407 |
textposition='auto',
|
| 408 |
marker_color='rgb(158,202,225)',
|
|
|
|
| 411 |
|
| 412 |
fig.update_layout(
|
| 413 |
title={
|
| 414 |
+
'text': 'Hugging Face Models Global Download Rankings (Top 3000)',
|
| 415 |
'y':0.95,
|
| 416 |
'x':0.5,
|
| 417 |
'xanchor': 'center',
|
| 418 |
'yanchor': 'top'
|
| 419 |
},
|
| 420 |
xaxis_title='Model ID',
|
| 421 |
+
yaxis_title='Global Rank',
|
| 422 |
yaxis=dict(
|
| 423 |
+
ticktext=[str(i) for i in range(1, 3001, 150)],
|
| 424 |
+
tickvals=[3001 - i for i in range(1, 3001, 150)],
|
| 425 |
+
range=[0, 3000]
|
| 426 |
),
|
| 427 |
height=800,
|
| 428 |
showlegend=False,
|
|
|
|
| 435 |
# HTML ์นด๋ ์์ฑ
|
| 436 |
html_content = """
|
| 437 |
<div style='padding: 20px; background: #f5f5f5;'>
|
| 438 |
+
<h2 style='color: #2c3e50;'>Models ๊ธ๋ก๋ฒ ์ธ๊ธฐ ์์ (Top 3000)</h2>
|
| 439 |
<div style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;'>
|
| 440 |
"""
|
| 441 |
|
|
|
|
| 445 |
rank = model['rank']
|
| 446 |
likes = model.get('likes', 0)
|
| 447 |
downloads = model.get('downloads', 0)
|
| 448 |
+
title = model.get('title', 'No Title')
|
| 449 |
|
| 450 |
html_content += f"""
|
| 451 |
<div style='
|
|
|
|
| 456 |
transition: transform 0.2s;
|
| 457 |
'>
|
| 458 |
<h3 style='color: #34495e;'>Rank #{rank} - {model_id}</h3>
|
| 459 |
+
<p style='color: #2c3e50;'>{title}</p>
|
| 460 |
+
<p style='color: #7f8c8d;'>๐ Likes: {likes:,}</p>
|
| 461 |
+
<p style='color: #7f8c8d;'>โฌ๏ธ Downloads: {downloads:,}</p>
|
| 462 |
<a href='{target_models[model_id]}'
|
| 463 |
target='_blank'
|
| 464 |
style='
|
|
|
|
| 475 |
</div>
|
| 476 |
"""
|
| 477 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 478 |
html_content += "</div></div>"
|
| 479 |
|
| 480 |
# ๋ฐ์ดํฐํ๋ ์ ์์ฑ
|
| 481 |
df_data = []
|
| 482 |
+
# ๋ชจ๋ ๋ชจ๋ธ ์ ๋ณด๋ฅผ ๋ฐ์ดํฐํ๋ ์์ ์ถ๊ฐ
|
| 483 |
for model in filtered_models:
|
| 484 |
df_data.append({
|
| 485 |
+
'Global Rank': model['rank'],
|
| 486 |
'Model ID': model['id'],
|
| 487 |
+
'Title': model.get('title', 'No Title'),
|
| 488 |
+
'Likes': f"{model.get('likes', 0):,}",
|
| 489 |
+
'Downloads': f"{model.get('downloads', 0):,}",
|
| 490 |
'URL': target_models[model['id']]
|
| 491 |
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 492 |
|
| 493 |
df = pd.DataFrame(df_data)
|
| 494 |
|
|
|
|
| 533 |
"VIDraft/Mouse-Hackathon": "https://huggingface.co/spaces/VIDraft/Mouse-Hackathon",
|
| 534 |
"upstage/open-ko-llm-leaderboard": "https://huggingface.co/spaces/upstage/open-ko-llm-leaderboard",
|
| 535 |
"LGAI-EXAONE/EXAONE-3.5-Instruct-Demo": "https://huggingface.co/spaces/LGAI-EXAONE/EXAONE-3.5-Instruct-Demo",
|
| 536 |
+
|
| 537 |
+
"cutechicken/TankWar3D": "https://huggingface.co/spaces/cutechicken/TankWar3D",
|
| 538 |
+
"kolaslab/RC4-EnDecoder": "https://huggingface.co/spaces/kolaslab/RC4-EnDecoder",
|
| 539 |
+
"kolaslab/simulator": "https://huggingface.co/spaces/kolaslab/simulator",
|
| 540 |
+
"kolaslab/calculator": "https://huggingface.co/spaces/kolaslab/calculator",
|
| 541 |
+
"etri-vilab/Ko-LLaVA": "https://huggingface.co/spaces/etri-vilab/Ko-LLaVA",
|
| 542 |
+
"etri-vilab/KOALA": "https://huggingface.co/spaces/etri-vilab/KOALA",
|
| 543 |
+
"naver-clova-ix/donut-base-finetuned-cord-v2": "https://huggingface.co/spaces/naver-clova-ix/donut-base-finetuned-cord-v2",
|
| 544 |
+
|
| 545 |
"NCSOFT/VARCO_Arena": "https://huggingface.co/spaces/NCSOFT/VARCO_Arena"
|
| 546 |
}
|
| 547 |
|
| 548 |
def get_spaces_data(sort_type="trending", progress=gr.Progress()):
|
| 549 |
"""์คํ์ด์ค ๋ฐ์ดํฐ ๊ฐ์ ธ์ค๊ธฐ (trending ๋๋ modes)"""
|
| 550 |
+
url = "https://huggingface.co/api/spaces"
|
| 551 |
params = {
|
| 552 |
'full': 'true',
|
| 553 |
'limit': 300
|
| 554 |
}
|
| 555 |
|
| 556 |
if sort_type == "modes":
|
| 557 |
+
params['sort'] = 'likes'
|
| 558 |
|
| 559 |
try:
|
| 560 |
progress(0, desc=f"Fetching {sort_type} spaces data...")
|
|
|
|
| 563 |
all_spaces = response.json()
|
| 564 |
|
| 565 |
# ์์ ์ ๋ณด ์ ์ฅ
|
| 566 |
+
space_ranks = {}
|
| 567 |
+
for idx, space in enumerate(all_spaces, 1):
|
| 568 |
+
space_id = space.get('id', '')
|
| 569 |
+
if space_id in target_spaces:
|
| 570 |
+
space['rank'] = idx
|
| 571 |
+
space_ranks[space_id] = space
|
|
|
|
|
|
|
| 572 |
|
| 573 |
+
spaces = [space_ranks[space_id] for space_id in space_ranks.keys()]
|
| 574 |
spaces.sort(key=lambda x: x['rank'])
|
| 575 |
|
| 576 |
progress(0.3, desc="Creating visualization...")
|
|
|
|
| 582 |
ids = [space['id'] for space in spaces]
|
| 583 |
ranks = [space['rank'] for space in spaces]
|
| 584 |
likes = [space.get('likes', 0) for space in spaces]
|
| 585 |
+
titles = [space.get('cardData', {}).get('title') or space.get('title', 'No Title') for space in spaces]
|
| 586 |
|
| 587 |
+
# Y์ถ ๊ฐ์ ๋ฐ์
|
| 588 |
+
y_values = [301 - r for r in ranks]
|
| 589 |
|
| 590 |
# ๋ง๋ ๊ทธ๋ํ ์์ฑ
|
| 591 |
fig.add_trace(go.Bar(
|
| 592 |
x=ids,
|
| 593 |
y=y_values,
|
| 594 |
+
text=[f"Rank: {r}<br>Title: {t}<br>Likes: {l}"
|
| 595 |
+
for r, t, l in zip(ranks, titles, likes)],
|
| 596 |
textposition='auto',
|
| 597 |
marker_color='rgb(158,202,225)',
|
| 598 |
opacity=0.8
|
|
|
|
| 609 |
xaxis_title='Space ID',
|
| 610 |
yaxis_title='Rank',
|
| 611 |
yaxis=dict(
|
| 612 |
+
ticktext=[str(i) for i in range(1, 301, 20)],
|
| 613 |
+
tickvals=[301 - i for i in range(1, 301, 20)],
|
| 614 |
+
range=[0, 300]
|
| 615 |
),
|
| 616 |
height=800,
|
| 617 |
showlegend=False,
|
|
|
|
| 629 |
"""
|
| 630 |
|
| 631 |
for space in spaces:
|
| 632 |
+
space_id = space['id']
|
| 633 |
+
rank = space['rank']
|
| 634 |
+
title = space.get('cardData', {}).get('title') or space.get('title', 'No Title')
|
| 635 |
likes = space.get('likes', 0)
|
| 636 |
+
|
| 637 |
+
# ์คํ์ด์ค ํจ์์ HTML ์นด๋ ์์ฑ ๋ถ๋ถ ์์
|
|
|
|
| 638 |
html_content += f"""
|
| 639 |
<div style='
|
| 640 |
background: white;
|
|
|
|
| 644 |
transition: transform 0.2s;
|
| 645 |
'>
|
| 646 |
<h3 style='color: #34495e;'>Rank #{rank} - {space_id}</h3>
|
| 647 |
+
<h4 style='
|
| 648 |
+
color: #2980b9;
|
| 649 |
+
margin: 10px 0;
|
| 650 |
+
font-size: 1.2em;
|
| 651 |
+
font-weight: bold;
|
| 652 |
+
text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
|
| 653 |
+
background: linear-gradient(to right, #3498db, #2980b9);
|
| 654 |
+
-webkit-background-clip: text;
|
| 655 |
+
-webkit-text-fill-color: transparent;
|
| 656 |
+
padding: 5px 0;
|
| 657 |
+
'>{title}</h4>
|
| 658 |
+
<p style='color: #7f8c8d; margin-bottom: 10px;'>๐ Likes: {likes}</p>
|
| 659 |
<a href='{target_spaces[space_id]}'
|
| 660 |
target='_blank'
|
| 661 |
style='
|
|
|
|
| 671 |
</a>
|
| 672 |
</div>
|
| 673 |
"""
|
| 674 |
+
|
| 675 |
+
|
| 676 |
|
| 677 |
html_content += "</div></div>"
|
| 678 |
|
| 679 |
# ๋ฐ์ดํฐํ๋ ์ ์์ฑ
|
| 680 |
df = pd.DataFrame([{
|
| 681 |
+
'Rank': space['rank'],
|
| 682 |
+
'Space ID': space['id'],
|
| 683 |
+
'Title': space.get('cardData', {}).get('title') or space.get('title', 'No Title'),
|
| 684 |
+
'Likes': space.get('likes', 0),
|
| 685 |
+
'URL': target_spaces[space['id']]
|
| 686 |
} for space in spaces])
|
| 687 |
|
| 688 |
progress(1.0, desc="Complete!")
|
| 689 |
return fig, html_content, df
|
| 690 |
|
| 691 |
except Exception as e:
|
| 692 |
+
print(f"Error in get_spaces_data: {str(e)}")
|
| 693 |
error_html = f'<div style="color: red; padding: 20px;">Error: {str(e)}</div>'
|
| 694 |
error_plot = create_error_plot()
|
| 695 |
return error_plot, error_html, pd.DataFrame()
|
| 696 |
|
| 697 |
|
|
|
|
|
|
|
| 698 |
def create_trend_visualization(spaces_data):
|
| 699 |
if not spaces_data:
|
| 700 |
return create_error_plot()
|
|
|
|
| 901 |
else:
|
| 902 |
return create_error_plot(), "<div>API ์ธ์ฆ์ด ํ์ํฉ๋๋ค.</div>", pd.DataFrame()
|
| 903 |
|
|
|
|
| 904 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 905 |
gr.Markdown("""
|
| 906 |
+
# ๐ค ํ๊น
ํ์ด์ค 'ํ๊ตญ(์ธ์ด) ๋ฆฌ๋๋ณด๋'
|
| 907 |
+
์ค์๊ฐ์ผ๋ก Hugging Face์ Spaces์ Models ์ธ๊ธฐ ์์๋ฅผ ๋ถ์ํฉ๋๋ค. ํ๊ตญ์ธ(๊ธฐ์
)์ด ๊ณต๊ฐ ๋ฐ ํ๊ตญ์ด 'LLM ๋ฆฌ๋๋ณด๋'์ ๊ณต๊ฐ๋ ๋ฆฌ์คํธ ๋ฑ์ ๋ฑ๋ก. ์ ๊ท ๋ฑ๋ก ์์ฒญ: [email protected]
|
| 908 |
""")
|
| 909 |
|
| 910 |
+
# ์๋ก ๊ณ ์นจ ๋ฒํผ์ ์๋จ์ผ๋ก ์ด๋ํ๊ณ ํ๊ธ๋ก ๋ณ๊ฒฝ
|
| 911 |
+
refresh_btn = gr.Button("๐ ์๋ก ๊ณ ์นจ", variant="primary")
|
| 912 |
+
|
| 913 |
with gr.Tab("Spaces Trending"):
|
| 914 |
trending_plot = gr.Plot()
|
| 915 |
trending_info = gr.HTML()
|
|
|
|
| 920 |
models_info = gr.HTML()
|
| 921 |
models_df = gr.DataFrame()
|
| 922 |
|
|
|
|
|
|
|
| 923 |
def refresh_all_data():
|
| 924 |
spaces_results = get_spaces_data("trending")
|
| 925 |
models_results = get_models_data()
|
|
|
|
| 940 |
trending_plot.value, trending_info.value, trending_df.value = spaces_results
|
| 941 |
models_plot.value, models_info.value, models_df.value = models_results
|
| 942 |
|
| 943 |
+
|
| 944 |
# Gradio ์ฑ ์คํ
|
| 945 |
demo.launch(
|
| 946 |
server_name="0.0.0.0",
|