Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -295,7 +295,11 @@ target_models = {
|
|
295 |
|
296 |
def get_models_data(progress=gr.Progress()):
|
297 |
"""๋ชจ๋ธ ๋ฐ์ดํฐ ๊ฐ์ ธ์ค๊ธฐ"""
|
298 |
-
|
|
|
|
|
|
|
|
|
299 |
|
300 |
try:
|
301 |
progress(0, desc="Fetching models data...")
|
@@ -324,38 +328,36 @@ def get_models_data(progress=gr.Progress()):
|
|
324 |
|
325 |
# ์ค๋ณต ์ ๊ฑฐ
|
326 |
seen_ids = set()
|
327 |
-
|
328 |
for model in all_found_models:
|
329 |
-
model_id = model.get('id', '')
|
330 |
-
if model_id not in seen_ids and model_id in target_models:
|
331 |
seen_ids.add(model_id)
|
332 |
-
|
333 |
|
334 |
# ๋ค์ด๋ก๋ ์๋ก ์ ๋ ฌ
|
335 |
-
|
336 |
|
337 |
# ์์ ํ ๋น
|
338 |
-
for idx, model in enumerate(
|
339 |
model['rank'] = idx
|
340 |
|
341 |
-
if not
|
342 |
return create_error_plot(), "<div>์ ํ๋ ๋ชจ๋ธ์ ๋ฐ์ดํฐ๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค.</div>", pd.DataFrame()
|
343 |
|
344 |
-
# ๋๋จธ์ง ์๊ฐํ ์ฝ๋๋ ๋์ผํ๊ฒ ์ ์ง
|
345 |
progress(0.3, desc="Creating visualization...")
|
346 |
|
347 |
# ์๊ฐํ ์์ฑ
|
348 |
fig = go.Figure()
|
349 |
|
350 |
# ๋ฐ์ดํฐ ์ค๋น
|
351 |
-
ids = [model['id'] for model in
|
352 |
-
ranks = [model['rank'] for model in
|
353 |
-
likes = [model.get('likes', 0) for model in
|
354 |
-
downloads = [model.get('downloads', 0) for model in
|
355 |
|
356 |
# Y์ถ ๊ฐ์ ๋ฐ์
|
357 |
y_values = [1001 - r for r in ranks]
|
358 |
-
|
359 |
|
360 |
# ๋ง๋ ๊ทธ๋ํ ์์ฑ
|
361 |
fig.add_trace(go.Bar(
|
@@ -492,60 +494,10 @@ def get_models_data(progress=gr.Progress()):
|
|
492 |
print(f"Error in get_models_data: {str(e)}")
|
493 |
return create_error_plot(), f"<div>์๋ฌ ๋ฐ์: {str(e)}</div>", pd.DataFrame()
|
494 |
|
495 |
-
# API ์๋ต ํ์์ ๋ง๊ฒ ๋ชจ๋ธ ID ์์
|
496 |
-
def normalize_model_id(model_id):
|
497 |
-
"""๋ชจ๋ธ ID๋ฅผ ์ ๊ทํ"""
|
498 |
-
return model_id.strip().lower()
|
499 |
-
|
500 |
-
# ๋งค์นญ ๋ก์ง ์์
|
501 |
-
filtered_models = []
|
502 |
-
for model in all_models:
|
503 |
-
model_id = normalize_model_id(model.get('id', ''))
|
504 |
-
target_id = next(
|
505 |
-
(tid for tid in target_models.keys()
|
506 |
-
if normalize_model_id(tid) == model_id),
|
507 |
-
None
|
508 |
-
)
|
509 |
-
|
510 |
-
if target_id:
|
511 |
-
model['rank'] = len(filtered_models) + 1
|
512 |
-
filtered_models.append(model)
|
513 |
-
print(f"Matched model: {model_id} with target: {target_id}")
|
514 |
-
|
515 |
-
print(f"\nMatched {len(filtered_models)} models out of {len(target_models)} targets")
|
516 |
-
|
517 |
-
def try_different_sorts():
|
518 |
-
"""๋ค์ํ ์ ๋ ฌ ๋ฐฉ์์ผ๋ก ๋ชจ๋ธ ๊ฒ์"""
|
519 |
-
sort_options = [
|
520 |
-
{'sort': 'downloads', 'direction': -1},
|
521 |
-
{'sort': 'lastModified', 'direction': -1},
|
522 |
-
{'sort': 'likes', 'direction': -1}
|
523 |
-
]
|
524 |
-
|
525 |
-
all_found_models = set()
|
526 |
-
for sort_params in sort_options:
|
527 |
-
params = {
|
528 |
-
'full': 'true',
|
529 |
-
'limit': 1000,
|
530 |
-
**sort_params
|
531 |
-
}
|
532 |
-
|
533 |
-
response = requests.get(url, params=params, headers=headers)
|
534 |
-
if response.status_code == 200:
|
535 |
-
models = response.json()
|
536 |
-
for model in models:
|
537 |
-
model_id = normalize_model_id(model.get('id', ''))
|
538 |
-
if model_id in [normalize_model_id(tid) for tid in target_models.keys()]:
|
539 |
-
all_found_models.add(model_id)
|
540 |
-
|
541 |
-
return all_found_models
|
542 |
-
|
543 |
-
# ๋ฉ์ธ ํจ์์์ ์ฌ์ฉ
|
544 |
-
all_found_models = try_different_sorts()
|
545 |
-
print(f"\nTotal unique models found across all sorts: {len(all_found_models)}")
|
546 |
-
|
547 |
# ๊ด์ฌ ์คํ์ด์ค URL ๋ฆฌ์คํธ์ ์ ๋ณด
|
548 |
target_spaces = {
|
|
|
|
|
549 |
"ginipick/FLUXllama": "https://huggingface.co/spaces/ginipick/FLUXllama",
|
550 |
"ginipick/SORA-3D": "https://huggingface.co/spaces/ginipick/SORA-3D",
|
551 |
"fantaxy/Sound-AI-SFX": "https://huggingface.co/spaces/fantaxy/Sound-AI-SFX",
|
|
|
295 |
|
296 |
def get_models_data(progress=gr.Progress()):
|
297 |
"""๋ชจ๋ธ ๋ฐ์ดํฐ ๊ฐ์ ธ์ค๊ธฐ"""
|
298 |
+
def normalize_model_id(model_id):
|
299 |
+
"""๋ชจ๋ธ ID๋ฅผ ์ ๊ทํ"""
|
300 |
+
return model_id.strip().lower()
|
301 |
+
|
302 |
+
url = "https://huggingface.co/api/models"
|
303 |
|
304 |
try:
|
305 |
progress(0, desc="Fetching models data...")
|
|
|
328 |
|
329 |
# ์ค๋ณต ์ ๊ฑฐ
|
330 |
seen_ids = set()
|
331 |
+
filtered_models = []
|
332 |
for model in all_found_models:
|
333 |
+
model_id = normalize_model_id(model.get('id', ''))
|
334 |
+
if model_id not in seen_ids and model_id in [normalize_model_id(tid) for tid in target_models.keys()]:
|
335 |
seen_ids.add(model_id)
|
336 |
+
filtered_models.append(model)
|
337 |
|
338 |
# ๋ค์ด๋ก๋ ์๋ก ์ ๋ ฌ
|
339 |
+
filtered_models.sort(key=lambda x: x.get('downloads', 0), reverse=True)
|
340 |
|
341 |
# ์์ ํ ๋น
|
342 |
+
for idx, model in enumerate(filtered_models, 1):
|
343 |
model['rank'] = idx
|
344 |
|
345 |
+
if not filtered_models:
|
346 |
return create_error_plot(), "<div>์ ํ๋ ๋ชจ๋ธ์ ๋ฐ์ดํฐ๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค.</div>", pd.DataFrame()
|
347 |
|
|
|
348 |
progress(0.3, desc="Creating visualization...")
|
349 |
|
350 |
# ์๊ฐํ ์์ฑ
|
351 |
fig = go.Figure()
|
352 |
|
353 |
# ๋ฐ์ดํฐ ์ค๋น
|
354 |
+
ids = [model['id'] for model in filtered_models]
|
355 |
+
ranks = [model['rank'] for model in filtered_models]
|
356 |
+
likes = [model.get('likes', 0) for model in filtered_models]
|
357 |
+
downloads = [model.get('downloads', 0) for model in filtered_models]
|
358 |
|
359 |
# Y์ถ ๊ฐ์ ๋ฐ์
|
360 |
y_values = [1001 - r for r in ranks]
|
|
|
361 |
|
362 |
# ๋ง๋ ๊ทธ๋ํ ์์ฑ
|
363 |
fig.add_trace(go.Bar(
|
|
|
494 |
print(f"Error in get_models_data: {str(e)}")
|
495 |
return create_error_plot(), f"<div>์๋ฌ ๋ฐ์: {str(e)}</div>", pd.DataFrame()
|
496 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
497 |
# ๊ด์ฌ ์คํ์ด์ค URL ๋ฆฌ์คํธ์ ์ ๋ณด
|
498 |
target_spaces = {
|
499 |
+
|
500 |
+
"openfree/Korean-Leaderboard": "https://huggingface.co/spaces/openfree/Korean-Leaderboard",
|
501 |
"ginipick/FLUXllama": "https://huggingface.co/spaces/ginipick/FLUXllama",
|
502 |
"ginipick/SORA-3D": "https://huggingface.co/spaces/ginipick/SORA-3D",
|
503 |
"fantaxy/Sound-AI-SFX": "https://huggingface.co/spaces/fantaxy/Sound-AI-SFX",
|