Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -989,49 +989,365 @@ def refresh_data():
|
|
989 |
else:
|
990 |
return create_error_plot(), "<div>API ์ธ์ฆ์ด ํ์ํฉ๋๋ค.</div>", pd.DataFrame()
|
991 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
992 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
993 |
gr.Markdown("""
|
994 |
# ๐ค ํ๊น
ํ์ด์ค 'ํ๊ตญ(์ธ์ด) ๋ฆฌ๋๋ณด๋'
|
995 |
-
HuggingFace๊ฐ ์ ๊ณตํ๋ Spaces
|
996 |
""")
|
997 |
|
998 |
-
# ์๋ก ๊ณ ์นจ ๋ฒํผ์ ์๋จ์ผ๋ก ์ด๋ํ๊ณ ํ๊ธ๋ก ๋ณ๊ฒฝ
|
999 |
refresh_btn = gr.Button("๐ ์๋ก ๊ณ ์นจ", variant="primary")
|
1000 |
|
1001 |
with gr.Tab("Spaces Trending"):
|
1002 |
trending_plot = gr.Plot()
|
1003 |
trending_info = gr.HTML()
|
1004 |
trending_df = gr.DataFrame()
|
1005 |
-
|
1006 |
with gr.Tab("Models Trending"):
|
1007 |
models_plot = gr.Plot()
|
1008 |
models_info = gr.HTML()
|
1009 |
models_df = gr.DataFrame()
|
|
|
|
|
|
|
|
|
|
|
1010 |
|
1011 |
def refresh_all_data():
|
1012 |
spaces_results = get_spaces_data("trending")
|
1013 |
models_results = get_models_data()
|
1014 |
-
|
|
|
|
|
|
|
|
|
|
|
1015 |
|
1016 |
refresh_btn.click(
|
1017 |
refresh_all_data,
|
1018 |
outputs=[
|
1019 |
trending_plot, trending_info, trending_df,
|
1020 |
-
models_plot, models_info, models_df
|
|
|
1021 |
]
|
1022 |
)
|
1023 |
-
|
1024 |
-
# ์ด๊ธฐ ๋ฐ์ดํฐ ๋ก๋
|
1025 |
-
spaces_results = get_spaces_data("trending")
|
1026 |
-
models_results = get_models_data()
|
1027 |
-
|
1028 |
-
trending_plot.value, trending_info.value, trending_df.value = spaces_results
|
1029 |
-
models_plot.value, models_info.value, models_df.value = models_results
|
1030 |
-
|
1031 |
-
|
1032 |
# Gradio ์ฑ ์คํ
|
1033 |
demo.launch(
|
1034 |
server_name="0.0.0.0",
|
1035 |
server_port=7860,
|
1036 |
share=False
|
1037 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
989 |
else:
|
990 |
return create_error_plot(), "<div>API ์ธ์ฆ์ด ํ์ํฉ๋๋ค.</div>", pd.DataFrame()
|
991 |
|
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",
|
1079 |
+
"nlpai-lab/kowiki": "https://huggingface.co/datasets/nlpai-lab/kowiki",
|
1080 |
+
"KETI-AIR/korpora": "https://huggingface.co/datasets/KETI-AIR/korpora",
|
1081 |
+
"heegyu/korean-parallel-corpora": "https://huggingface.co/datasets/heegyu/korean-parallel-corpora",
|
1082 |
+
"heegyu/korean-hate-speech": "https://huggingface.co/datasets/heegyu/korean-hate-speech",
|
1083 |
+
"KETI-AIR/korean-parallel-corpora": "https://huggingface.co/datasets/KETI-AIR/korean-parallel-corpora",
|
1084 |
+
"heegyu/korean-chatbot-data": "https://huggingface.co/datasets/heegyu/korean-chatbot-data",
|
1085 |
+
"heegyu/korean-qa": "https://huggingface.co/datasets/heegyu/korean-qa",
|
1086 |
+
"heegyu/korean-summarization": "https://huggingface.co/datasets/heegyu/korean-summarization",
|
1087 |
+
"nlpai-lab/kullm-chat-v2": "https://huggingface.co/datasets/nlpai-lab/kullm-chat-v2",
|
1088 |
+
"upstage/open-ko-llm-leaderboard": "https://huggingface.co/datasets/upstage/open-ko-llm-leaderboard"
|
1089 |
+
}
|
1090 |
+
|
1091 |
+
def get_datasets_data(progress=gr.Progress()):
|
1092 |
+
"""๋ฐ์ดํฐ์
๋ฐ์ดํฐ ๊ฐ์ ธ์ค๊ธฐ"""
|
1093 |
+
def calculate_rank(dataset_id, all_global_datasets, korea_datasets):
|
1094 |
+
# ๊ธ๋ก๋ฒ ์์ ํ์ธ
|
1095 |
+
global_rank = next((idx for idx, d in enumerate(all_global_datasets, 1)
|
1096 |
+
if d.get('id', '').strip() == dataset_id.strip()), None)
|
1097 |
+
|
1098 |
+
# Korea ๋ฐ์ดํฐ์
์ธ ๊ฒฝ์ฐ
|
1099 |
+
is_korea = any(d.get('id', '').strip() == dataset_id.strip() for d in korea_datasets)
|
1100 |
+
|
1101 |
+
if is_korea:
|
1102 |
+
# Korea ๋ฐ์ดํฐ์
์ค์์์ ์์ ํ์ธ
|
1103 |
+
korea_rank = next((idx for idx, d in enumerate(korea_datasets, 1)
|
1104 |
+
if d.get('id', '').strip() == dataset_id.strip()), None)
|
1105 |
+
|
1106 |
+
if korea_rank:
|
1107 |
+
return min(global_rank or 3001, korea_rank + 1000), True
|
1108 |
+
|
1109 |
+
return global_rank if global_rank else 'Not in top 3000', is_korea
|
1110 |
+
|
1111 |
+
try:
|
1112 |
+
progress(0, desc="Fetching datasets...")
|
1113 |
+
|
1114 |
+
if not HF_TOKEN:
|
1115 |
+
fig = create_error_plot()
|
1116 |
+
error_html = """
|
1117 |
+
<div style='padding: 20px; background: #fee; border-radius: 10px; margin: 10px 0;'>
|
1118 |
+
<h3 style='color: #c00;'>โ ๏ธ API ์ธ์ฆ์ด ํ์ํฉ๋๋ค</h3>
|
1119 |
+
<p>HuggingFace API ํ ํฐ์ด ์ค์ ๋์ง ์์์ต๋๋ค.</p>
|
1120 |
+
</div>
|
1121 |
+
"""
|
1122 |
+
empty_df = pd.DataFrame(columns=['Global Rank', 'Dataset ID', 'Title', 'Downloads', 'Likes', 'Korea Search', 'URL'])
|
1123 |
+
return fig, error_html, empty_df
|
1124 |
+
|
1125 |
+
# ์ผ๋ฐ ๋ฐ์ดํฐ์
๊ณผ Korea ๊ด๋ จ ๋ฐ์ดํฐ์
๊ฐ์ ธ์ค๊ธฐ
|
1126 |
+
params = {
|
1127 |
+
'limit': 3000,
|
1128 |
+
'full': 'true'
|
1129 |
+
}
|
1130 |
+
|
1131 |
+
all_datasets_response = requests.get(
|
1132 |
+
"https://huggingface.co/api/datasets",
|
1133 |
+
headers={'Authorization': f'Bearer {HF_TOKEN}'},
|
1134 |
+
params=params
|
1135 |
+
)
|
1136 |
+
|
1137 |
+
korea_params = {
|
1138 |
+
'search': 'korea',
|
1139 |
+
'limit': 3000,
|
1140 |
+
'full': 'true'
|
1141 |
+
}
|
1142 |
+
|
1143 |
+
korea_datasets_response = requests.get(
|
1144 |
+
"https://huggingface.co/api/datasets",
|
1145 |
+
headers={'Authorization': f'Bearer {HF_TOKEN}'},
|
1146 |
+
params=korea_params
|
1147 |
+
)
|
1148 |
+
|
1149 |
+
all_global_datasets = all_datasets_response.json()
|
1150 |
+
korea_datasets = korea_datasets_response.json()
|
1151 |
+
|
1152 |
+
# ์๊ฐํ๋ฅผ ์ํ Figure ์์ฑ
|
1153 |
+
fig = go.Figure()
|
1154 |
+
|
1155 |
+
# ์์ ์ ๋ณด ์์ง
|
1156 |
+
filtered_datasets = []
|
1157 |
+
for dataset_id in target_datasets.keys():
|
1158 |
+
try:
|
1159 |
+
normalized_id = dataset_id.strip('/')
|
1160 |
+
dataset_url_api = f"https://huggingface.co/api/datasets/{normalized_id}"
|
1161 |
+
response = requests.get(
|
1162 |
+
dataset_url_api,
|
1163 |
+
headers={'Authorization': f'Bearer {HF_TOKEN}'}
|
1164 |
+
)
|
1165 |
+
|
1166 |
+
if response.status_code == 200:
|
1167 |
+
dataset_data = response.json()
|
1168 |
+
rank, is_korea = calculate_rank(dataset_id, all_global_datasets, korea_datasets)
|
1169 |
+
|
1170 |
+
filtered_datasets.append({
|
1171 |
+
'id': dataset_id,
|
1172 |
+
'global_rank': rank,
|
1173 |
+
'downloads': dataset_data.get('downloads', 0),
|
1174 |
+
'likes': dataset_data.get('likes', 0),
|
1175 |
+
'title': dataset_data.get('title', 'No Title'),
|
1176 |
+
'is_korea': is_korea
|
1177 |
+
})
|
1178 |
+
|
1179 |
+
print(f"Dataset {dataset_id}: Rank={rank}, Is Korea={is_korea}")
|
1180 |
+
else:
|
1181 |
+
filtered_datasets.append({
|
1182 |
+
'id': dataset_id,
|
1183 |
+
'global_rank': 'Not in top 3000',
|
1184 |
+
'downloads': 0,
|
1185 |
+
'likes': 0,
|
1186 |
+
'title': 'No Title',
|
1187 |
+
'is_korea': False
|
1188 |
+
})
|
1189 |
+
except Exception as e:
|
1190 |
+
print(f"Error processing {dataset_id}: {str(e)}")
|
1191 |
+
continue
|
1192 |
+
|
1193 |
+
# ์์๋ก ์ ๋ ฌ
|
1194 |
+
filtered_datasets.sort(key=lambda x: float('inf') if isinstance(x['global_rank'], str) else x['global_rank'])
|
1195 |
+
|
1196 |
+
# ์๊ฐํ ๋ฐ์ดํฐ ์ค๋น
|
1197 |
+
valid_datasets = [d for d in filtered_datasets if isinstance(d['global_rank'], (int, float))]
|
1198 |
+
|
1199 |
+
if valid_datasets:
|
1200 |
+
ids = [d['id'] for d in valid_datasets]
|
1201 |
+
ranks = [d['global_rank'] for d in valid_datasets]
|
1202 |
+
|
1203 |
+
fig.add_trace(go.Bar(
|
1204 |
+
x=ids,
|
1205 |
+
y=[3001 - r for r in ranks],
|
1206 |
+
text=[f"Rank: #{r}<br>Downloads: {format(d['downloads'], ',')}<br>Likes: {format(d['likes'], ',')}"
|
1207 |
+
for r, d in zip(ranks, valid_datasets)],
|
1208 |
+
textposition='auto',
|
1209 |
+
marker_color=['rgba(255,0,0,0.6)' if d['is_korea'] else 'rgba(0,0,255,0.6)'
|
1210 |
+
for d in valid_datasets],
|
1211 |
+
opacity=0.8
|
1212 |
+
))
|
1213 |
+
|
1214 |
+
fig.update_layout(
|
1215 |
+
title="HuggingFace Datasets Global Rankings (Up to #3000)",
|
1216 |
+
xaxis_title="Dataset ID",
|
1217 |
+
yaxis_title="Global Rank",
|
1218 |
+
yaxis=dict(
|
1219 |
+
ticktext=[f"#{i}" for i in range(1, 3001, 100)],
|
1220 |
+
tickvals=[3001 - i for i in range(1, 3001, 100)],
|
1221 |
+
range=[0, 3000]
|
1222 |
+
),
|
1223 |
+
height=800,
|
1224 |
+
showlegend=False,
|
1225 |
+
template='plotly_white',
|
1226 |
+
xaxis_tickangle=-45
|
1227 |
+
)
|
1228 |
+
|
1229 |
+
# HTML ์นด๋ ์์ฑ
|
1230 |
+
html_content = """
|
1231 |
+
<div style='padding: 20px; background: #f5f5f5;'>
|
1232 |
+
<h2 style='color: #2c3e50;'>Datasets Rankings (Up to #3000)</h2>
|
1233 |
+
<div style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;'>
|
1234 |
+
"""
|
1235 |
+
|
1236 |
+
for dataset in filtered_datasets:
|
1237 |
+
rank_display = f"Global Rank #{dataset['global_rank']}" if isinstance(dataset['global_rank'], (int, float)) else "Not in top 3000"
|
1238 |
+
korea_badge = "๐ฐ๐ท Korea Search Result" if dataset['is_korea'] else ""
|
1239 |
+
|
1240 |
+
html_content += f"""
|
1241 |
+
<div style='
|
1242 |
+
background: white;
|
1243 |
+
padding: 20px;
|
1244 |
+
border-radius: 10px;
|
1245 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
1246 |
+
transition: transform 0.2s;
|
1247 |
+
{f"border: 2px solid #e74c3c;" if dataset['is_korea'] else ""}
|
1248 |
+
'>
|
1249 |
+
<h3 style='color: #34495e;'>{rank_display}</h3>
|
1250 |
+
<h4 style='color: #2c3e50;'>{dataset['id']}</h4>
|
1251 |
+
<p style='color: #e74c3c; font-weight: bold;'>{korea_badge}</p>
|
1252 |
+
<p style='color: #7f8c8d;'>โฌ๏ธ Downloads: {format(dataset['downloads'], ',')}</p>
|
1253 |
+
<p style='color: #7f8c8d;'>๐ Likes: {format(dataset['likes'], ',')}</p>
|
1254 |
+
<a href='{target_datasets[dataset['id']]}'
|
1255 |
+
target='_blank'
|
1256 |
+
style='
|
1257 |
+
display: inline-block;
|
1258 |
+
padding: 8px 16px;
|
1259 |
+
background: #3498db;
|
1260 |
+
color: white;
|
1261 |
+
text-decoration: none;
|
1262 |
+
border-radius: 5px;
|
1263 |
+
transition: background 0.3s;
|
1264 |
+
'>
|
1265 |
+
Visit Dataset ๐
|
1266 |
+
</a>
|
1267 |
+
</div>
|
1268 |
+
"""
|
1269 |
+
|
1270 |
+
html_content += "</div></div>"
|
1271 |
+
|
1272 |
+
# ๋ฐ์ดํฐํ๋ ์ ์์ฑ
|
1273 |
+
df = pd.DataFrame([{
|
1274 |
+
'Global Rank': f"#{d['global_rank']}" if isinstance(d['global_rank'], (int, float)) else d['global_rank'],
|
1275 |
+
'Dataset ID': d['id'],
|
1276 |
+
'Title': d['title'],
|
1277 |
+
'Downloads': format(d['downloads'], ','),
|
1278 |
+
'Likes': format(d['likes'], ','),
|
1279 |
+
'Korea Search': '๐ฐ๐ท' if d['is_korea'] else '',
|
1280 |
+
'URL': target_datasets[d['id']]
|
1281 |
+
} for d in filtered_datasets])
|
1282 |
+
|
1283 |
+
progress(1.0, desc="Complete!")
|
1284 |
+
return fig, html_content, df
|
1285 |
+
|
1286 |
+
except Exception as e:
|
1287 |
+
print(f"Error in get_datasets_data: {str(e)}")
|
1288 |
+
error_fig = create_error_plot()
|
1289 |
+
error_html = f"""
|
1290 |
+
<div style='padding: 20px; background: #fee; border-radius: 10px; margin: 10px 0;'>
|
1291 |
+
<h3 style='color: #c00;'>โ ๏ธ ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค</h3>
|
1292 |
+
<p>{str(e)}</p>
|
1293 |
+
</div>
|
1294 |
+
"""
|
1295 |
+
empty_df = pd.DataFrame(columns=['Global Rank', 'Dataset ID', 'Title', 'Downloads', 'Likes', 'Korea Search', 'URL'])
|
1296 |
+
return error_fig, error_html, empty_df
|
1297 |
+
|
1298 |
+
|
1299 |
+
# Gradio UI ์์
|
1300 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
1301 |
gr.Markdown("""
|
1302 |
# ๐ค ํ๊น
ํ์ด์ค 'ํ๊ตญ(์ธ์ด) ๋ฆฌ๋๋ณด๋'
|
1303 |
+
HuggingFace๊ฐ ์ ๊ณตํ๋ Spaces, Models, Datasets์ ์ค์๊ฐ ์ธ๊ธฐ ์์๋ฅผ ๋ฐ์ํ์ฌ 'ํ๊ตญ์(๊ธฐ์
/์ธ์ด)'์ ๋ฆฌ์คํธ(๊ณต๊ฐ,๊ฒ์,๋ฆฌ๋๋ณด๋ ๋ฑ)๋ง ๋ถ์. (c)'ํ๊ตญ์ธ๊ณต์ง๋ฅ์งํฅํํ' / ์์ฒญ: [email protected]
|
1304 |
""")
|
1305 |
|
|
|
1306 |
refresh_btn = gr.Button("๐ ์๋ก ๊ณ ์นจ", variant="primary")
|
1307 |
|
1308 |
with gr.Tab("Spaces Trending"):
|
1309 |
trending_plot = gr.Plot()
|
1310 |
trending_info = gr.HTML()
|
1311 |
trending_df = gr.DataFrame()
|
1312 |
+
|
1313 |
with gr.Tab("Models Trending"):
|
1314 |
models_plot = gr.Plot()
|
1315 |
models_info = gr.HTML()
|
1316 |
models_df = gr.DataFrame()
|
1317 |
+
|
1318 |
+
with gr.Tab("Datasets Trending"):
|
1319 |
+
datasets_plot = gr.Plot()
|
1320 |
+
datasets_info = gr.HTML()
|
1321 |
+
datasets_df = gr.DataFrame()
|
1322 |
|
1323 |
def refresh_all_data():
|
1324 |
spaces_results = get_spaces_data("trending")
|
1325 |
models_results = get_models_data()
|
1326 |
+
datasets_results = get_datasets_data()
|
1327 |
+
return [
|
1328 |
+
*spaces_results,
|
1329 |
+
*models_results,
|
1330 |
+
*datasets_results
|
1331 |
+
]
|
1332 |
|
1333 |
refresh_btn.click(
|
1334 |
refresh_all_data,
|
1335 |
outputs=[
|
1336 |
trending_plot, trending_info, trending_df,
|
1337 |
+
models_plot, models_info, models_df,
|
1338 |
+
datasets_plot, datasets_info, datasets_df
|
1339 |
]
|
1340 |
)
|
1341 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1342 |
# Gradio ์ฑ ์คํ
|
1343 |
demo.launch(
|
1344 |
server_name="0.0.0.0",
|
1345 |
server_port=7860,
|
1346 |
share=False
|
1347 |
+
)
|
1348 |
+
|
1349 |
+
|
1350 |
+
|
1351 |
+
|
1352 |
+
|
1353 |
+
|