openfree commited on
Commit
1474ca0
โ€ข
1 Parent(s): cbed34a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +55 -38
app.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",
@@ -538,38 +539,44 @@ target_spaces = {
538
  "VIDraft/Mouse-Hackathon": "https://huggingface.co/spaces/VIDraft/Mouse-Hackathon",
539
  "upstage/open-ko-llm-leaderboard": "https://huggingface.co/spaces/upstage/open-ko-llm-leaderboard",
540
  "LGAI-EXAONE/EXAONE-3.5-Instruct-Demo": "https://huggingface.co/spaces/LGAI-EXAONE/EXAONE-3.5-Instruct-Demo",
 
 
 
 
 
 
 
 
541
  "NCSOFT/VARCO_Arena": "https://huggingface.co/spaces/NCSOFT/VARCO_Arena"
542
  }
543
 
544
  def get_spaces_data(sort_type="trending", progress=gr.Progress()):
545
  """์ŠคํŽ˜์ด์Šค ๋ฐ์ดํ„ฐ ๊ฐ€์ ธ์˜ค๊ธฐ (trending ๋˜๋Š” modes)"""
546
- url = f"https://huggingface.co/api/spaces"
547
- params = {
548
- 'full': 'true',
549
- 'limit': 300
550
- }
551
-
552
- if sort_type == "modes":
553
- params['sort'] = 'likes' # modes๋Š” ์ข‹์•„์š” ์ˆœ์œผ๋กœ ์ •๋ ฌ
554
 
555
  try:
556
  progress(0, desc=f"Fetching {sort_type} spaces data...")
 
 
 
 
 
557
  response = requests.get(url, params=params)
558
  response.raise_for_status()
559
  all_spaces = response.json()
560
 
561
  # ์ˆœ์œ„ ์ •๋ณด ์ €์žฅ
562
- space_ranks = {space['id']: idx + 1 for idx, space in enumerate(all_spaces)}
563
-
564
- # target_spaces ํ•„ํ„ฐ๋ง ๋ฐ ์ˆœ์œ„ ์ •๋ณด ํฌํ•จ
565
- spaces = []
566
- for space in all_spaces:
567
- if space.get('id', '') in target_spaces:
568
- space['rank'] = space_ranks.get(space['id'], 'N/A')
569
- spaces.append(space)
570
 
571
- # ์ˆœ์œ„๋ณ„๋กœ ์ •๋ ฌ
572
- spaces.sort(key=lambda x: x['rank'])
 
573
 
574
  progress(0.3, desc="Creating visualization...")
575
 
@@ -580,15 +587,17 @@ def get_spaces_data(sort_type="trending", progress=gr.Progress()):
580
  ids = [space['id'] for space in spaces]
581
  ranks = [space['rank'] for space in spaces]
582
  likes = [space.get('likes', 0) for space in spaces]
 
583
 
584
- # Y์ถ• ๊ฐ’์„ ๋ฐ˜์ „ (300 - rank + 1)
585
- y_values = [301 - r for r in ranks] # ์ˆœ์œ„๋ฅผ ๋ฐ˜์ „๋œ ๊ฐ’์œผ๋กœ ๋ณ€ํ™˜
586
 
587
  # ๋ง‰๋Œ€ ๊ทธ๋ž˜ํ”„ ์ƒ์„ฑ
588
  fig.add_trace(go.Bar(
589
  x=ids,
590
  y=y_values,
591
- text=[f"Rank: {r}<br>Likes: {l}" for r, l in zip(ranks, likes)],
 
592
  textposition='auto',
593
  marker_color='rgb(158,202,225)',
594
  opacity=0.8
@@ -605,9 +614,9 @@ def get_spaces_data(sort_type="trending", progress=gr.Progress()):
605
  xaxis_title='Space ID',
606
  yaxis_title='Rank',
607
  yaxis=dict(
608
- ticktext=[str(i) for i in range(1, 301, 20)], # 1๋ถ€ํ„ฐ 300๊นŒ์ง€ 20 ๊ฐ„๊ฒฉ
609
- tickvals=[301 - i for i in range(1, 301, 20)], # ๋ฐ˜์ „๋œ ๊ฐ’
610
- range=[0, 300] # y์ถ• ๋ฒ”์œ„ ์„ค์ •
611
  ),
612
  height=800,
613
  showlegend=False,
@@ -625,11 +634,19 @@ def get_spaces_data(sort_type="trending", progress=gr.Progress()):
625
  """
626
 
627
  for space in spaces:
628
- space_id = space.get('id', '')
629
- rank = space.get('rank', 'N/A')
630
- likes = space.get('likes', 0)
631
  title = space.get('title', 'No Title')
632
- description = space.get('description', 'No Description')[:100]
 
 
 
 
 
 
 
 
 
633
 
634
  html_content += f"""
635
  <div style='
@@ -640,9 +657,9 @@ def get_spaces_data(sort_type="trending", progress=gr.Progress()):
640
  transition: transform 0.2s;
641
  '>
642
  <h3 style='color: #34495e;'>Rank #{rank} - {space_id}</h3>
643
- <p style='color: #7f8c8d;'>๐Ÿ‘ Likes: {likes}</p>
644
- <p style='color: #2c3e50;'>{title}</p>
645
- <p style='color: #7f8c8d; font-size: 0.9em;'>{description}...</p>
646
  <a href='{target_spaces[space_id]}'
647
  target='_blank'
648
  style='
@@ -663,24 +680,24 @@ def get_spaces_data(sort_type="trending", progress=gr.Progress()):
663
 
664
  # ๋ฐ์ดํ„ฐํ”„๋ ˆ์ž„ ์ƒ์„ฑ
665
  df = pd.DataFrame([{
666
- 'Rank': space.get('rank', 'N/A'),
667
- 'Space ID': space.get('id', ''),
668
- 'Likes': space.get('likes', 'N/A'),
669
- 'Title': space.get('title', 'N/A'),
670
- 'URL': target_spaces[space.get('id', '')]
 
671
  } for space in spaces])
672
 
673
  progress(1.0, desc="Complete!")
674
  return fig, html_content, df
675
 
676
  except Exception as e:
 
677
  error_html = f'<div style="color: red; padding: 20px;">Error: {str(e)}</div>'
678
  error_plot = create_error_plot()
679
  return error_plot, error_html, pd.DataFrame()
680
 
681
 
682
-
683
-
684
  def create_trend_visualization(spaces_data):
685
  if not spaces_data:
686
  return create_error_plot()
 
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",
 
539
  "VIDraft/Mouse-Hackathon": "https://huggingface.co/spaces/VIDraft/Mouse-Hackathon",
540
  "upstage/open-ko-llm-leaderboard": "https://huggingface.co/spaces/upstage/open-ko-llm-leaderboard",
541
  "LGAI-EXAONE/EXAONE-3.5-Instruct-Demo": "https://huggingface.co/spaces/LGAI-EXAONE/EXAONE-3.5-Instruct-Demo",
542
+
543
+ "kolaslab/RC4-EnDecoder": "https://huggingface.co/spaces/kolaslab/RC4-EnDecoder",
544
+ "kolaslab/simulator": "https://huggingface.co/spaces/kolaslab/simulator",
545
+ "kolaslab/calculator": "https://huggingface.co/spaces/kolaslab/calculator",
546
+ "etri-vilab/Ko-LLaVA": "https://huggingface.co/spaces/etri-vilab/Ko-LLaVA",
547
+ "etri-vilab/KOALA": "https://huggingface.co/spaces/etri-vilab/KOALA",
548
+ "naver-clova-ix/donut-base-finetuned-cord-v2": "https://huggingface.co/spaces/naver-clova-ix/donut-base-finetuned-cord-v2",
549
+
550
  "NCSOFT/VARCO_Arena": "https://huggingface.co/spaces/NCSOFT/VARCO_Arena"
551
  }
552
 
553
  def get_spaces_data(sort_type="trending", progress=gr.Progress()):
554
  """์ŠคํŽ˜์ด์Šค ๋ฐ์ดํ„ฐ ๊ฐ€์ ธ์˜ค๊ธฐ (trending ๋˜๋Š” modes)"""
555
+ url = "https://huggingface.co/api/spaces"
 
 
 
 
 
 
 
556
 
557
  try:
558
  progress(0, desc=f"Fetching {sort_type} spaces data...")
559
+ params = {
560
+ 'full': 'true',
561
+ 'limit': 300
562
+ }
563
+
564
  response = requests.get(url, params=params)
565
  response.raise_for_status()
566
  all_spaces = response.json()
567
 
568
  # ์ˆœ์œ„ ์ •๋ณด ์ €์žฅ
569
+ space_ranks = {}
570
+ for idx, space in enumerate(all_spaces, 1):
571
+ space_id = space.get('id', '')
572
+ if space_id in target_spaces:
573
+ # ์ „์ฒด space ์ •๋ณด ์ €์žฅ
574
+ space['rank'] = idx
575
+ space_ranks[space_id] = space
 
576
 
577
+ # target_spaces ์ค‘ ์ˆœ์œ„๊ถŒ ๋‚ด space ํ•„ํ„ฐ๋ง
578
+ spaces = [space_ranks[space_id] for space_id in space_ranks.keys()]
579
+ spaces.sort(key=lambda x: x['rank']) # ์ˆœ์œ„๋ณ„๋กœ ์ •๋ ฌ
580
 
581
  progress(0.3, desc="Creating visualization...")
582
 
 
587
  ids = [space['id'] for space in spaces]
588
  ranks = [space['rank'] for space in spaces]
589
  likes = [space.get('likes', 0) for space in spaces]
590
+ titles = [space.get('title', 'No Title') for space in spaces]
591
 
592
+ # Y์ถ• ๊ฐ’์„ ๋ฐ˜์ „
593
+ y_values = [301 - r for r in ranks]
594
 
595
  # ๋ง‰๋Œ€ ๊ทธ๋ž˜ํ”„ ์ƒ์„ฑ
596
  fig.add_trace(go.Bar(
597
  x=ids,
598
  y=y_values,
599
+ text=[f"Rank: {r}<br>Title: {t}<br>Likes: {l}"
600
+ for r, t, l in zip(ranks, titles, likes)],
601
  textposition='auto',
602
  marker_color='rgb(158,202,225)',
603
  opacity=0.8
 
614
  xaxis_title='Space ID',
615
  yaxis_title='Rank',
616
  yaxis=dict(
617
+ ticktext=[str(i) for i in range(1, 301, 20)],
618
+ tickvals=[301 - i for i in range(1, 301, 20)],
619
+ range=[0, 300]
620
  ),
621
  height=800,
622
  showlegend=False,
 
634
  """
635
 
636
  for space in spaces:
637
+ space_id = space['id']
638
+ rank = space['rank']
 
639
  title = space.get('title', 'No Title')
640
+ likes = space.get('likes', 0)
641
+ description = space.get('description', '')
642
+
643
+ # cardData์—์„œ ์ถ”๊ฐ€ ์ •๋ณด ๊ฐ€์ ธ์˜ค๊ธฐ
644
+ card_data = space.get('cardData', {})
645
+ if not description and card_data:
646
+ description = card_data.get('description', 'No Description')
647
+
648
+ # description์ด ๋„ˆ๋ฌด ๊ธธ๋ฉด ์ž๋ฅด๊ธฐ
649
+ short_description = description[:150] + '...' if description and len(description) > 150 else description
650
 
651
  html_content += f"""
652
  <div style='
 
657
  transition: transform 0.2s;
658
  '>
659
  <h3 style='color: #34495e;'>Rank #{rank} - {space_id}</h3>
660
+ <h4 style='color: #2c3e50; margin: 10px 0; font-size: 1.1em;'>{title}</h4>
661
+ <p style='color: #7f8c8d; margin-bottom: 10px;'>๐Ÿ‘ Likes: {likes}</p>
662
+ <p style='color: #7f8c8d; font-size: 0.9em; margin-bottom: 15px; line-height: 1.4;'>{short_description}</p>
663
  <a href='{target_spaces[space_id]}'
664
  target='_blank'
665
  style='
 
680
 
681
  # ๋ฐ์ดํ„ฐํ”„๋ ˆ์ž„ ์ƒ์„ฑ
682
  df = pd.DataFrame([{
683
+ 'Rank': space['rank'],
684
+ 'Space ID': space['id'],
685
+ 'Title': space.get('title', 'No Title'),
686
+ 'Description': (space.get('description', '') or space.get('cardData', {}).get('description', 'No Description'))[:100] + '...',
687
+ 'Likes': space.get('likes', 0),
688
+ 'URL': target_spaces[space['id']]
689
  } for space in spaces])
690
 
691
  progress(1.0, desc="Complete!")
692
  return fig, html_content, df
693
 
694
  except Exception as e:
695
+ print(f"Error in get_spaces_data: {str(e)}")
696
  error_html = f'<div style="color: red; padding: 20px;">Error: {str(e)}</div>'
697
  error_plot = create_error_plot()
698
  return error_plot, error_html, pd.DataFrame()
699
 
700
 
 
 
701
  def create_trend_visualization(spaces_data):
702
  if not spaces_data:
703
  return create_error_plot()