openfree commited on
Commit
dad05a7
Β·
verified Β·
1 Parent(s): 58008e9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -89
app.py CHANGED
@@ -992,87 +992,6 @@ def refresh_data():
992
 
993
 
994
 
995
-
996
- # λ¨Όμ € target_datasets λ”•μ…”λ„ˆλ¦¬λ₯Ό μΆ”κ°€ν•©λ‹ˆλ‹€
997
- target_datasets = {
998
- "aiqtech/kolaw": "https://huggingface.co/datasets/aiqtech/kolaw",
999
- # μΆ”κ°€ 데이터셋은 여기에 계속 μΆ”κ°€ν•  수 μžˆμŠ΅λ‹ˆλ‹€
1000
- }
1001
-
1002
- def get_datasets_data(progress=gr.Progress()):
1003
- """데이터셋 데이터 κ°€μ Έμ˜€κΈ°"""
1004
- def calculate_rank(dataset_id, all_global_datasets, korea_datasets):
1005
- # κΈ€λ‘œλ²Œ μˆœμœ„ 확인
1006
- global_rank = next((idx for idx, d in enumerate(all_global_datasets, 1)
1007
- if d.get('id', '').strip() == dataset_id.strip()), None)
1008
-
1009
- # Korea 데이터셋인 경우
1010
- is_korea = any(d.get('id', '').strip() == dataset_id.strip() for d in korea_datasets)
1011
-
1012
- if is_korea:
1013
- # Korea 데이터셋 μ€‘μ—μ„œμ˜ μˆœμœ„ 확인
1014
- korea_rank = next((idx for idx, d in enumerate(korea_datasets, 1)
1015
- if d.get('id', '').strip() == dataset_id.strip()), None)
1016
-
1017
- if korea_rank:
1018
- return min(global_rank or 3001, korea_rank + 1000), True
1019
-
1020
- return global_rank if global_rank else 'Not in top 3000', is_korea
1021
-
1022
- try:
1023
- progress(0, desc="Fetching datasets...")
1024
-
1025
- if not HF_TOKEN:
1026
- fig = create_error_plot()
1027
- error_html = """
1028
- <div style='padding: 20px; background: #fee; border-radius: 10px; margin: 10px 0;'>
1029
- <h3 style='color: #c00;'>⚠️ API 인증이 ν•„μš”ν•©λ‹ˆλ‹€</h3>
1030
- <p>HuggingFace API 토큰이 μ„€μ •λ˜μ§€ μ•Šμ•˜μŠ΅λ‹ˆλ‹€.</p>
1031
- </div>
1032
- """
1033
- empty_df = pd.DataFrame(columns=['Global Rank', 'Dataset ID', 'Title', 'Downloads', 'Likes', 'Korea Search', 'URL'])
1034
- return fig, error_html, empty_df
1035
-
1036
- # 일반 데이터셋과 Korea κ΄€λ ¨ 데이터셋 κ°€μ Έμ˜€κΈ°
1037
- params = {
1038
- 'limit': 3000,
1039
- 'full': 'true'
1040
- }
1041
-
1042
- all_datasets_response = requests.get(
1043
- "https://huggingface.co/api/datasets",
1044
- headers={'Authorization': f'Bearer {HF_TOKEN}'},
1045
- params=params
1046
- )
1047
-
1048
- korea_params = {
1049
- 'search': 'korea',
1050
- 'limit': 3000,
1051
- 'full': 'true'
1052
- }
1053
-
1054
- korea_datasets_response = requests.get(
1055
- "https://huggingface.co/api/datasets",
1056
- headers={'Authorization': f'Bearer {HF_TOKEN}'},
1057
- params=korea_params
1058
- )
1059
-
1060
- all_global_datasets = all_datasets_response.json()
1061
- korea_datasets = korea_datasets_response.json()
1062
-
1063
- # μ‹œκ°ν™”λ₯Ό μœ„ν•œ Figure 생성
1064
- fig = go.Figure()
1065
-
1066
- # μˆœμœ„ 정보 μˆ˜μ§‘
1067
- filtered_datasets = []
1068
- for dataset_id in target_datasets.keys():
1069
- try:
1070
- normalized_id = dataset_id.strip('/')
1071
- dataset_url_api = f"https://huggingface.co/api/datasets/{normalized_id}"
1072
- response# λ¨Όμ € target_datasets λ”•μ…”λ„ˆλ¦¬λ₯Ό μΆ”κ°€ν•©λ‹ˆλ‹€
1073
-
1074
-
1075
-
1076
  target_datasets = {
1077
  "aiqtech/kolaw": "https://huggingface.co/datasets/aiqtech/kolaw",
1078
  "heegyu/korquad-v1-v2": "https://huggingface.co/datasets/heegyu/korquad-v1-v2",
@@ -1089,8 +1008,6 @@ target_datasets = {
1089
  }
1090
 
1091
  def get_datasets_data(progress=gr.Progress()):
1092
- try:
1093
-
1094
  def calculate_rank(dataset_id, all_global_datasets, korea_datasets):
1095
  # κΈ€λ‘œλ²Œ μˆœμœ„ 확인
1096
  global_rank = next((idx for idx, d in enumerate(all_global_datasets, 1)
@@ -1100,7 +1017,6 @@ def get_datasets_data(progress=gr.Progress()):
1100
  is_korea = any(d.get('id', '').strip() == dataset_id.strip() for d in korea_datasets)
1101
 
1102
  if is_korea:
1103
- # Korea 데이터셋 μ€‘μ—μ„œμ˜ μˆœμœ„ 확인
1104
  korea_rank = next((idx for idx, d in enumerate(korea_datasets, 1)
1105
  if d.get('id', '').strip() == dataset_id.strip()), None)
1106
 
@@ -1283,7 +1199,9 @@ def get_datasets_data(progress=gr.Progress()):
1283
 
1284
  progress(1.0, desc="Complete!")
1285
 
 
1286
  return fig, html_content, df
 
1287
  except Exception as e:
1288
  print(f"Error in get_datasets_data: {str(e)}")
1289
  error_fig = create_error_plot()
@@ -1296,7 +1214,7 @@ def get_datasets_data(progress=gr.Progress()):
1296
  empty_df = pd.DataFrame(columns=['Global Rank', 'Dataset ID', 'Title', 'Downloads', 'Likes', 'Korea Search', 'URL'])
1297
  return error_fig, error_html, empty_df
1298
 
1299
-
1300
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
1301
  gr.Markdown("""
1302
  # πŸ€— ν—ˆκΉ…νŽ˜μ΄μŠ€ 'ν•œκ΅­(μ–Έμ–΄) λ¦¬λ”λ³΄λ“œ'
@@ -1345,13 +1263,12 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
1345
  datasets_results = get_datasets_data()
1346
 
1347
  trending_plot.value, trending_info.value, trending_df.value = spaces_results
1348
- models_plot.value, models_
1349
-
1350
-
1351
 
1352
  # Gradio μ•± μ‹€ν–‰
1353
  demo.launch(
1354
  server_name="0.0.0.0",
1355
  server_port=7860,
1356
  share=False
1357
- )
 
992
 
993
 
994
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
995
  target_datasets = {
996
  "aiqtech/kolaw": "https://huggingface.co/datasets/aiqtech/kolaw",
997
  "heegyu/korquad-v1-v2": "https://huggingface.co/datasets/heegyu/korquad-v1-v2",
 
1008
  }
1009
 
1010
  def get_datasets_data(progress=gr.Progress()):
 
 
1011
  def calculate_rank(dataset_id, all_global_datasets, korea_datasets):
1012
  # κΈ€λ‘œλ²Œ μˆœμœ„ 확인
1013
  global_rank = next((idx for idx, d in enumerate(all_global_datasets, 1)
 
1017
  is_korea = any(d.get('id', '').strip() == dataset_id.strip() for d in korea_datasets)
1018
 
1019
  if is_korea:
 
1020
  korea_rank = next((idx for idx, d in enumerate(korea_datasets, 1)
1021
  if d.get('id', '').strip() == dataset_id.strip()), None)
1022
 
 
1199
 
1200
  progress(1.0, desc="Complete!")
1201
 
1202
+
1203
  return fig, html_content, df
1204
+
1205
  except Exception as e:
1206
  print(f"Error in get_datasets_data: {str(e)}")
1207
  error_fig = create_error_plot()
 
1214
  empty_df = pd.DataFrame(columns=['Global Rank', 'Dataset ID', 'Title', 'Downloads', 'Likes', 'Korea Search', 'URL'])
1215
  return error_fig, error_html, empty_df
1216
 
1217
+
1218
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
1219
  gr.Markdown("""
1220
  # πŸ€— ν—ˆκΉ…νŽ˜μ΄μŠ€ 'ν•œκ΅­(μ–Έμ–΄) λ¦¬λ”λ³΄λ“œ'
 
1263
  datasets_results = get_datasets_data()
1264
 
1265
  trending_plot.value, trending_info.value, trending_df.value = spaces_results
1266
+ models_plot.value, models_info.value, models_df.value = models_results
1267
+ datasets_plot.value, datasets_info.value, datasets_df.value = datasets_results
 
1268
 
1269
  # Gradio μ•± μ‹€ν–‰
1270
  demo.launch(
1271
  server_name="0.0.0.0",
1272
  server_port=7860,
1273
  share=False
1274
+ )