Spaces:
Running
Running
Update app-backup2.py
Browse files- app-backup2.py +97 -68
app-backup2.py
CHANGED
|
@@ -595,6 +595,56 @@ def get_models_data(progress=gr.Progress()):
|
|
| 595 |
# ๊ด์ฌ ์คํ์ด์ค URL ๋ฆฌ์คํธ์ ์ ๋ณด
|
| 596 |
target_spaces = {
|
| 597 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 598 |
"immunobiotech/MUSIC-Jukebox": "https://huggingface.co/spaces/immunobiotech/MUSIC-Jukebox",
|
| 599 |
"seawolf2357/Flowise-AI": "https://huggingface.co/spaces/seawolf2357/Flowise-AI",
|
| 600 |
"kolaslab/Binaural-Beat-Generator": "https://huggingface.co/spaces/kolaslab/Binaural-Beat-Generator",
|
|
@@ -807,10 +857,6 @@ target_spaces = {
|
|
| 807 |
|
| 808 |
def get_spaces_data(sort_type="trending", progress=gr.Progress()):
|
| 809 |
"""์คํ์ด์ค ๋ฐ์ดํฐ ๊ฐ์ ธ์ค๊ธฐ (trending ๋๋ modes)"""
|
| 810 |
-
|
| 811 |
-
# target_spaces ๋์
๋๋ฆฌ์ ๋ชจ๋ ํค๋ฅผ ์๋ฌธ์๋ก ์ ๊ทํ
|
| 812 |
-
normalized_target_spaces = { key.lower(): url for key, url in target_spaces.items() }
|
| 813 |
-
|
| 814 |
url = "https://huggingface.co/api/spaces"
|
| 815 |
params = {
|
| 816 |
'full': 'true',
|
|
@@ -826,17 +872,15 @@ def get_spaces_data(sort_type="trending", progress=gr.Progress()):
|
|
| 826 |
response.raise_for_status()
|
| 827 |
all_spaces = response.json()
|
| 828 |
|
| 829 |
-
# ์์ ์ ๋ณด ์ ์ฅ
|
| 830 |
space_ranks = {}
|
| 831 |
for idx, space in enumerate(all_spaces, 1):
|
| 832 |
space_id = space.get('id', '')
|
| 833 |
-
|
| 834 |
-
if normalized_id in normalized_target_spaces:
|
| 835 |
space['rank'] = idx
|
| 836 |
-
space_ranks[
|
| 837 |
|
| 838 |
-
|
| 839 |
-
spaces = list(space_ranks.values())
|
| 840 |
spaces.sort(key=lambda x: x['rank'])
|
| 841 |
|
| 842 |
progress(0.3, desc="Creating visualization...")
|
|
@@ -845,8 +889,8 @@ def get_spaces_data(sort_type="trending", progress=gr.Progress()):
|
|
| 845 |
fig = go.Figure()
|
| 846 |
|
| 847 |
# ๋ฐ์ดํฐ ์ค๋น
|
| 848 |
-
ids = [space
|
| 849 |
-
ranks = [space
|
| 850 |
likes = [space.get('likes', 0) for space in spaces]
|
| 851 |
titles = [space.get('cardData', {}).get('title') or space.get('title', 'No Title') for space in spaces]
|
| 852 |
|
|
@@ -864,8 +908,8 @@ def get_spaces_data(sort_type="trending", progress=gr.Progress()):
|
|
| 864 |
fig.update_layout(
|
| 865 |
title={
|
| 866 |
'text': f'Hugging Face Spaces {sort_type.title()} Rankings (Top 500)',
|
| 867 |
-
'y':
|
| 868 |
-
'x':
|
| 869 |
'xanchor': 'center',
|
| 870 |
'yanchor': 'top'
|
| 871 |
},
|
|
@@ -874,9 +918,9 @@ def get_spaces_data(sort_type="trending", progress=gr.Progress()):
|
|
| 874 |
yaxis=dict(
|
| 875 |
autorange='reversed', # Y์ถ์ ๋ฐ์
|
| 876 |
tickmode='array',
|
| 877 |
-
ticktext=[str(i) for i in range(1, 501, 20)],
|
| 878 |
tickvals=[i for i in range(1, 501, 20)],
|
| 879 |
-
range=[1, 500]
|
| 880 |
),
|
| 881 |
height=800,
|
| 882 |
showlegend=False,
|
|
@@ -886,7 +930,7 @@ def get_spaces_data(sort_type="trending", progress=gr.Progress()):
|
|
| 886 |
|
| 887 |
progress(0.6, desc="Creating space cards...")
|
| 888 |
|
| 889 |
-
# HTML ์นด๋ ์์ฑ
|
| 890 |
html_content = f"""
|
| 891 |
<div style='padding: 20px; background: #f5f5f5;'>
|
| 892 |
<h2 style='color: #2c3e50;'>{sort_type.title()} Rankings</h2>
|
|
@@ -894,13 +938,11 @@ def get_spaces_data(sort_type="trending", progress=gr.Progress()):
|
|
| 894 |
"""
|
| 895 |
|
| 896 |
for space in spaces:
|
| 897 |
-
space_id = space
|
| 898 |
-
|
| 899 |
-
rank = space.get('rank')
|
| 900 |
title = space.get('cardData', {}).get('title') or space.get('title', 'No Title')
|
| 901 |
-
|
| 902 |
-
|
| 903 |
-
|
| 904 |
html_content += f"""
|
| 905 |
<div style='
|
| 906 |
background: white;
|
|
@@ -921,8 +963,8 @@ def get_spaces_data(sort_type="trending", progress=gr.Progress()):
|
|
| 921 |
-webkit-text-fill-color: transparent;
|
| 922 |
padding: 5px 0;
|
| 923 |
'>{title}</h4>
|
| 924 |
-
<p style='color: #7f8c8d; margin-bottom: 10px;'>๐ Likes: {
|
| 925 |
-
<a href='{
|
| 926 |
target='_blank'
|
| 927 |
style='
|
| 928 |
display: inline-block;
|
|
@@ -940,13 +982,13 @@ def get_spaces_data(sort_type="trending", progress=gr.Progress()):
|
|
| 940 |
|
| 941 |
html_content += "</div></div>"
|
| 942 |
|
| 943 |
-
# ๋ฐ์ดํฐํ๋ ์ ์์ฑ
|
| 944 |
df = pd.DataFrame([{
|
| 945 |
-
'Rank': space
|
| 946 |
-
'Space ID': space
|
| 947 |
'Title': space.get('cardData', {}).get('title') or space.get('title', 'No Title'),
|
| 948 |
'Likes': space.get('likes', 0),
|
| 949 |
-
'URL':
|
| 950 |
} for space in spaces])
|
| 951 |
|
| 952 |
progress(1.0, desc="Complete!")
|
|
@@ -1166,50 +1208,40 @@ def refresh_data():
|
|
| 1166 |
return create_error_plot(), "<div>API ์ธ์ฆ์ด ํ์ํฉ๋๋ค.</div>", pd.DataFrame()
|
| 1167 |
|
| 1168 |
|
|
|
|
| 1169 |
def create_registration_bar_chart(data, type_name="Spaces"):
|
| 1170 |
try:
|
| 1171 |
-
# TOP
|
| 1172 |
top_limit = 500 if type_name == "Spaces" else 3000
|
| 1173 |
-
|
|
|
|
| 1174 |
if isinstance(data, pd.DataFrame):
|
| 1175 |
-
if type_name == "
|
| 1176 |
-
#
|
| 1177 |
-
|
| 1178 |
-
|
| 1179 |
-
|
| 1180 |
-
|
| 1181 |
-
|
| 1182 |
-
|
| 1183 |
-
|
| 1184 |
-
|
| 1185 |
-
|
| 1186 |
-
lambda x: int(str(x).replace('#', '').strip()) if isinstance(x, str) and x.startswith('#') else int(x)
|
| 1187 |
-
)
|
| 1188 |
-
data = data[data["Global Rank"] <= top_limit]
|
| 1189 |
-
id_column = "Model ID"
|
| 1190 |
-
|
| 1191 |
-
# ๊ณ์ ๋ช
์ถ์ถ: 'creator/spaceName' ํ์์์ ์๋ถ๋ถ(creator)์ ์๋ฌธ์์ ์์ชฝ ๊ณต๋ฐฑ ์ ๊ฑฐ ํ ์ฌ์ฉ
|
| 1192 |
-
registrations = data[id_column].apply(lambda x: x.split('/')[0].strip().lower()).value_counts()
|
| 1193 |
else:
|
| 1194 |
-
#
|
| 1195 |
registrations = {}
|
| 1196 |
for item in data:
|
| 1197 |
-
|
| 1198 |
-
|
| 1199 |
-
|
| 1200 |
-
try:
|
| 1201 |
-
rank = int(rank.replace('#', '').strip())
|
| 1202 |
-
except Exception:
|
| 1203 |
continue
|
| 1204 |
-
|
| 1205 |
-
|
| 1206 |
-
creator = item.get("id", "")
|
| 1207 |
-
creator = creator.split('/')[0].strip().lower() if '/' in creator else creator.strip().lower()
|
| 1208 |
-
registrations[creator] = registrations.get(creator, 0) + 1
|
| 1209 |
registrations = pd.Series(registrations)
|
| 1210 |
-
|
|
|
|
| 1211 |
registrations = registrations.sort_values(ascending=False)
|
| 1212 |
-
|
| 1213 |
fig = go.Figure(data=[go.Bar(
|
| 1214 |
x=registrations.index,
|
| 1215 |
y=registrations.values,
|
|
@@ -1217,7 +1249,7 @@ def create_registration_bar_chart(data, type_name="Spaces"):
|
|
| 1217 |
textposition='auto',
|
| 1218 |
marker_color='#FF6B6B'
|
| 1219 |
)])
|
| 1220 |
-
|
| 1221 |
fig.update_layout(
|
| 1222 |
title=f"Korean {type_name} Registrations by Creator (Top {top_limit})",
|
| 1223 |
xaxis_title="Creator ID",
|
|
@@ -1226,15 +1258,12 @@ def create_registration_bar_chart(data, type_name="Spaces"):
|
|
| 1226 |
height=400,
|
| 1227 |
width=700
|
| 1228 |
)
|
| 1229 |
-
|
| 1230 |
return fig
|
| 1231 |
-
|
| 1232 |
except Exception as e:
|
| 1233 |
print(f"Error in create_registration_bar_chart: {str(e)}")
|
| 1234 |
return go.Figure()
|
| 1235 |
|
| 1236 |
-
|
| 1237 |
-
|
| 1238 |
def create_pie_chart(data, total_count, type_name="Spaces"):
|
| 1239 |
try:
|
| 1240 |
# TOP ๊ธฐ์ค ์ค์
|
|
|
|
| 595 |
# ๊ด์ฌ ์คํ์ด์ค URL ๋ฆฌ์คํธ์ ์ ๋ณด
|
| 596 |
target_spaces = {
|
| 597 |
|
| 598 |
+
"openfree/deepseek_r1_API": "https://huggingface.co/spaces/openfree/deepseek_r1_API",
|
| 599 |
+
"ginipick/Tech_Hangman_Game": "https://huggingface.co/spaces/ginipick/Tech_Hangman_Game",
|
| 600 |
+
"openfree/Mouse2-HF": "https://huggingface.co/spaces/openfree/Mouse2-HF",
|
| 601 |
+
"seawolf2357/DeepSeek-R1-32b-search": "https://huggingface.co/spaces/seawolf2357/DeepSeek-R1-32b-search",
|
| 602 |
+
"aiqmaster/open-deep-research": "https://huggingface.co/spaces/aiqmaster/open-deep-research",
|
| 603 |
+
"ginipick/open_Deep-Research": "https://huggingface.co/spaces/ginipick/open_Deep-Research",
|
| 604 |
+
"ginigen/LLaDA": "https://huggingface.co/spaces/ginigen/LLaDA",
|
| 605 |
+
"VIDraft/PHI4-Multimodal": "https://huggingface.co/spaces/VIDraft/PHI4-Multimodal",
|
| 606 |
+
|
| 607 |
+
"ginipick/spaces-research-think": "https://huggingface.co/spaces/ginipick/spaces-research-think",
|
| 608 |
+
"ginipick/spaces-research-korea": "https://huggingface.co/spaces/ginipick/spaces-research-korea",
|
| 609 |
+
"openfree/Datasets-Convertor": "https://huggingface.co/spaces/openfree/Datasets-Convertor",
|
| 610 |
+
"VIDraft/mouse-Visual-Chat": "https://huggingface.co/spaces/VIDraft/mouse-Visual-Chat",
|
| 611 |
+
"VIDraft/mouse-file-chat": "https://huggingface.co/spaces/VIDraft/mouse-file-chat",
|
| 612 |
+
"ginigen/Ovis2-8B": "https://huggingface.co/spaces/ginigen/Ovis2-8B",
|
| 613 |
+
"openfree/Parquet-CSV-Convertor": "https://huggingface.co/spaces/openfree/Parquet-CSV-Convertor",
|
| 614 |
+
"ginigen/FLUX-Eternity": "https://huggingface.co/spaces/ginigen/FLUX-Eternity",
|
| 615 |
+
"ginipick/live-detect-pose": "https://huggingface.co/spaces/ginipick/live-detect-pose",
|
| 616 |
+
"ginigen/OmniParser-v2-pro": "https://huggingface.co/spaces/ginigen/OmniParser-v2-pro",
|
| 617 |
+
"ginigen/panorama-images": "https://huggingface.co/spaces/ginigen/panorama-images",
|
| 618 |
+
"ginigen/Celebrity": "https://huggingface.co/spaces/ginigen/Celebrity",
|
| 619 |
+
"ginigen/Fashion-Pose-Control": "https://huggingface.co/spaces/ginigen/Fashion-Pose-Control",
|
| 620 |
+
"ginigen/zonos-longform": "https://huggingface.co/spaces/ginigen/zonos-longform",
|
| 621 |
+
"ginigen/Workflow-Canvas": "https://huggingface.co/spaces/ginigen/Workflow-Canvas",
|
| 622 |
+
"ginigen/Design": "https://huggingface.co/spaces/ginigen/Design",
|
| 623 |
+
"ginigen/Diagram": "https://huggingface.co/spaces/ginigen/Diagram",
|
| 624 |
+
"ginigen/Mockup": "https://huggingface.co/spaces/ginigen/Mockup",
|
| 625 |
+
"ginigen/Infographic": "https://huggingface.co/spaces/ginigen/Infographic",
|
| 626 |
+
"ginigen/Flowchart": "https://huggingface.co/spaces/ginigen/Flowchart",
|
| 627 |
+
"aiqcamp/FLUX-Vision": "https://huggingface.co/spaces/aiqcamp/FLUX-Vision",
|
| 628 |
+
"ginigen/VoiceClone-TTS": "https://huggingface.co/spaces/ginigen/VoiceClone-TTS",
|
| 629 |
+
"openfree/Perceptron-Network": "https://huggingface.co/spaces/openfree/Perceptron-Network",
|
| 630 |
+
"openfree/Article-Generator": "https://huggingface.co/spaces/openfree/Article-Generator",
|
| 631 |
+
"openfree/Math-Game": "https://huggingface.co/spaces/openfree/Math-Game",
|
| 632 |
+
"openfree/PDF-TTS": "https://huggingface.co/spaces/openfree/PDF-TTS",
|
| 633 |
+
"openfree/chess": "https://huggingface.co/spaces/openfree/chess",
|
| 634 |
+
"fantos/Panorama": "https://huggingface.co/spaces/fantos/Panorama",
|
| 635 |
+
"ginigen/Multi-LoRAgen": "https://huggingface.co/spaces/ginigen/Multi-LoRAgen",
|
| 636 |
+
"ginigen/canvas-studio": "https://huggingface.co/spaces/ginigen/canvas-studio",
|
| 637 |
+
"ginipick/Fashion-Stylegen": "https://huggingface.co/spaces/ginipick/Fashion-Style",
|
| 638 |
+
"ginipick/Time-Stream": "https://huggingface.co/spaces/ginipick/Time-Stream",
|
| 639 |
+
"ginipick/AccuVision-Diffusion": "https://huggingface.co/spaces/ginipick/AccuVision-Diffusion",
|
| 640 |
+
"fantos/Magic-Drawings": "https://huggingface.co/spaces/fantos/Magic-Drawings",
|
| 641 |
+
"ginigen/Lumina-Image-PLUS": "https://huggingface.co/spaces/ginigen/Lumina-Image-PLUS",
|
| 642 |
+
"fantaxy/fantasy-novel": "https://huggingface.co/spaces/fantaxy/fantasy-novel",
|
| 643 |
+
"fantaxy/eros": "https://huggingface.co/spaces/fantaxy/eros",
|
| 644 |
+
"fantaxy/adult-novel": "https://huggingface.co/spaces/fantaxy/adult-novel",
|
| 645 |
+
"fantaxy/kungfu-novel": "https://huggingface.co/spaces/fantaxy/kungfu-novel",
|
| 646 |
+
"fantaxy/love-novel": "https://huggingface.co/spaces/fantaxy/love-novel",
|
| 647 |
+
"VIDraft/mouse-webgen": "https://huggingface.co/spaces/VIDraft/mouse-webgen",
|
| 648 |
"immunobiotech/MUSIC-Jukebox": "https://huggingface.co/spaces/immunobiotech/MUSIC-Jukebox",
|
| 649 |
"seawolf2357/Flowise-AI": "https://huggingface.co/spaces/seawolf2357/Flowise-AI",
|
| 650 |
"kolaslab/Binaural-Beat-Generator": "https://huggingface.co/spaces/kolaslab/Binaural-Beat-Generator",
|
|
|
|
| 857 |
|
| 858 |
def get_spaces_data(sort_type="trending", progress=gr.Progress()):
|
| 859 |
"""์คํ์ด์ค ๋ฐ์ดํฐ ๊ฐ์ ธ์ค๊ธฐ (trending ๋๋ modes)"""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 860 |
url = "https://huggingface.co/api/spaces"
|
| 861 |
params = {
|
| 862 |
'full': 'true',
|
|
|
|
| 872 |
response.raise_for_status()
|
| 873 |
all_spaces = response.json()
|
| 874 |
|
| 875 |
+
# ์์ ์ ๋ณด ์ ์ฅ
|
| 876 |
space_ranks = {}
|
| 877 |
for idx, space in enumerate(all_spaces, 1):
|
| 878 |
space_id = space.get('id', '')
|
| 879 |
+
if space_id in target_spaces:
|
|
|
|
| 880 |
space['rank'] = idx
|
| 881 |
+
space_ranks[space_id] = space
|
| 882 |
|
| 883 |
+
spaces = [space_ranks[space_id] for space_id in space_ranks.keys()]
|
|
|
|
| 884 |
spaces.sort(key=lambda x: x['rank'])
|
| 885 |
|
| 886 |
progress(0.3, desc="Creating visualization...")
|
|
|
|
| 889 |
fig = go.Figure()
|
| 890 |
|
| 891 |
# ๋ฐ์ดํฐ ์ค๋น
|
| 892 |
+
ids = [space['id'] for space in spaces]
|
| 893 |
+
ranks = [space['rank'] for space in spaces]
|
| 894 |
likes = [space.get('likes', 0) for space in spaces]
|
| 895 |
titles = [space.get('cardData', {}).get('title') or space.get('title', 'No Title') for space in spaces]
|
| 896 |
|
|
|
|
| 908 |
fig.update_layout(
|
| 909 |
title={
|
| 910 |
'text': f'Hugging Face Spaces {sort_type.title()} Rankings (Top 500)',
|
| 911 |
+
'y':0.95,
|
| 912 |
+
'x':0.5,
|
| 913 |
'xanchor': 'center',
|
| 914 |
'yanchor': 'top'
|
| 915 |
},
|
|
|
|
| 918 |
yaxis=dict(
|
| 919 |
autorange='reversed', # Y์ถ์ ๋ฐ์
|
| 920 |
tickmode='array',
|
| 921 |
+
ticktext=[str(i) for i in range(1, 501, 20)], # 1๋ถํฐ 400๊น์ง 20 ๊ฐ๊ฒฉ์ผ๋ก ํ์
|
| 922 |
tickvals=[i for i in range(1, 501, 20)],
|
| 923 |
+
range=[1, 500] # Y์ถ ๋ฒ์๋ฅผ 1๋ถํฐ 400๊น์ง๋ก ์ค์
|
| 924 |
),
|
| 925 |
height=800,
|
| 926 |
showlegend=False,
|
|
|
|
| 930 |
|
| 931 |
progress(0.6, desc="Creating space cards...")
|
| 932 |
|
| 933 |
+
# HTML ์นด๋ ์์ฑ
|
| 934 |
html_content = f"""
|
| 935 |
<div style='padding: 20px; background: #f5f5f5;'>
|
| 936 |
<h2 style='color: #2c3e50;'>{sort_type.title()} Rankings</h2>
|
|
|
|
| 938 |
"""
|
| 939 |
|
| 940 |
for space in spaces:
|
| 941 |
+
space_id = space['id']
|
| 942 |
+
rank = space['rank']
|
|
|
|
| 943 |
title = space.get('cardData', {}).get('title') or space.get('title', 'No Title')
|
| 944 |
+
likes = space.get('likes', 0)
|
| 945 |
+
|
|
|
|
| 946 |
html_content += f"""
|
| 947 |
<div style='
|
| 948 |
background: white;
|
|
|
|
| 963 |
-webkit-text-fill-color: transparent;
|
| 964 |
padding: 5px 0;
|
| 965 |
'>{title}</h4>
|
| 966 |
+
<p style='color: #7f8c8d; margin-bottom: 10px;'>๐ Likes: {likes}</p>
|
| 967 |
+
<a href='{target_spaces[space_id]}'
|
| 968 |
target='_blank'
|
| 969 |
style='
|
| 970 |
display: inline-block;
|
|
|
|
| 982 |
|
| 983 |
html_content += "</div></div>"
|
| 984 |
|
| 985 |
+
# ๋ฐ์ดํฐํ๋ ์ ์์ฑ
|
| 986 |
df = pd.DataFrame([{
|
| 987 |
+
'Rank': space['rank'],
|
| 988 |
+
'Space ID': space['id'],
|
| 989 |
'Title': space.get('cardData', {}).get('title') or space.get('title', 'No Title'),
|
| 990 |
'Likes': space.get('likes', 0),
|
| 991 |
+
'URL': target_spaces[space['id']]
|
| 992 |
} for space in spaces])
|
| 993 |
|
| 994 |
progress(1.0, desc="Complete!")
|
|
|
|
| 1208 |
return create_error_plot(), "<div>API ์ธ์ฆ์ด ํ์ํฉ๋๋ค.</div>", pd.DataFrame()
|
| 1209 |
|
| 1210 |
|
| 1211 |
+
|
| 1212 |
def create_registration_bar_chart(data, type_name="Spaces"):
|
| 1213 |
try:
|
| 1214 |
+
# TOP ๊ธฐ์ค ์ค์
|
| 1215 |
top_limit = 500 if type_name == "Spaces" else 3000
|
| 1216 |
+
|
| 1217 |
+
# DataFrame์ธ ๊ฒฝ์ฐ ์ฒ๋ฆฌ
|
| 1218 |
if isinstance(data, pd.DataFrame):
|
| 1219 |
+
if type_name == "Models":
|
| 1220 |
+
# 3000์ ์ด๋ด์ ๋ชจ๋ธ๋ง ํํฐ๋ง
|
| 1221 |
+
data = data[data['Global Rank'].apply(lambda x: isinstance(x, (int, float)) or (isinstance(x, str) and x.startswith('#')))]
|
| 1222 |
+
data = data[data['Global Rank'].apply(lambda x: int(str(x).replace('#', '')) if isinstance(x, str) else x) <= top_limit]
|
| 1223 |
+
elif type_name == "Spaces":
|
| 1224 |
+
# 500์ ์ด๋ด์ ์คํ์ด์ค๋ง ํํฐ๋ง
|
| 1225 |
+
data = data[data['Rank'].apply(lambda x: isinstance(x, (int, float))) & (data['Rank'] <= top_limit)]
|
| 1226 |
+
|
| 1227 |
+
# ID ์ปฌ๋ผ ์ ํ
|
| 1228 |
+
id_column = 'Space ID' if type_name == "Spaces" else 'Model ID'
|
| 1229 |
+
registrations = data[id_column].apply(lambda x: x.split('/')[0]).value_counts()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1230 |
else:
|
| 1231 |
+
# ๋ฆฌ์คํธ๋ ๋ค๋ฅธ ํํ์ ๋ฐ์ดํฐ์ธ ๊ฒฝ์ฐ ์ฒ๋ฆฌ
|
| 1232 |
registrations = {}
|
| 1233 |
for item in data:
|
| 1234 |
+
if isinstance(item, dict):
|
| 1235 |
+
rank = item.get('global_rank' if type_name == "Models" else 'rank')
|
| 1236 |
+
if isinstance(rank, str) or rank > top_limit:
|
|
|
|
|
|
|
|
|
|
| 1237 |
continue
|
| 1238 |
+
creator = item.get('id', '').split('/')[0]
|
| 1239 |
+
registrations[creator] = registrations.get(creator, 0) + 1
|
|
|
|
|
|
|
|
|
|
| 1240 |
registrations = pd.Series(registrations)
|
| 1241 |
+
|
| 1242 |
+
# ์ ๋ ฌ๋ ๋ฐ์ดํฐ ์ค๋น
|
| 1243 |
registrations = registrations.sort_values(ascending=False)
|
| 1244 |
+
|
| 1245 |
fig = go.Figure(data=[go.Bar(
|
| 1246 |
x=registrations.index,
|
| 1247 |
y=registrations.values,
|
|
|
|
| 1249 |
textposition='auto',
|
| 1250 |
marker_color='#FF6B6B'
|
| 1251 |
)])
|
| 1252 |
+
|
| 1253 |
fig.update_layout(
|
| 1254 |
title=f"Korean {type_name} Registrations by Creator (Top {top_limit})",
|
| 1255 |
xaxis_title="Creator ID",
|
|
|
|
| 1258 |
height=400,
|
| 1259 |
width=700
|
| 1260 |
)
|
| 1261 |
+
|
| 1262 |
return fig
|
|
|
|
| 1263 |
except Exception as e:
|
| 1264 |
print(f"Error in create_registration_bar_chart: {str(e)}")
|
| 1265 |
return go.Figure()
|
| 1266 |
|
|
|
|
|
|
|
| 1267 |
def create_pie_chart(data, total_count, type_name="Spaces"):
|
| 1268 |
try:
|
| 1269 |
# TOP ๊ธฐ์ค ์ค์
|