Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -322,25 +322,9 @@ def get_korea_models():
|
|
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",
|
@@ -356,16 +340,14 @@ def get_all_models(limit=1000):
|
|
356 |
|
357 |
if korea_response.status_code == 200:
|
358 |
korea_models = korea_response.json()
|
359 |
-
print(f"
|
360 |
-
|
361 |
-
# ์ค๋ณต ์ ๊ฑฐํ๋ฉด์ Korea ๋ชจ๋ธ ์ถ๊ฐ
|
362 |
-
existing_ids = {model.get('id', '') for model in all_models}
|
363 |
for model in korea_models:
|
364 |
-
|
|
|
365 |
all_models.append(model)
|
366 |
-
existing_ids.add(
|
367 |
|
368 |
-
#
|
369 |
korean_params = {
|
370 |
"search": "korean",
|
371 |
"full": "True",
|
@@ -381,13 +363,33 @@ def get_all_models(limit=1000):
|
|
381 |
|
382 |
if korean_response.status_code == 200:
|
383 |
korean_models = korean_response.json()
|
384 |
-
print(f"
|
385 |
-
|
386 |
-
# ์ค๋ณต ์ ๊ฑฐํ๋ฉด์ Korean ๋ชจ๋ธ ์ถ๊ฐ
|
387 |
for model in korean_models:
|
388 |
-
|
|
|
389 |
all_models.append(model)
|
390 |
-
existing_ids.add(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
391 |
|
392 |
print(f"Total unique models: {len(all_models)}")
|
393 |
return all_models[:limit]
|
@@ -476,12 +478,11 @@ def get_models_data(progress=gr.Progress()):
|
|
476 |
likes = [m['likes'] for m in valid_models]
|
477 |
downloads = [m['downloads'] for m in valid_models]
|
478 |
|
479 |
-
#
|
480 |
-
y_values = [1001 - r for r in ranks]
|
481 |
-
|
482 |
fig.add_trace(go.Bar(
|
483 |
x=ids,
|
484 |
-
y=
|
|
|
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',
|
@@ -498,10 +499,12 @@ def get_models_data(progress=gr.Progress()):
|
|
498 |
'yanchor': 'top'
|
499 |
},
|
500 |
xaxis_title='Model ID',
|
501 |
-
yaxis_title='
|
502 |
yaxis=dict(
|
503 |
-
|
504 |
-
|
|
|
|
|
505 |
range=[0, 1000]
|
506 |
),
|
507 |
height=800,
|
|
|
322 |
def get_all_models(limit=1000):
|
323 |
"""๋ชจ๋ ๋ชจ๋ธ๊ณผ Korea ๊ด๋ จ ๋ชจ๋ธ ๊ฐ์ ธ์ค๊ธฐ"""
|
324 |
all_models = []
|
325 |
+
existing_ids = set()
|
326 |
|
327 |
+
# 1. Korea ๊ฒ์ ๊ฒฐ๊ณผ ๊ฐ์ ธ์ค๊ธฐ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
328 |
korea_params = {
|
329 |
"search": "korea",
|
330 |
"full": "True",
|
|
|
340 |
|
341 |
if korea_response.status_code == 200:
|
342 |
korea_models = korea_response.json()
|
343 |
+
print(f"Found {len(korea_models)} Korea-related models")
|
|
|
|
|
|
|
344 |
for model in korea_models:
|
345 |
+
model_id = model.get('id', '')
|
346 |
+
if model_id not in existing_ids:
|
347 |
all_models.append(model)
|
348 |
+
existing_ids.add(model_id)
|
349 |
|
350 |
+
# 2. Korean ๊ฒ์ ๊ฒฐ๊ณผ ๊ฐ์ ธ์ค๊ธฐ
|
351 |
korean_params = {
|
352 |
"search": "korean",
|
353 |
"full": "True",
|
|
|
363 |
|
364 |
if korean_response.status_code == 200:
|
365 |
korean_models = korean_response.json()
|
366 |
+
print(f"Found {len(korean_models)} Korean-related models")
|
|
|
|
|
367 |
for model in korean_models:
|
368 |
+
model_id = model.get('id', '')
|
369 |
+
if model_id not in existing_ids:
|
370 |
all_models.append(model)
|
371 |
+
existing_ids.add(model_id)
|
372 |
+
|
373 |
+
# 3. ์ผ๋ฐ ๋ชจ๋ธ ๋ฆฌ์คํธ ๊ฐ์ ธ์ค๊ธฐ
|
374 |
+
params = {
|
375 |
+
"limit": limit,
|
376 |
+
"full": "True",
|
377 |
+
"config": "True"
|
378 |
+
}
|
379 |
+
|
380 |
+
response = requests.get(
|
381 |
+
"https://huggingface.co/api/models",
|
382 |
+
headers={'Accept': 'application/json'},
|
383 |
+
params=params
|
384 |
+
)
|
385 |
+
|
386 |
+
if response.status_code == 200:
|
387 |
+
general_models = response.json()
|
388 |
+
for model in general_models:
|
389 |
+
model_id = model.get('id', '')
|
390 |
+
if model_id not in existing_ids:
|
391 |
+
all_models.append(model)
|
392 |
+
existing_ids.add(model_id)
|
393 |
|
394 |
print(f"Total unique models: {len(all_models)}")
|
395 |
return all_models[:limit]
|
|
|
478 |
likes = [m['likes'] for m in valid_models]
|
479 |
downloads = [m['downloads'] for m in valid_models]
|
480 |
|
481 |
+
# ๋ง๋ ๊ทธ๋ํ ์์ฑ (๊ฐ ์์์์ 1000๊น์ง์ ๊ธธ์ด๋ก ๋ง๋ ์์ฑ)
|
|
|
|
|
482 |
fig.add_trace(go.Bar(
|
483 |
x=ids,
|
484 |
+
y=ranks, # ์ค์ ์์ ์ฌ์ฉ
|
485 |
+
base=1000, # ๋ง๋์ ๊ธฐ์ค์ ์ 1000์ผ๋ก ์ค์
|
486 |
text=[f"Global Rank: #{r}<br>Downloads: {format(d, ',')}<br>Likes: {format(l, ',')}"
|
487 |
for r, d, l in zip(ranks, downloads, likes)],
|
488 |
textposition='auto',
|
|
|
499 |
'yanchor': 'top'
|
500 |
},
|
501 |
xaxis_title='Model ID',
|
502 |
+
yaxis_title='Rank',
|
503 |
yaxis=dict(
|
504 |
+
autorange='reversed', # Y์ถ์ ๋ฐ์
|
505 |
+
tickmode='linear',
|
506 |
+
tick0=0,
|
507 |
+
dtick=50,
|
508 |
range=[0, 1000]
|
509 |
),
|
510 |
height=800,
|