Update app.py
Browse files
app.py
CHANGED
|
@@ -15,7 +15,10 @@ target_models = {
|
|
| 15 |
"LGAI-EXAONE/EXAONE-3.5-7.8B-Instruct": "https://huggingface.co/LGAI-EXAONE/EXAONE-3.5-7.8B-Instruct",
|
| 16 |
"ginipick/flux-lora-eric-cat": "https://huggingface.co/ginipick/flux-lora-eric-cat",
|
| 17 |
"seawolf2357/flux-lora-car-rolls-royce": "https://huggingface.co/seawolf2357/flux-lora-car-rolls-royce",
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
| 19 |
"Saxo/Linkbricks-Horizon-AI-Korean-Gemma-2-sft-dpo-27B": "https://huggingface.co/Saxo/Linkbricks-Horizon-AI-Korean-Gemma-2-sft-dpo-27B",
|
| 20 |
"AALF/gemma-2-27b-it-SimPO-37K": "https://huggingface.co/AALF/gemma-2-27b-it-SimPO-37K",
|
| 21 |
"nbeerbower/mistral-nemo-wissenschaft-12B": "https://huggingface.co/nbeerbower/mistral-nemo-wissenschaft-12B",
|
|
@@ -290,52 +293,46 @@ target_models = {
|
|
| 290 |
|
| 291 |
def get_models_data(progress=gr.Progress()):
|
| 292 |
"""๋ชจ๋ธ ๋ฐ์ดํฐ ๊ฐ์ ธ์ค๊ธฐ"""
|
| 293 |
-
url = "https://huggingface.co/api/models"
|
| 294 |
|
| 295 |
try:
|
| 296 |
progress(0, desc="Fetching models data...")
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
{'sort': 'downloads', 'direction': -1},
|
| 302 |
-
{'sort': 'lastModified', 'direction': -1},
|
| 303 |
-
{'sort': 'likes', 'direction': -1}
|
| 304 |
-
]
|
| 305 |
|
| 306 |
headers = {
|
| 307 |
-
'Accept': 'application/json'
|
| 308 |
-
'User-Agent': 'Mozilla/5.0'
|
| 309 |
}
|
| 310 |
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
**sort_params
|
| 316 |
-
}
|
| 317 |
-
|
| 318 |
-
response = requests.get(url, params=params, headers=headers)
|
| 319 |
-
if response.status_code == 200:
|
| 320 |
-
models = response.json()
|
| 321 |
-
all_found_models.extend(models)
|
| 322 |
-
print(f"Found {len(models)} models with {sort_params['sort']} sort")
|
| 323 |
-
|
| 324 |
-
if not all_found_models:
|
| 325 |
-
print("No models found from API")
|
| 326 |
return create_error_plot(), "<div>๋ชจ๋ธ ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์ค๋๋ฐ ์คํจํ์ต๋๋ค.</div>", pd.DataFrame()
|
| 327 |
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
print(f"Total unique models: {len(unique_models)}")
|
| 331 |
|
| 332 |
# target_models์ ๋งค์นญ
|
| 333 |
filtered_models = []
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 337 |
filtered_models.append(model)
|
| 338 |
-
print(f"
|
|
|
|
|
|
|
|
|
|
| 339 |
|
| 340 |
print(f"Matched {len(filtered_models)} models out of {len(target_models)} targets")
|
| 341 |
|
|
@@ -349,25 +346,19 @@ def get_models_data(progress=gr.Progress()):
|
|
| 349 |
|
| 350 |
# ๋ฐ์ดํฐ ์ค๋น
|
| 351 |
ids = [model['id'] for model in filtered_models]
|
| 352 |
-
|
| 353 |
likes = [model.get('likes', 0) for model in filtered_models]
|
|
|
|
| 354 |
|
| 355 |
-
#
|
| 356 |
-
sorted_models = sorted(filtered_models, key=lambda x: x.get('downloads', 0), reverse=True)
|
| 357 |
-
for idx, model in enumerate(sorted_models):
|
| 358 |
-
model['rank'] = idx + 1
|
| 359 |
-
|
| 360 |
-
ranks = [model['rank'] for model in sorted_models]
|
| 361 |
-
|
| 362 |
-
# Y์ถ ๊ฐ์ ๋ฐ์
|
| 363 |
y_values = [1001 - r for r in ranks]
|
| 364 |
|
| 365 |
# ๋ง๋ ๊ทธ๋ํ ์์ฑ
|
| 366 |
fig.add_trace(go.Bar(
|
| 367 |
x=ids,
|
| 368 |
y=y_values,
|
| 369 |
-
text=[f"Rank: {r}<br>
|
| 370 |
-
for r,
|
| 371 |
textposition='auto',
|
| 372 |
marker_color='rgb(158,202,225)',
|
| 373 |
opacity=0.8
|
|
@@ -375,7 +366,7 @@ def get_models_data(progress=gr.Progress()):
|
|
| 375 |
|
| 376 |
fig.update_layout(
|
| 377 |
title={
|
| 378 |
-
'text': 'Hugging Face Models Rankings (Top 1000)',
|
| 379 |
'y':0.95,
|
| 380 |
'x':0.5,
|
| 381 |
'xanchor': 'center',
|
|
@@ -399,15 +390,16 @@ def get_models_data(progress=gr.Progress()):
|
|
| 399 |
# HTML ์นด๋ ์์ฑ
|
| 400 |
html_content = """
|
| 401 |
<div style='padding: 20px; background: #f5f5f5;'>
|
| 402 |
-
<h2 style='color: #2c3e50;'>Models Rankings</h2>
|
| 403 |
<div style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;'>
|
| 404 |
"""
|
| 405 |
|
| 406 |
-
|
|
|
|
| 407 |
model_id = model['id']
|
| 408 |
rank = model['rank']
|
| 409 |
-
downloads = model.get('downloads', 0)
|
| 410 |
likes = model.get('likes', 0)
|
|
|
|
| 411 |
|
| 412 |
html_content += f"""
|
| 413 |
<div style='
|
|
@@ -418,8 +410,8 @@ def get_models_data(progress=gr.Progress()):
|
|
| 418 |
transition: transform 0.2s;
|
| 419 |
'>
|
| 420 |
<h3 style='color: #34495e;'>Rank #{rank} - {model_id}</h3>
|
| 421 |
-
<p style='color: #7f8c8d;'>โฌ๏ธ Downloads: {downloads}</p>
|
| 422 |
<p style='color: #7f8c8d;'>๐ Likes: {likes}</p>
|
|
|
|
| 423 |
<a href='{target_models[model_id]}'
|
| 424 |
target='_blank'
|
| 425 |
style='
|
|
@@ -436,16 +428,58 @@ def get_models_data(progress=gr.Progress()):
|
|
| 436 |
</div>
|
| 437 |
"""
|
| 438 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 439 |
html_content += "</div></div>"
|
| 440 |
|
| 441 |
# ๋ฐ์ดํฐํ๋ ์ ์์ฑ
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 449 |
|
| 450 |
progress(1.0, desc="Complete!")
|
| 451 |
return fig, html_content, df
|
|
|
|
| 15 |
"LGAI-EXAONE/EXAONE-3.5-7.8B-Instruct": "https://huggingface.co/LGAI-EXAONE/EXAONE-3.5-7.8B-Instruct",
|
| 16 |
"ginipick/flux-lora-eric-cat": "https://huggingface.co/ginipick/flux-lora-eric-cat",
|
| 17 |
"seawolf2357/flux-lora-car-rolls-royce": "https://huggingface.co/seawolf2357/flux-lora-car-rolls-royce",
|
| 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",
|
| 24 |
"nbeerbower/mistral-nemo-wissenschaft-12B": "https://huggingface.co/nbeerbower/mistral-nemo-wissenschaft-12B",
|
|
|
|
| 293 |
|
| 294 |
def get_models_data(progress=gr.Progress()):
|
| 295 |
"""๋ชจ๋ธ ๋ฐ์ดํฐ ๊ฐ์ ธ์ค๊ธฐ"""
|
| 296 |
+
url = "https://huggingface.co/api/models/trending" # trending API ์ฌ์ฉ
|
| 297 |
|
| 298 |
try:
|
| 299 |
progress(0, desc="Fetching models data...")
|
| 300 |
+
params = {
|
| 301 |
+
'full': 'true',
|
| 302 |
+
'limit': 1000
|
| 303 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 304 |
|
| 305 |
headers = {
|
| 306 |
+
'Accept': 'application/json'
|
|
|
|
| 307 |
}
|
| 308 |
|
| 309 |
+
response = requests.get(url, params=params, headers=headers)
|
| 310 |
+
if response.status_code != 200:
|
| 311 |
+
print(f"API ์์ฒญ ์คํจ: {response.status_code}")
|
| 312 |
+
print(f"Response: {response.text}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 313 |
return create_error_plot(), "<div>๋ชจ๋ธ ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์ค๋๋ฐ ์คํจํ์ต๋๋ค.</div>", pd.DataFrame()
|
| 314 |
|
| 315 |
+
models = response.json()
|
| 316 |
+
print(f"Total models fetched: {len(models)}")
|
|
|
|
| 317 |
|
| 318 |
# target_models์ ๋งค์นญ
|
| 319 |
filtered_models = []
|
| 320 |
+
model_ranks = {}
|
| 321 |
+
|
| 322 |
+
# ์ ์ฒด ์์ ์ ๋ณด ์ ์ฅ
|
| 323 |
+
for idx, model in enumerate(models, 1):
|
| 324 |
+
model_id = model.get('id', '')
|
| 325 |
+
model_ranks[model_id] = idx
|
| 326 |
+
|
| 327 |
+
# target_models ์ค ์์๊ถ ๋ด ๋ชจ๋ธ ํํฐ๋ง
|
| 328 |
+
for model in models:
|
| 329 |
+
if model.get('id', '') in target_models:
|
| 330 |
+
model['rank'] = model_ranks[model.get('id', '')]
|
| 331 |
filtered_models.append(model)
|
| 332 |
+
print(f"Found model: {model.get('id', '')} at rank {model['rank']}")
|
| 333 |
+
|
| 334 |
+
# ์์๋ก ์ ๋ ฌ
|
| 335 |
+
filtered_models.sort(key=lambda x: x['rank'])
|
| 336 |
|
| 337 |
print(f"Matched {len(filtered_models)} models out of {len(target_models)} targets")
|
| 338 |
|
|
|
|
| 346 |
|
| 347 |
# ๋ฐ์ดํฐ ์ค๋น
|
| 348 |
ids = [model['id'] for model in filtered_models]
|
| 349 |
+
ranks = [model['rank'] for model in filtered_models]
|
| 350 |
likes = [model.get('likes', 0) for model in filtered_models]
|
| 351 |
+
downloads = [model.get('downloads', 0) for model in filtered_models]
|
| 352 |
|
| 353 |
+
# Y์ถ ๊ฐ์ ๋ฐ์ (1000 - rank + 1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 354 |
y_values = [1001 - r for r in ranks]
|
| 355 |
|
| 356 |
# ๋ง๋ ๊ทธ๋ํ ์์ฑ
|
| 357 |
fig.add_trace(go.Bar(
|
| 358 |
x=ids,
|
| 359 |
y=y_values,
|
| 360 |
+
text=[f"Rank: {r}<br>Likes: {l}<br>Downloads: {d}"
|
| 361 |
+
for r, l, d in zip(ranks, likes, downloads)],
|
| 362 |
textposition='auto',
|
| 363 |
marker_color='rgb(158,202,225)',
|
| 364 |
opacity=0.8
|
|
|
|
| 366 |
|
| 367 |
fig.update_layout(
|
| 368 |
title={
|
| 369 |
+
'text': 'Hugging Face Models Trending Rankings (Top 1000)',
|
| 370 |
'y':0.95,
|
| 371 |
'x':0.5,
|
| 372 |
'xanchor': 'center',
|
|
|
|
| 390 |
# HTML ์นด๋ ์์ฑ
|
| 391 |
html_content = """
|
| 392 |
<div style='padding: 20px; background: #f5f5f5;'>
|
| 393 |
+
<h2 style='color: #2c3e50;'>Models Trending Rankings</h2>
|
| 394 |
<div style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;'>
|
| 395 |
"""
|
| 396 |
|
| 397 |
+
# ์์๊ถ ๋ด ๋ชจ๋ธ ์นด๋ ์์ฑ
|
| 398 |
+
for model in filtered_models:
|
| 399 |
model_id = model['id']
|
| 400 |
rank = model['rank']
|
|
|
|
| 401 |
likes = model.get('likes', 0)
|
| 402 |
+
downloads = model.get('downloads', 0)
|
| 403 |
|
| 404 |
html_content += f"""
|
| 405 |
<div style='
|
|
|
|
| 410 |
transition: transform 0.2s;
|
| 411 |
'>
|
| 412 |
<h3 style='color: #34495e;'>Rank #{rank} - {model_id}</h3>
|
|
|
|
| 413 |
<p style='color: #7f8c8d;'>๐ Likes: {likes}</p>
|
| 414 |
+
<p style='color: #7f8c8d;'>โฌ๏ธ Downloads: {downloads}</p>
|
| 415 |
<a href='{target_models[model_id]}'
|
| 416 |
target='_blank'
|
| 417 |
style='
|
|
|
|
| 428 |
</div>
|
| 429 |
"""
|
| 430 |
|
| 431 |
+
# ์์๊ถ ๋ฐ ๋ชจ๋ธ ์นด๋ ์์ฑ
|
| 432 |
+
for model_id in target_models:
|
| 433 |
+
if model_id not in [m['id'] for m in filtered_models]:
|
| 434 |
+
html_content += f"""
|
| 435 |
+
<div style='
|
| 436 |
+
background: #f8f9fa;
|
| 437 |
+
padding: 20px;
|
| 438 |
+
border-radius: 10px;
|
| 439 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
| 440 |
+
'>
|
| 441 |
+
<h3 style='color: #34495e;'>{model_id}</h3>
|
| 442 |
+
<p style='color: #7f8c8d;'>Not in top 1000</p>
|
| 443 |
+
<a href='{target_models[model_id]}'
|
| 444 |
+
target='_blank'
|
| 445 |
+
style='
|
| 446 |
+
display: inline-block;
|
| 447 |
+
padding: 8px 16px;
|
| 448 |
+
background: #95a5a6;
|
| 449 |
+
color: white;
|
| 450 |
+
text-decoration: none;
|
| 451 |
+
border-radius: 5px;
|
| 452 |
+
'>
|
| 453 |
+
Visit Model ๐
|
| 454 |
+
</a>
|
| 455 |
+
</div>
|
| 456 |
+
"""
|
| 457 |
+
|
| 458 |
html_content += "</div></div>"
|
| 459 |
|
| 460 |
# ๋ฐ์ดํฐํ๋ ์ ์์ฑ
|
| 461 |
+
df_data = []
|
| 462 |
+
# ์์๊ถ ๋ด ๋ชจ๋ธ
|
| 463 |
+
for model in filtered_models:
|
| 464 |
+
df_data.append({
|
| 465 |
+
'Rank': model['rank'],
|
| 466 |
+
'Model ID': model['id'],
|
| 467 |
+
'Likes': model.get('likes', 'N/A'),
|
| 468 |
+
'Downloads': model.get('downloads', 'N/A'),
|
| 469 |
+
'URL': target_models[model['id']]
|
| 470 |
+
})
|
| 471 |
+
# ์์๊ถ ๋ฐ ๋ชจ๋ธ
|
| 472 |
+
for model_id in target_models:
|
| 473 |
+
if model_id not in [m['id'] for m in filtered_models]:
|
| 474 |
+
df_data.append({
|
| 475 |
+
'Rank': 'Not in top 1000',
|
| 476 |
+
'Model ID': model_id,
|
| 477 |
+
'Likes': 'N/A',
|
| 478 |
+
'Downloads': 'N/A',
|
| 479 |
+
'URL': target_models[model_id]
|
| 480 |
+
})
|
| 481 |
+
|
| 482 |
+
df = pd.DataFrame(df_data)
|
| 483 |
|
| 484 |
progress(1.0, desc="Complete!")
|
| 485 |
return fig, html_content, df
|