openfree commited on
Commit
ad40285
ยท
verified ยท
1 Parent(s): 047cc12

Update app-backup.py

Browse files
Files changed (1) hide show
  1. 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=1000):
323
  """๋ชจ๋“  ๋ชจ๋ธ๊ณผ Korea ๊ด€๋ จ ๋ชจ๋ธ ๊ฐ€์ ธ์˜ค๊ธฐ"""
324
  all_models = []
 
325
 
326
- # 1. ์ผ๋ฐ˜ ๋ชจ๋ธ ๋ฆฌ์ŠคํŠธ ๊ฐ€์ ธ์˜ค๊ธฐ
327
- params = {
328
- "limit": limit,
329
- "full": "True",
330
- "config": "True"
331
- }
332
-
333
- response = requests.get(
334
- "https://huggingface.co/api/models",
335
- headers={'Accept': 'application/json'},
336
- params=params
337
- )
338
-
339
- if response.status_code == 200:
340
- all_models.extend(response.json())
341
- print(f"Fetched {len(all_models)} general models")
 
 
 
 
 
342
 
343
- # 2. Korea ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ ๊ฐ€์ ธ์˜ค๊ธฐ
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
- all_global_models = get_all_models(limit=1000)
402
- print(f"Actually fetched models count: {len(all_global_models)}")
403
-
404
- # API ์‘๋‹ต ์ˆœ์„œ๋ฅผ ์ˆœ์œ„๋กœ ์‚ฌ์šฉํ•˜์—ฌ ์ˆœ์œ„ ๋งต ์ƒ์„ฑ
405
- rank_map = {}
406
- for rank, model in enumerate(all_global_models, 1):
407
- model_id = model.get('id', '').strip()
408
- rank_map[model_id] = {
409
- 'rank': rank,
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
- # target_models์˜ ์ˆœ์œ„ ํ™•์ธ ๋ฐ ์ •๋ณด ์ˆ˜์ง‘
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
- api_id = model_data.get('id', '').strip()
431
 
432
- # API ์‘๋‹ต ์ˆœ์„œ์—์„œ ์ˆœ์œ„ ์ฐพ๊ธฐ
433
- rank_info = rank_map.get(api_id)
434
-
435
- model_info = {
436
  'id': model_id,
437
- 'global_rank': rank_info['rank'] if rank_info else 'Not in top 1000',
438
  'downloads': model_data.get('downloads', 0),
439
  'likes': model_data.get('likes', 0),
440
- 'title': model_data.get('title', 'No Title')
441
- }
442
- filtered_models.append(model_info)
443
- print(f"Model {model_id}: Rank={model_info['global_rank']}, Downloads={model_info['downloads']}, Likes={model_info['likes']}")
 
444
  else:
445
  filtered_models.append({
446
  'id': model_id,
447
- 'global_rank': 'Not in top 1000',
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
- filtered_models.append({
455
- 'id': model_id,
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
- progress(0.3, desc="Creating visualization...")
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=y_values,
485
- text=[f"Global Rank: #{r}<br>Downloads: {format(d, ',')}<br>Likes: {format(l, ',')}"
486
- for r, d, l in zip(ranks, downloads, likes)],
487
  textposition='auto',
488
- marker_color='rgb(158,202,225)',
 
489
  opacity=0.8
490
  ))
491
-
492
  fig.update_layout(
493
- title={
494
- 'text': 'Hugging Face Models Global Rankings',
495
- 'y':0.95,
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, 1001, 50)],
504
- tickvals=[1001 - i for i in range(1, 1001, 50)],
505
- range=[0, 1000]
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 Global Rankings</h2>
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 1000"
 
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
- return create_error_plot(), f"<div>์—๋Ÿฌ ๋ฐœ์ƒ: {str(e)}</div>", pd.DataFrame()
 
 
 
 
 
 
 
 
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': 400
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 400)',
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, 401, 20)], # 1๋ถ€ํ„ฐ 400๊นŒ์ง€ 20 ๊ฐ„๊ฒฉ์œผ๋กœ ํ‘œ์‹œ
683
- tickvals=[i for i in range(1, 401, 20)],
684
- range=[1, 400] # Y์ถ• ๋ฒ”์œ„๋ฅผ 1๋ถ€ํ„ฐ 400๊นŒ์ง€๋กœ ์„ค์ •
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': 400,
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 ์‹ค์‹œ๊ฐ„ ์ธ๊ธฐ ์ˆœ์œ„๋ฅผ ๋ฐ˜์˜: ํ•œ๊ตญ์ธ(๊ธฐ์—…)์ด ๊ณต๊ฐœ, ํ•œ๊ตญ 'LLM ๋ฆฌ๋”๋ณด๋“œ' ๋ฐ TAG ๋“ฑ์„ ์ฐธ๊ณ ํ•ด ๋ฆฌ์ŠคํŠธ ๊ฐฑ์‹ . ์‹ ๊ทœ ๋“ฑ๋ก ์š”์ฒญ: [email protected]
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
  # ์ƒˆ๋กœ ๊ณ ์นจ ๋ฒ„ํŠผ์„ ์ƒ๋‹จ์œผ๋กœ ์ด๋™ํ•˜๊ณ  ํ•œ๊ธ€๋กœ ๋ณ€๊ฒฝ