Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -15,7 +15,10 @@ target_models = {
|
|
15 |
"LGAI-EXAONE/EXAONE-3.5-7.8B-Instruct": "https://huggingface.co/LGAI-EXAONE/EXAONE-3.5-7.8B-Instruct",
|
16 |
"ginipick/flux-lora-eric-cat": "https://huggingface.co/ginipick/flux-lora-eric-cat",
|
17 |
"seawolf2357/flux-lora-car-rolls-royce": "https://huggingface.co/seawolf2357/flux-lora-car-rolls-royce",
|
18 |
-
|
|
|
|
|
|
|
19 |
"Saxo/Linkbricks-Horizon-AI-Korean-Gemma-2-sft-dpo-27B": "https://huggingface.co/Saxo/Linkbricks-Horizon-AI-Korean-Gemma-2-sft-dpo-27B",
|
20 |
"AALF/gemma-2-27b-it-SimPO-37K": "https://huggingface.co/AALF/gemma-2-27b-it-SimPO-37K",
|
21 |
"nbeerbower/mistral-nemo-wissenschaft-12B": "https://huggingface.co/nbeerbower/mistral-nemo-wissenschaft-12B",
|
@@ -288,14 +291,20 @@ target_models = {
|
|
288 |
"sel303/llama3-diverce-ver1.6": "https://huggingface.co/sel303/llama3-diverce-ver1.6"
|
289 |
}
|
290 |
|
|
|
|
|
291 |
def get_models_data(progress=gr.Progress()):
|
292 |
"""모델 데이터 가져오기"""
|
|
|
|
|
|
|
|
|
293 |
url = "https://huggingface.co/api/models"
|
294 |
|
295 |
try:
|
296 |
progress(0, desc="Fetching models data...")
|
297 |
|
298 |
-
# 여러 정렬 방식으로
|
299 |
all_found_models = []
|
300 |
sort_options = [
|
301 |
{'sort': 'downloads', 'direction': -1},
|
@@ -303,11 +312,6 @@ def get_models_data(progress=gr.Progress()):
|
|
303 |
{'sort': 'likes', 'direction': -1}
|
304 |
]
|
305 |
|
306 |
-
headers = {
|
307 |
-
'Accept': 'application/json',
|
308 |
-
'User-Agent': 'Mozilla/5.0'
|
309 |
-
}
|
310 |
-
|
311 |
for sort_params in sort_options:
|
312 |
params = {
|
313 |
'full': 'true',
|
@@ -315,29 +319,28 @@ def get_models_data(progress=gr.Progress()):
|
|
315 |
**sort_params
|
316 |
}
|
317 |
|
|
|
|
|
318 |
response = requests.get(url, params=params, headers=headers)
|
319 |
if response.status_code == 200:
|
320 |
models = response.json()
|
321 |
all_found_models.extend(models)
|
322 |
-
print(f"Found {len(models)} models with {sort_params['sort']} sort")
|
323 |
-
|
324 |
-
if not all_found_models:
|
325 |
-
print("No models found from API")
|
326 |
-
return create_error_plot(), "<div>모델 데이터를 가져오는데 실패했습니다.</div>", pd.DataFrame()
|
327 |
|
328 |
# 중복 제거
|
329 |
-
|
330 |
-
print(f"Total unique models: {len(unique_models)}")
|
331 |
-
|
332 |
-
# target_models와 매칭
|
333 |
filtered_models = []
|
334 |
-
for model in
|
335 |
-
|
336 |
-
|
|
|
337 |
filtered_models.append(model)
|
338 |
-
print(f"Matched model: {model['id']}")
|
339 |
|
340 |
-
|
|
|
|
|
|
|
|
|
|
|
341 |
|
342 |
if not filtered_models:
|
343 |
return create_error_plot(), "<div>선택된 모델의 데이터를 찾을 수 없습니다.</div>", pd.DataFrame()
|
@@ -349,15 +352,9 @@ def get_models_data(progress=gr.Progress()):
|
|
349 |
|
350 |
# 데이터 준비
|
351 |
ids = [model['id'] for model in filtered_models]
|
352 |
-
|
353 |
likes = [model.get('likes', 0) for model in filtered_models]
|
354 |
-
|
355 |
-
# 다운로드 수를 기준으로 순위 재계산
|
356 |
-
sorted_models = sorted(filtered_models, key=lambda x: x.get('downloads', 0), reverse=True)
|
357 |
-
for idx, model in enumerate(sorted_models):
|
358 |
-
model['rank'] = idx + 1
|
359 |
-
|
360 |
-
ranks = [model['rank'] for model in sorted_models]
|
361 |
|
362 |
# Y축 값을 반전
|
363 |
y_values = [1001 - r for r in ranks]
|
@@ -366,8 +363,8 @@ def get_models_data(progress=gr.Progress()):
|
|
366 |
fig.add_trace(go.Bar(
|
367 |
x=ids,
|
368 |
y=y_values,
|
369 |
-
text=[f"Rank: {r}<br>
|
370 |
-
for r,
|
371 |
textposition='auto',
|
372 |
marker_color='rgb(158,202,225)',
|
373 |
opacity=0.8
|
@@ -375,7 +372,7 @@ def get_models_data(progress=gr.Progress()):
|
|
375 |
|
376 |
fig.update_layout(
|
377 |
title={
|
378 |
-
'text': 'Hugging Face Models Rankings (Top 1000)',
|
379 |
'y':0.95,
|
380 |
'x':0.5,
|
381 |
'xanchor': 'center',
|
@@ -399,15 +396,16 @@ def get_models_data(progress=gr.Progress()):
|
|
399 |
# HTML 카드 생성
|
400 |
html_content = """
|
401 |
<div style='padding: 20px; background: #f5f5f5;'>
|
402 |
-
<h2 style='color: #2c3e50;'>Models Rankings</h2>
|
403 |
<div style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;'>
|
404 |
"""
|
405 |
|
406 |
-
|
|
|
407 |
model_id = model['id']
|
408 |
rank = model['rank']
|
409 |
-
downloads = model.get('downloads', 0)
|
410 |
likes = model.get('likes', 0)
|
|
|
411 |
|
412 |
html_content += f"""
|
413 |
<div style='
|
@@ -418,8 +416,8 @@ def get_models_data(progress=gr.Progress()):
|
|
418 |
transition: transform 0.2s;
|
419 |
'>
|
420 |
<h3 style='color: #34495e;'>Rank #{rank} - {model_id}</h3>
|
421 |
-
<p style='color: #7f8c8d;'>⬇️ Downloads: {downloads}</p>
|
422 |
<p style='color: #7f8c8d;'>👍 Likes: {likes}</p>
|
|
|
423 |
<a href='{target_models[model_id]}'
|
424 |
target='_blank'
|
425 |
style='
|
@@ -436,16 +434,58 @@ def get_models_data(progress=gr.Progress()):
|
|
436 |
</div>
|
437 |
"""
|
438 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
439 |
html_content += "</div></div>"
|
440 |
|
441 |
# 데이터프레임 생성
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
449 |
|
450 |
progress(1.0, desc="Complete!")
|
451 |
return fig, html_content, df
|
@@ -454,60 +494,10 @@ def get_models_data(progress=gr.Progress()):
|
|
454 |
print(f"Error in get_models_data: {str(e)}")
|
455 |
return create_error_plot(), f"<div>에러 발생: {str(e)}</div>", pd.DataFrame()
|
456 |
|
457 |
-
# API 응답 형식에 맞게 모델 ID 수정
|
458 |
-
def normalize_model_id(model_id):
|
459 |
-
"""모델 ID를 정규화"""
|
460 |
-
return model_id.strip().lower()
|
461 |
-
|
462 |
-
# 매칭 로직 수정
|
463 |
-
filtered_models = []
|
464 |
-
for model in all_models:
|
465 |
-
model_id = normalize_model_id(model.get('id', ''))
|
466 |
-
target_id = next(
|
467 |
-
(tid for tid in target_models.keys()
|
468 |
-
if normalize_model_id(tid) == model_id),
|
469 |
-
None
|
470 |
-
)
|
471 |
-
|
472 |
-
if target_id:
|
473 |
-
model['rank'] = len(filtered_models) + 1
|
474 |
-
filtered_models.append(model)
|
475 |
-
print(f"Matched model: {model_id} with target: {target_id}")
|
476 |
-
|
477 |
-
print(f"\nMatched {len(filtered_models)} models out of {len(target_models)} targets")
|
478 |
-
|
479 |
-
def try_different_sorts():
|
480 |
-
"""다양한 정렬 방식으로 모델 검색"""
|
481 |
-
sort_options = [
|
482 |
-
{'sort': 'downloads', 'direction': -1},
|
483 |
-
{'sort': 'lastModified', 'direction': -1},
|
484 |
-
{'sort': 'likes', 'direction': -1}
|
485 |
-
]
|
486 |
-
|
487 |
-
all_found_models = set()
|
488 |
-
for sort_params in sort_options:
|
489 |
-
params = {
|
490 |
-
'full': 'true',
|
491 |
-
'limit': 1000,
|
492 |
-
**sort_params
|
493 |
-
}
|
494 |
-
|
495 |
-
response = requests.get(url, params=params, headers=headers)
|
496 |
-
if response.status_code == 200:
|
497 |
-
models = response.json()
|
498 |
-
for model in models:
|
499 |
-
model_id = normalize_model_id(model.get('id', ''))
|
500 |
-
if model_id in [normalize_model_id(tid) for tid in target_models.keys()]:
|
501 |
-
all_found_models.add(model_id)
|
502 |
-
|
503 |
-
return all_found_models
|
504 |
-
|
505 |
-
# 메인 함수에서 사용
|
506 |
-
all_found_models = try_different_sorts()
|
507 |
-
print(f"\nTotal unique models found across all sorts: {len(all_found_models)}")
|
508 |
-
|
509 |
# 관심 스페이스 URL 리스트와 정보
|
510 |
target_spaces = {
|
|
|
|
|
511 |
"ginipick/FLUXllama": "https://huggingface.co/spaces/ginipick/FLUXllama",
|
512 |
"ginipick/SORA-3D": "https://huggingface.co/spaces/ginipick/SORA-3D",
|
513 |
"fantaxy/Sound-AI-SFX": "https://huggingface.co/spaces/fantaxy/Sound-AI-SFX",
|
|
|
15 |
"LGAI-EXAONE/EXAONE-3.5-7.8B-Instruct": "https://huggingface.co/LGAI-EXAONE/EXAONE-3.5-7.8B-Instruct",
|
16 |
"ginipick/flux-lora-eric-cat": "https://huggingface.co/ginipick/flux-lora-eric-cat",
|
17 |
"seawolf2357/flux-lora-car-rolls-royce": "https://huggingface.co/seawolf2357/flux-lora-car-rolls-royce",
|
18 |
+
|
19 |
+
"moreh/Llama-3-Motif-102B-Instruct": "https://huggingface.co/moreh/Llama-3-Motif-102B-Instruct",
|
20 |
+
"moreh/Llama-3-Motif-102B": "https://huggingface.co/moreh/Llama-3-Motif-102B",
|
21 |
+
|
22 |
"Saxo/Linkbricks-Horizon-AI-Korean-Gemma-2-sft-dpo-27B": "https://huggingface.co/Saxo/Linkbricks-Horizon-AI-Korean-Gemma-2-sft-dpo-27B",
|
23 |
"AALF/gemma-2-27b-it-SimPO-37K": "https://huggingface.co/AALF/gemma-2-27b-it-SimPO-37K",
|
24 |
"nbeerbower/mistral-nemo-wissenschaft-12B": "https://huggingface.co/nbeerbower/mistral-nemo-wissenschaft-12B",
|
|
|
291 |
"sel303/llama3-diverce-ver1.6": "https://huggingface.co/sel303/llama3-diverce-ver1.6"
|
292 |
}
|
293 |
|
294 |
+
# all_models 관련 코드 제거하고 get_models_data 함수 내부에서 처리하도록 수정
|
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...")
|
306 |
|
307 |
+
# 여러 정렬 방식으로 시도
|
308 |
all_found_models = []
|
309 |
sort_options = [
|
310 |
{'sort': 'downloads', 'direction': -1},
|
|
|
312 |
{'sort': 'likes', 'direction': -1}
|
313 |
]
|
314 |
|
|
|
|
|
|
|
|
|
|
|
315 |
for sort_params in sort_options:
|
316 |
params = {
|
317 |
'full': 'true',
|
|
|
319 |
**sort_params
|
320 |
}
|
321 |
|
322 |
+
headers = {'Accept': 'application/json'}
|
323 |
+
|
324 |
response = requests.get(url, params=params, headers=headers)
|
325 |
if response.status_code == 200:
|
326 |
models = response.json()
|
327 |
all_found_models.extend(models)
|
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
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]
|
|
|
363 |
fig.add_trace(go.Bar(
|
364 |
x=ids,
|
365 |
y=y_values,
|
366 |
+
text=[f"Rank: {r}<br>Likes: {l}<br>Downloads: {d}"
|
367 |
+
for r, l, d in zip(ranks, likes, downloads)],
|
368 |
textposition='auto',
|
369 |
marker_color='rgb(158,202,225)',
|
370 |
opacity=0.8
|
|
|
372 |
|
373 |
fig.update_layout(
|
374 |
title={
|
375 |
+
'text': 'Hugging Face Models Trending Rankings (Top 1000)',
|
376 |
'y':0.95,
|
377 |
'x':0.5,
|
378 |
'xanchor': 'center',
|
|
|
396 |
# HTML 카드 생성
|
397 |
html_content = """
|
398 |
<div style='padding: 20px; background: #f5f5f5;'>
|
399 |
+
<h2 style='color: #2c3e50;'>Models Trending Rankings</h2>
|
400 |
<div style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;'>
|
401 |
"""
|
402 |
|
403 |
+
# 순위권 내 모델 카드 생성
|
404 |
+
for model in filtered_models:
|
405 |
model_id = model['id']
|
406 |
rank = model['rank']
|
|
|
407 |
likes = model.get('likes', 0)
|
408 |
+
downloads = model.get('downloads', 0)
|
409 |
|
410 |
html_content += f"""
|
411 |
<div style='
|
|
|
416 |
transition: transform 0.2s;
|
417 |
'>
|
418 |
<h3 style='color: #34495e;'>Rank #{rank} - {model_id}</h3>
|
|
|
419 |
<p style='color: #7f8c8d;'>👍 Likes: {likes}</p>
|
420 |
+
<p style='color: #7f8c8d;'>⬇️ Downloads: {downloads}</p>
|
421 |
<a href='{target_models[model_id]}'
|
422 |
target='_blank'
|
423 |
style='
|
|
|
434 |
</div>
|
435 |
"""
|
436 |
|
437 |
+
# 순위권 밖 모델 카드 생성
|
438 |
+
for model_id in target_models:
|
439 |
+
if model_id not in [m['id'] for m in filtered_models]:
|
440 |
+
html_content += f"""
|
441 |
+
<div style='
|
442 |
+
background: #f8f9fa;
|
443 |
+
padding: 20px;
|
444 |
+
border-radius: 10px;
|
445 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
446 |
+
'>
|
447 |
+
<h3 style='color: #34495e;'>{model_id}</h3>
|
448 |
+
<p style='color: #7f8c8d;'>Not in top 1000</p>
|
449 |
+
<a href='{target_models[model_id]}'
|
450 |
+
target='_blank'
|
451 |
+
style='
|
452 |
+
display: inline-block;
|
453 |
+
padding: 8px 16px;
|
454 |
+
background: #95a5a6;
|
455 |
+
color: white;
|
456 |
+
text-decoration: none;
|
457 |
+
border-radius: 5px;
|
458 |
+
'>
|
459 |
+
Visit Model 🔗
|
460 |
+
</a>
|
461 |
+
</div>
|
462 |
+
"""
|
463 |
+
|
464 |
html_content += "</div></div>"
|
465 |
|
466 |
# 데이터프레임 생성
|
467 |
+
df_data = []
|
468 |
+
# 순위권 내 모델
|
469 |
+
for model in filtered_models:
|
470 |
+
df_data.append({
|
471 |
+
'Rank': model['rank'],
|
472 |
+
'Model ID': model['id'],
|
473 |
+
'Likes': model.get('likes', 'N/A'),
|
474 |
+
'Downloads': model.get('downloads', 'N/A'),
|
475 |
+
'URL': target_models[model['id']]
|
476 |
+
})
|
477 |
+
# 순위권 밖 모델
|
478 |
+
for model_id in target_models:
|
479 |
+
if model_id not in [m['id'] for m in filtered_models]:
|
480 |
+
df_data.append({
|
481 |
+
'Rank': 'Not in top 1000',
|
482 |
+
'Model ID': model_id,
|
483 |
+
'Likes': 'N/A',
|
484 |
+
'Downloads': 'N/A',
|
485 |
+
'URL': target_models[model_id]
|
486 |
+
})
|
487 |
+
|
488 |
+
df = pd.DataFrame(df_data)
|
489 |
|
490 |
progress(1.0, desc="Complete!")
|
491 |
return fig, html_content, df
|
|
|
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",
|