Spaces:
Running
Running
Update app-backup.py
Browse files- app-backup.py +146 -125
app-backup.py
CHANGED
@@ -10,18 +10,28 @@ HF_TOKEN = os.getenv("HF_TOKEN")
|
|
10 |
target_models = {
|
11 |
"openfree/flux-lora-korea-palace": "https://huggingface.co/openfree/flux-lora-korea-palace",
|
12 |
"seawolf2357/hanbok": "https://huggingface.co/seawolf2357/hanbok",
|
|
|
|
|
13 |
"LGAI-EXAONE/EXAONE-3.5-32B-Instruct": "https://huggingface.co/LGAI-EXAONE/EXAONE-3.5-32B-Instruct",
|
14 |
"LGAI-EXAONE/EXAONE-3.5-2.4B-Instruct": "https://huggingface.co/LGAI-EXAONE/EXAONE-3.5-2.4B-Instruct",
|
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 |
"moreh/Llama-3-Motif-102B-Instruct": "https://huggingface.co/moreh/Llama-3-Motif-102B-Instruct",
|
19 |
-
|
20 |
-
|
21 |
"NCSOFT/VARCO-VISION-14B": "https://huggingface.co/NCSOFT/VARCO-VISION-14B",
|
22 |
"NCSOFT/Llama-VARCO-8B-Instruct": "https://huggingface.co/NCSOFT/Llama-VARCO-8B-Instruct",
|
23 |
"NCSOFT/VARCO-VISION-14B-HF": "https://huggingface.co/NCSOFT/VARCO-VISION-14B-HF",
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
"Saxo/Linkbricks-Horizon-AI-Korean-Gemma-2-sft-dpo-27B": "https://huggingface.co/Saxo/Linkbricks-Horizon-AI-Korean-Gemma-2-sft-dpo-27B",
|
26 |
"AALF/gemma-2-27b-it-SimPO-37K": "https://huggingface.co/AALF/gemma-2-27b-it-SimPO-37K",
|
27 |
"nbeerbower/mistral-nemo-wissenschaft-12B": "https://huggingface.co/nbeerbower/mistral-nemo-wissenschaft-12B",
|
@@ -319,28 +329,34 @@ def get_korea_models():
|
|
319 |
print(f"Error fetching Korea models: {str(e)}")
|
320 |
return []
|
321 |
|
322 |
-
def get_all_models(limit=
|
323 |
"""๋ชจ๋ ๋ชจ๋ธ๊ณผ Korea ๊ด๋ จ ๋ชจ๋ธ ๊ฐ์ ธ์ค๊ธฐ"""
|
324 |
all_models = []
|
|
|
325 |
|
326 |
-
#
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
|
|
|
|
|
|
|
|
|
|
342 |
|
343 |
-
#
|
344 |
korea_params = {
|
345 |
"search": "korea",
|
346 |
"full": "True",
|
@@ -365,59 +381,70 @@ def get_all_models(limit=1000):
|
|
365 |
all_models.append(model)
|
366 |
existing_ids.add(model.get('id', ''))
|
367 |
|
368 |
-
# 3. Korean ๊ฒ์ ๊ฒฐ๊ณผ ๊ฐ์ ธ์ค๊ธฐ
|
369 |
-
korean_params = {
|
370 |
-
"search": "korean",
|
371 |
-
"full": "True",
|
372 |
-
"config": "True",
|
373 |
-
"limit": limit
|
374 |
-
}
|
375 |
-
|
376 |
-
korean_response = requests.get(
|
377 |
-
"https://huggingface.co/api/models",
|
378 |
-
headers={'Accept': 'application/json'},
|
379 |
-
params=korean_params
|
380 |
-
)
|
381 |
-
|
382 |
-
if korean_response.status_code == 200:
|
383 |
-
korean_models = korean_response.json()
|
384 |
-
print(f"Fetched {len(korean_models)} Korean-related models")
|
385 |
-
|
386 |
-
# ์ค๋ณต ์ ๊ฑฐํ๋ฉด์ Korean ๋ชจ๋ธ ์ถ๊ฐ
|
387 |
-
for model in korean_models:
|
388 |
-
if model.get('id', '') not in existing_ids:
|
389 |
-
all_models.append(model)
|
390 |
-
existing_ids.add(model.get('id', ''))
|
391 |
-
|
392 |
print(f"Total unique models: {len(all_models)}")
|
393 |
return all_models[:limit]
|
394 |
|
395 |
def get_models_data(progress=gr.Progress()):
|
396 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
397 |
try:
|
398 |
progress(0, desc="Fetching models...")
|
399 |
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
'likes': model.get('likes', 0),
|
411 |
-
'downloads': model.get('downloads', 0),
|
412 |
-
'title': model.get('title', 'No Title')
|
413 |
-
}
|
414 |
-
print(f"Rank {rank}: {model_id}")
|
415 |
|
416 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
417 |
filtered_models = []
|
418 |
for model_id in target_models.keys():
|
419 |
try:
|
420 |
-
# ๊ฐ๋ณ ๋ชจ๋ธ API ํธ์ถ
|
421 |
normalized_id = model_id.strip('/')
|
422 |
model_url_api = f"https://huggingface.co/api/models/{normalized_id}"
|
423 |
response = requests.get(
|
@@ -427,100 +454,77 @@ def get_models_data(progress=gr.Progress()):
|
|
427 |
|
428 |
if response.status_code == 200:
|
429 |
model_data = response.json()
|
430 |
-
|
431 |
|
432 |
-
|
433 |
-
rank_info = rank_map.get(api_id)
|
434 |
-
|
435 |
-
model_info = {
|
436 |
'id': model_id,
|
437 |
-
'global_rank':
|
438 |
'downloads': model_data.get('downloads', 0),
|
439 |
'likes': model_data.get('likes', 0),
|
440 |
-
'title': model_data.get('title', 'No Title')
|
441 |
-
|
442 |
-
|
443 |
-
|
|
|
444 |
else:
|
445 |
filtered_models.append({
|
446 |
'id': model_id,
|
447 |
-
'global_rank': 'Not in top
|
448 |
'downloads': 0,
|
449 |
'likes': 0,
|
450 |
-
'title': 'No Title'
|
|
|
451 |
})
|
452 |
except Exception as e:
|
453 |
print(f"Error processing {model_id}: {str(e)}")
|
454 |
-
|
455 |
-
|
456 |
-
'global_rank': 'Not in top 1000',
|
457 |
-
'downloads': 0,
|
458 |
-
'likes': 0,
|
459 |
-
'title': 'No Title'
|
460 |
-
})
|
461 |
-
|
462 |
# ์์๋ก ์ ๋ ฌ
|
463 |
filtered_models.sort(key=lambda x: float('inf') if isinstance(x['global_rank'], str) else x['global_rank'])
|
464 |
|
465 |
-
|
466 |
-
|
467 |
-
# ์๊ฐํ ์์ฑ
|
468 |
-
fig = go.Figure()
|
469 |
-
|
470 |
-
# ์์๊ถ ๋ด ๋ชจ๋ธ๋ง ํํฐ๋งํ์ฌ ์๊ฐํ
|
471 |
valid_models = [m for m in filtered_models if isinstance(m['global_rank'], (int, float))]
|
472 |
|
473 |
if valid_models:
|
474 |
ids = [m['id'] for m in valid_models]
|
475 |
ranks = [m['global_rank'] for m in valid_models]
|
476 |
-
likes = [m['likes'] for m in valid_models]
|
477 |
-
downloads = [m['downloads'] for m in valid_models]
|
478 |
-
|
479 |
-
# Y์ถ ๊ฐ์ ๋ฐ์ (๋์ ์์๊ฐ ์๋ก ๊ฐ๋๋ก)
|
480 |
-
y_values = [1001 - r for r in ranks]
|
481 |
|
482 |
fig.add_trace(go.Bar(
|
483 |
x=ids,
|
484 |
-
y=
|
485 |
-
text=[f"
|
486 |
-
for r,
|
487 |
textposition='auto',
|
488 |
-
marker_color='
|
|
|
489 |
opacity=0.8
|
490 |
))
|
491 |
-
|
492 |
fig.update_layout(
|
493 |
-
title=
|
494 |
-
|
495 |
-
|
496 |
-
'x':0.5,
|
497 |
-
'xanchor': 'center',
|
498 |
-
'yanchor': 'top'
|
499 |
-
},
|
500 |
-
xaxis_title='Model ID',
|
501 |
-
yaxis_title='Global Rank',
|
502 |
yaxis=dict(
|
503 |
-
ticktext=[f"#{i}" for i in range(1,
|
504 |
-
tickvals=[
|
505 |
-
range=[0,
|
506 |
),
|
507 |
height=800,
|
508 |
showlegend=False,
|
509 |
template='plotly_white',
|
510 |
xaxis_tickangle=-45
|
511 |
)
|
512 |
-
|
513 |
-
progress(0.6, desc="Creating model cards...")
|
514 |
-
|
515 |
# HTML ์นด๋ ์์ฑ
|
516 |
html_content = """
|
517 |
<div style='padding: 20px; background: #f5f5f5;'>
|
518 |
-
<h2 style='color: #2c3e50;'>Models
|
519 |
<div style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;'>
|
520 |
"""
|
521 |
|
522 |
for model in filtered_models:
|
523 |
-
rank_display = f"Global Rank #{model['global_rank']}" if isinstance(model['global_rank'], (int, float)) else "Not in top
|
|
|
524 |
|
525 |
html_content += f"""
|
526 |
<div style='
|
@@ -529,9 +533,11 @@ def get_models_data(progress=gr.Progress()):
|
|
529 |
border-radius: 10px;
|
530 |
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
531 |
transition: transform 0.2s;
|
|
|
532 |
'>
|
533 |
<h3 style='color: #34495e;'>{rank_display}</h3>
|
534 |
<h4 style='color: #2c3e50;'>{model['id']}</h4>
|
|
|
535 |
<p style='color: #7f8c8d;'>โฌ๏ธ Downloads: {format(model['downloads'], ',')}</p>
|
536 |
<p style='color: #7f8c8d;'>๐ Likes: {format(model['likes'], ',')}</p>
|
537 |
<a href='{target_models[model['id']]}'
|
@@ -559,6 +565,7 @@ def get_models_data(progress=gr.Progress()):
|
|
559 |
'Title': m['title'],
|
560 |
'Downloads': format(m['downloads'], ','),
|
561 |
'Likes': format(m['likes'], ','),
|
|
|
562 |
'URL': target_models[m['id']]
|
563 |
} for m in filtered_models])
|
564 |
|
@@ -567,12 +574,20 @@ def get_models_data(progress=gr.Progress()):
|
|
567 |
|
568 |
except Exception as e:
|
569 |
print(f"Error in get_models_data: {str(e)}")
|
570 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
571 |
|
572 |
|
573 |
# ๊ด์ฌ ์คํ์ด์ค URL ๋ฆฌ์คํธ์ ์ ๋ณด
|
574 |
target_spaces = {
|
575 |
-
|
576 |
"openfree/Korean-Leaderboard": "https://huggingface.co/spaces/openfree/Korean-Leaderboard",
|
577 |
"ginipick/FLUXllama": "https://huggingface.co/spaces/ginipick/FLUXllama",
|
578 |
"ginipick/SORA-3D": "https://huggingface.co/spaces/ginipick/SORA-3D",
|
@@ -605,6 +620,12 @@ target_spaces = {
|
|
605 |
"upstage/open-ko-llm-leaderboard": "https://huggingface.co/spaces/upstage/open-ko-llm-leaderboard",
|
606 |
"LGAI-EXAONE/EXAONE-3.5-Instruct-Demo": "https://huggingface.co/spaces/LGAI-EXAONE/EXAONE-3.5-Instruct-Demo",
|
607 |
|
|
|
|
|
|
|
|
|
|
|
|
|
608 |
"cutechicken/TankWar3D": "https://huggingface.co/spaces/cutechicken/TankWar3D",
|
609 |
"kolaslab/RC4-EnDecoder": "https://huggingface.co/spaces/kolaslab/RC4-EnDecoder",
|
610 |
"kolaslab/simulator": "https://huggingface.co/spaces/kolaslab/simulator",
|
@@ -621,7 +642,7 @@ def get_spaces_data(sort_type="trending", progress=gr.Progress()):
|
|
621 |
url = "https://huggingface.co/api/spaces"
|
622 |
params = {
|
623 |
'full': 'true',
|
624 |
-
'limit':
|
625 |
}
|
626 |
|
627 |
if sort_type == "modes":
|
@@ -668,7 +689,7 @@ def get_spaces_data(sort_type="trending", progress=gr.Progress()):
|
|
668 |
|
669 |
fig.update_layout(
|
670 |
title={
|
671 |
-
'text': f'Hugging Face Spaces {sort_type.title()} Rankings (Top
|
672 |
'y':0.95,
|
673 |
'x':0.5,
|
674 |
'xanchor': 'center',
|
@@ -679,9 +700,9 @@ def get_spaces_data(sort_type="trending", progress=gr.Progress()):
|
|
679 |
yaxis=dict(
|
680 |
autorange='reversed', # Y์ถ์ ๋ฐ์
|
681 |
tickmode='array',
|
682 |
-
ticktext=[str(i) for i in range(1,
|
683 |
-
tickvals=[i for i in range(1,
|
684 |
-
range=[1,
|
685 |
),
|
686 |
height=800,
|
687 |
showlegend=False,
|
@@ -829,7 +850,7 @@ def get_trending_spaces_without_token():
|
|
829 |
params = {
|
830 |
'sort': 'likes',
|
831 |
'direction': -1,
|
832 |
-
'limit':
|
833 |
'full': 'true'
|
834 |
}
|
835 |
|
@@ -971,7 +992,7 @@ def refresh_data():
|
|
971 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
972 |
gr.Markdown("""
|
973 |
# ๐ค ํ๊น
ํ์ด์ค 'ํ๊ตญ(์ธ์ด) ๋ฆฌ๋๋ณด๋'
|
974 |
-
HuggingFace๊ฐ ์ ๊ณตํ๋ Spaces์ Models ์ค์๊ฐ ์ธ๊ธฐ
|
975 |
""")
|
976 |
|
977 |
# ์๋ก ๊ณ ์นจ ๋ฒํผ์ ์๋จ์ผ๋ก ์ด๋ํ๊ณ ํ๊ธ๋ก ๋ณ๊ฒฝ
|
|
|
10 |
target_models = {
|
11 |
"openfree/flux-lora-korea-palace": "https://huggingface.co/openfree/flux-lora-korea-palace",
|
12 |
"seawolf2357/hanbok": "https://huggingface.co/seawolf2357/hanbok",
|
13 |
+
"seawolf2357/ntower": "https://huggingface.co/seawolf2357/ntower",
|
14 |
+
|
15 |
"LGAI-EXAONE/EXAONE-3.5-32B-Instruct": "https://huggingface.co/LGAI-EXAONE/EXAONE-3.5-32B-Instruct",
|
16 |
"LGAI-EXAONE/EXAONE-3.5-2.4B-Instruct": "https://huggingface.co/LGAI-EXAONE/EXAONE-3.5-2.4B-Instruct",
|
17 |
"LGAI-EXAONE/EXAONE-3.5-7.8B-Instruct": "https://huggingface.co/LGAI-EXAONE/EXAONE-3.5-7.8B-Instruct",
|
18 |
"ginipick/flux-lora-eric-cat": "https://huggingface.co/ginipick/flux-lora-eric-cat",
|
19 |
"seawolf2357/flux-lora-car-rolls-royce": "https://huggingface.co/seawolf2357/flux-lora-car-rolls-royce",
|
20 |
"moreh/Llama-3-Motif-102B-Instruct": "https://huggingface.co/moreh/Llama-3-Motif-102B-Instruct",
|
21 |
+
"OnomaAIResearch/Illustrious-xl-early-release-v0": "https://huggingface.co/OnomaAIResearch/Illustrious-xl-early-release-v0",
|
22 |
+
"upstage/solar-pro-preview-instruct": "https://huggingface.co/upstage/solar-pro-preview-instruct",
|
23 |
"NCSOFT/VARCO-VISION-14B": "https://huggingface.co/NCSOFT/VARCO-VISION-14B",
|
24 |
"NCSOFT/Llama-VARCO-8B-Instruct": "https://huggingface.co/NCSOFT/Llama-VARCO-8B-Instruct",
|
25 |
"NCSOFT/VARCO-VISION-14B-HF": "https://huggingface.co/NCSOFT/VARCO-VISION-14B-HF",
|
26 |
+
"KAERI-MLP/llama-3.1-Korean-AtomicGPT-Bllossom-8B": "https://huggingface.co/KAERI-MLP/llama-3.1-Korean-AtomicGPT-Bllossom-8B",
|
27 |
+
"dnotitia/Llama-DNA-1.0-8B-Instruct": "https://huggingface.co/dnotitia/Llama-DNA-1.0-8B-Instruct",
|
28 |
+
"Bllossom/llama-3.2-Korean-Bllossom-3B": "https://huggingface.co/Bllossom/llama-3.2-Korean-Bllossom-3B",
|
29 |
+
|
30 |
+
"unidocs/llama-3.1-8b-komedic-instruct": "https://huggingface.co/unidocs/llama-3.1-8b-komedic-instruct",
|
31 |
+
"unidocs/llama-3.2-3b-komedic-instruct": "https://huggingface.co/unidocs/llama-3.2-3b-komedic-instruct",
|
32 |
+
"etri-lirs/eagle-3b-preview": "https://huggingface.co/etri-lirs/eagle-3b-preview",
|
33 |
+
"kakaobrain/kogpt": "https://huggingface.co/kakaobrain/kogpt",
|
34 |
+
|
35 |
"Saxo/Linkbricks-Horizon-AI-Korean-Gemma-2-sft-dpo-27B": "https://huggingface.co/Saxo/Linkbricks-Horizon-AI-Korean-Gemma-2-sft-dpo-27B",
|
36 |
"AALF/gemma-2-27b-it-SimPO-37K": "https://huggingface.co/AALF/gemma-2-27b-it-SimPO-37K",
|
37 |
"nbeerbower/mistral-nemo-wissenschaft-12B": "https://huggingface.co/nbeerbower/mistral-nemo-wissenschaft-12B",
|
|
|
329 |
print(f"Error fetching Korea models: {str(e)}")
|
330 |
return []
|
331 |
|
332 |
+
def get_all_models(limit=3000):
|
333 |
"""๋ชจ๋ ๋ชจ๋ธ๊ณผ Korea ๊ด๋ จ ๋ชจ๋ธ ๊ฐ์ ธ์ค๊ธฐ"""
|
334 |
all_models = []
|
335 |
+
page_size = 1000 # API์ ํ ๋ฒ ์์ฒญ๋น ์ต๋ ํฌ๊ธฐ
|
336 |
|
337 |
+
# ์ฌ๋ฌ ํ์ด์ง์ ๊ฑธ์ณ ๋ฐ์ดํฐ ์์ง
|
338 |
+
for offset in range(0, limit, page_size):
|
339 |
+
params = {
|
340 |
+
'limit': min(page_size, limit - offset),
|
341 |
+
'full': 'True',
|
342 |
+
'config': 'True',
|
343 |
+
'offset': offset
|
344 |
+
}
|
345 |
+
|
346 |
+
response = requests.get(
|
347 |
+
"https://huggingface.co/api/models",
|
348 |
+
headers={'Accept': 'application/json'},
|
349 |
+
params=params
|
350 |
+
)
|
351 |
+
|
352 |
+
if response.status_code == 200:
|
353 |
+
all_models.extend(response.json())
|
354 |
+
print(f"Fetched models {offset+1} to {offset+len(response.json())}")
|
355 |
+
else:
|
356 |
+
print(f"Failed to fetch models at offset {offset}: {response.status_code}")
|
357 |
+
break
|
358 |
|
359 |
+
# Korea ๊ฒ์ ๊ฒฐ๊ณผ๋ ๋์ผํ๊ฒ ํ์ฅ
|
360 |
korea_params = {
|
361 |
"search": "korea",
|
362 |
"full": "True",
|
|
|
381 |
all_models.append(model)
|
382 |
existing_ids.add(model.get('id', ''))
|
383 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
384 |
print(f"Total unique models: {len(all_models)}")
|
385 |
return all_models[:limit]
|
386 |
|
387 |
def get_models_data(progress=gr.Progress()):
|
388 |
+
def calculate_rank(model_id, all_global_models, korea_models):
|
389 |
+
# ๊ธ๋ก๋ฒ ์์ ํ์ธ
|
390 |
+
global_rank = next((idx for idx, m in enumerate(all_global_models, 1)
|
391 |
+
if m.get('id', '').strip() == model_id.strip()), None)
|
392 |
+
|
393 |
+
# Korea ๋ชจ๋ธ์ธ ๊ฒฝ์ฐ
|
394 |
+
is_korea = any(m.get('id', '').strip() == model_id.strip() for m in korea_models)
|
395 |
+
|
396 |
+
if is_korea:
|
397 |
+
# Korea ๋ชจ๋ธ ์ค์์์ ์์ ํ์ธ
|
398 |
+
korea_rank = next((idx for idx, m in enumerate(korea_models, 1)
|
399 |
+
if m.get('id', '').strip() == model_id.strip()), None)
|
400 |
+
|
401 |
+
if korea_rank:
|
402 |
+
return min(global_rank or 3001, korea_rank + 1000), True
|
403 |
+
|
404 |
+
return global_rank if global_rank else 'Not in top 3000', is_korea
|
405 |
+
|
406 |
try:
|
407 |
progress(0, desc="Fetching models...")
|
408 |
|
409 |
+
if not HF_TOKEN:
|
410 |
+
fig = create_error_plot()
|
411 |
+
error_html = """
|
412 |
+
<div style='padding: 20px; background: #fee; border-radius: 10px; margin: 10px 0;'>
|
413 |
+
<h3 style='color: #c00;'>โ ๏ธ API ์ธ์ฆ์ด ํ์ํฉ๋๋ค</h3>
|
414 |
+
<p>HuggingFace API ํ ํฐ์ด ์ค์ ๋์ง ์์์ต๋๋ค. ์์ ํ ๊ธฐ๋ฅ์ ์ฌ์ฉํ๊ธฐ ์ํด์๋ API ํ ํฐ์ด ํ์ํฉ๋๋ค.</p>
|
415 |
+
</div>
|
416 |
+
"""
|
417 |
+
empty_df = pd.DataFrame(columns=['Global Rank', 'Model ID', 'Title', 'Downloads', 'Likes', 'Korea Search', 'URL'])
|
418 |
+
return fig, error_html, empty_df
|
|
|
|
|
|
|
|
|
|
|
419 |
|
420 |
+
# ์ผ๋ฐ ๋ชจ๋ธ๊ณผ Korea ๊ด๋ จ ๋ชจ๋ธ ๋ชจ๋ ๊ฐ์ ธ์ค๊ธฐ (3000์๊น์ง)
|
421 |
+
all_global_models = get_all_models(limit=3000)
|
422 |
+
korea_models = get_korea_models()
|
423 |
+
|
424 |
+
print(f"Total global models fetched: {len(all_global_models)}")
|
425 |
+
print(f"Total Korea models fetched: {len(korea_models)}")
|
426 |
+
|
427 |
+
# ๋ชจ๋ ๋ชจ๋ธ ํตํฉ (์ค๋ณต ์ ๊ฑฐ)
|
428 |
+
all_models = all_global_models.copy()
|
429 |
+
existing_ids = {model.get('id', '') for model in all_global_models}
|
430 |
+
|
431 |
+
added_korea_models = 0
|
432 |
+
for korea_model in korea_models:
|
433 |
+
if korea_model.get('id', '') not in existing_ids:
|
434 |
+
all_models.append(korea_model)
|
435 |
+
existing_ids.add(korea_model.get('id', ''))
|
436 |
+
added_korea_models += 1
|
437 |
+
|
438 |
+
print(f"Added {added_korea_models} unique Korea models")
|
439 |
+
print(f"Total combined models: {len(all_models)}")
|
440 |
+
|
441 |
+
# ์๊ฐํ๋ฅผ ์ํ Figure ์์ฑ
|
442 |
+
fig = go.Figure()
|
443 |
+
|
444 |
+
# ์์ ์ ๋ณด ์์ง
|
445 |
filtered_models = []
|
446 |
for model_id in target_models.keys():
|
447 |
try:
|
|
|
448 |
normalized_id = model_id.strip('/')
|
449 |
model_url_api = f"https://huggingface.co/api/models/{normalized_id}"
|
450 |
response = requests.get(
|
|
|
454 |
|
455 |
if response.status_code == 200:
|
456 |
model_data = response.json()
|
457 |
+
rank, is_korea = calculate_rank(model_id, all_global_models, korea_models)
|
458 |
|
459 |
+
filtered_models.append({
|
|
|
|
|
|
|
460 |
'id': model_id,
|
461 |
+
'global_rank': rank,
|
462 |
'downloads': model_data.get('downloads', 0),
|
463 |
'likes': model_data.get('likes', 0),
|
464 |
+
'title': model_data.get('title', 'No Title'),
|
465 |
+
'is_korea': is_korea
|
466 |
+
})
|
467 |
+
|
468 |
+
print(f"Model {model_id}: Rank={rank}, Is Korea={is_korea}")
|
469 |
else:
|
470 |
filtered_models.append({
|
471 |
'id': model_id,
|
472 |
+
'global_rank': 'Not in top 3000',
|
473 |
'downloads': 0,
|
474 |
'likes': 0,
|
475 |
+
'title': 'No Title',
|
476 |
+
'is_korea': False
|
477 |
})
|
478 |
except Exception as e:
|
479 |
print(f"Error processing {model_id}: {str(e)}")
|
480 |
+
continue
|
481 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
482 |
# ์์๋ก ์ ๋ ฌ
|
483 |
filtered_models.sort(key=lambda x: float('inf') if isinstance(x['global_rank'], str) else x['global_rank'])
|
484 |
|
485 |
+
# ์๊ฐํ ๋ฐ์ดํฐ ์ค๋น
|
|
|
|
|
|
|
|
|
|
|
486 |
valid_models = [m for m in filtered_models if isinstance(m['global_rank'], (int, float))]
|
487 |
|
488 |
if valid_models:
|
489 |
ids = [m['id'] for m in valid_models]
|
490 |
ranks = [m['global_rank'] for m in valid_models]
|
|
|
|
|
|
|
|
|
|
|
491 |
|
492 |
fig.add_trace(go.Bar(
|
493 |
x=ids,
|
494 |
+
y=[3001 - r for r in ranks], # Y์ถ ๋ฒ์ 3000๊น์ง ํ์ฅ
|
495 |
+
text=[f"Rank: #{r}<br>Downloads: {format(m['downloads'], ',')}<br>Likes: {format(m['likes'], ',')}"
|
496 |
+
for r, m in zip(ranks, valid_models)],
|
497 |
textposition='auto',
|
498 |
+
marker_color=['rgba(255,0,0,0.6)' if m['is_korea'] else 'rgba(0,0,255,0.6)'
|
499 |
+
for m in valid_models],
|
500 |
opacity=0.8
|
501 |
))
|
502 |
+
|
503 |
fig.update_layout(
|
504 |
+
title="HuggingFace Models Global Rankings (Up to #3000)",
|
505 |
+
xaxis_title="Model ID",
|
506 |
+
yaxis_title="Global Rank",
|
|
|
|
|
|
|
|
|
|
|
|
|
507 |
yaxis=dict(
|
508 |
+
ticktext=[f"#{i}" for i in range(1, 3001, 100)],
|
509 |
+
tickvals=[3001 - i for i in range(1, 3001, 100)],
|
510 |
+
range=[0, 3000]
|
511 |
),
|
512 |
height=800,
|
513 |
showlegend=False,
|
514 |
template='plotly_white',
|
515 |
xaxis_tickangle=-45
|
516 |
)
|
517 |
+
|
|
|
|
|
518 |
# HTML ์นด๋ ์์ฑ
|
519 |
html_content = """
|
520 |
<div style='padding: 20px; background: #f5f5f5;'>
|
521 |
+
<h2 style='color: #2c3e50;'>Models Rankings (Up to #3000)</h2>
|
522 |
<div style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;'>
|
523 |
"""
|
524 |
|
525 |
for model in filtered_models:
|
526 |
+
rank_display = f"Global Rank #{model['global_rank']}" if isinstance(model['global_rank'], (int, float)) else "Not in top 3000"
|
527 |
+
korea_badge = "๐ฐ๐ท Korea Search Result" if model['is_korea'] else ""
|
528 |
|
529 |
html_content += f"""
|
530 |
<div style='
|
|
|
533 |
border-radius: 10px;
|
534 |
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
535 |
transition: transform 0.2s;
|
536 |
+
{f"border: 2px solid #e74c3c;" if model['is_korea'] else ""}
|
537 |
'>
|
538 |
<h3 style='color: #34495e;'>{rank_display}</h3>
|
539 |
<h4 style='color: #2c3e50;'>{model['id']}</h4>
|
540 |
+
<p style='color: #e74c3c; font-weight: bold;'>{korea_badge}</p>
|
541 |
<p style='color: #7f8c8d;'>โฌ๏ธ Downloads: {format(model['downloads'], ',')}</p>
|
542 |
<p style='color: #7f8c8d;'>๐ Likes: {format(model['likes'], ',')}</p>
|
543 |
<a href='{target_models[model['id']]}'
|
|
|
565 |
'Title': m['title'],
|
566 |
'Downloads': format(m['downloads'], ','),
|
567 |
'Likes': format(m['likes'], ','),
|
568 |
+
'Korea Search': '๐ฐ๐ท' if m['is_korea'] else '',
|
569 |
'URL': target_models[m['id']]
|
570 |
} for m in filtered_models])
|
571 |
|
|
|
574 |
|
575 |
except Exception as e:
|
576 |
print(f"Error in get_models_data: {str(e)}")
|
577 |
+
error_fig = create_error_plot()
|
578 |
+
error_html = f"""
|
579 |
+
<div style='padding: 20px; background: #fee; border-radius: 10px; margin: 10px 0;'>
|
580 |
+
<h3 style='color: #c00;'>โ ๏ธ ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค</h3>
|
581 |
+
<p>{str(e)}</p>
|
582 |
+
</div>
|
583 |
+
"""
|
584 |
+
empty_df = pd.DataFrame(columns=['Global Rank', 'Model ID', 'Title', 'Downloads', 'Likes', 'Korea Search', 'URL'])
|
585 |
+
return error_fig, error_html, empty_df
|
586 |
|
587 |
|
588 |
# ๊ด์ฌ ์คํ์ด์ค URL ๋ฆฌ์คํธ์ ์ ๋ณด
|
589 |
target_spaces = {
|
590 |
+
"fantos/x-mas": "https://huggingface.co/spaces/fantos/x-mas",
|
591 |
"openfree/Korean-Leaderboard": "https://huggingface.co/spaces/openfree/Korean-Leaderboard",
|
592 |
"ginipick/FLUXllama": "https://huggingface.co/spaces/ginipick/FLUXllama",
|
593 |
"ginipick/SORA-3D": "https://huggingface.co/spaces/ginipick/SORA-3D",
|
|
|
620 |
"upstage/open-ko-llm-leaderboard": "https://huggingface.co/spaces/upstage/open-ko-llm-leaderboard",
|
621 |
"LGAI-EXAONE/EXAONE-3.5-Instruct-Demo": "https://huggingface.co/spaces/LGAI-EXAONE/EXAONE-3.5-Instruct-Demo",
|
622 |
|
623 |
+
"r3gm/DiffuseCraft": "https://huggingface.co/spaces/r3gm/DiffuseCraft",
|
624 |
+
|
625 |
+
"LeeSangHoon/HierSpeech_TTS": "https://huggingface.co/spaces/LeeSangHoon/HierSpeech_TTS",
|
626 |
+
"etri-vilab/KOALA": "https://huggingface.co/spaces/etri-vilab/KOALA",
|
627 |
+
"etri-vilab/Ko-LLaVA": "https://huggingface.co/spaces/etri-vilab/Ko-LLaVA",
|
628 |
+
|
629 |
"cutechicken/TankWar3D": "https://huggingface.co/spaces/cutechicken/TankWar3D",
|
630 |
"kolaslab/RC4-EnDecoder": "https://huggingface.co/spaces/kolaslab/RC4-EnDecoder",
|
631 |
"kolaslab/simulator": "https://huggingface.co/spaces/kolaslab/simulator",
|
|
|
642 |
url = "https://huggingface.co/api/spaces"
|
643 |
params = {
|
644 |
'full': 'true',
|
645 |
+
'limit': 500
|
646 |
}
|
647 |
|
648 |
if sort_type == "modes":
|
|
|
689 |
|
690 |
fig.update_layout(
|
691 |
title={
|
692 |
+
'text': f'Hugging Face Spaces {sort_type.title()} Rankings (Top 500)',
|
693 |
'y':0.95,
|
694 |
'x':0.5,
|
695 |
'xanchor': 'center',
|
|
|
700 |
yaxis=dict(
|
701 |
autorange='reversed', # Y์ถ์ ๋ฐ์
|
702 |
tickmode='array',
|
703 |
+
ticktext=[str(i) for i in range(1, 501, 20)], # 1๋ถํฐ 400๊น์ง 20 ๊ฐ๊ฒฉ์ผ๋ก ํ์
|
704 |
+
tickvals=[i for i in range(1, 501, 20)],
|
705 |
+
range=[1, 500] # Y์ถ ๋ฒ์๋ฅผ 1๋ถํฐ 400๊น์ง๋ก ์ค์
|
706 |
),
|
707 |
height=800,
|
708 |
showlegend=False,
|
|
|
850 |
params = {
|
851 |
'sort': 'likes',
|
852 |
'direction': -1,
|
853 |
+
'limit': 500,
|
854 |
'full': 'true'
|
855 |
}
|
856 |
|
|
|
992 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
993 |
gr.Markdown("""
|
994 |
# ๐ค ํ๊น
ํ์ด์ค 'ํ๊ตญ(์ธ์ด) ๋ฆฌ๋๋ณด๋'
|
995 |
+
HuggingFace๊ฐ ์ ๊ณตํ๋ Spaces์ Models ์ค์๊ฐ ์ธ๊ธฐ ์์ ๋ฐ์ํ์ฌ 'ํ๊ตญ์(๊ธฐ์
/์ธ์ด)'์ ๋ฆฌ์คํธ(๊ณต๊ฐ,๊ฒ์,๋ฆฌ๋๋ณด๋ ๋ฑ)๋ง ๋ถ์. (c)'ํ๊ตญ์ธ๊ณต์ง๋ฅ์งํฅํํ' / ์์ฒญ: [email protected]
|
996 |
""")
|
997 |
|
998 |
# ์๋ก ๊ณ ์นจ ๋ฒํผ์ ์๋จ์ผ๋ก ์ด๋ํ๊ณ ํ๊ธ๋ก ๋ณ๊ฒฝ
|