Update app.py
Browse files
app.py
CHANGED
@@ -292,23 +292,19 @@ target_models = {
|
|
292 |
"sel303/llama3-diverce-ver1.6": "https://huggingface.co/sel303/llama3-diverce-ver1.6"
|
293 |
}
|
294 |
|
295 |
-
|
296 |
-
|
297 |
def get_models_data(progress=gr.Progress()):
|
298 |
"""모델 데이터 가져오기"""
|
299 |
def normalize_model_id(model_id):
|
300 |
"""모델 ID를 정규화"""
|
301 |
return model_id.strip().lower()
|
302 |
|
303 |
-
url = "https://huggingface.co/api/models"
|
304 |
|
305 |
try:
|
306 |
progress(0, desc="Fetching models data...")
|
307 |
params = {
|
308 |
'full': 'true',
|
309 |
-
'limit': 3000
|
310 |
-
'sort': 'likes',
|
311 |
-
'direction': -1
|
312 |
}
|
313 |
|
314 |
headers = {'Accept': 'application/json'}
|
@@ -321,7 +317,7 @@ def get_models_data(progress=gr.Progress()):
|
|
321 |
|
322 |
models = response.json()
|
323 |
|
324 |
-
# 전체 순위 정보 저장 (
|
325 |
model_ranks = {}
|
326 |
model_data = {} # 모든 모델의 상세 데이터 저장
|
327 |
|
@@ -338,8 +334,6 @@ def get_models_data(progress=gr.Progress()):
|
|
338 |
filtered_models = []
|
339 |
for target_id in target_models.keys():
|
340 |
normalized_target_id = normalize_model_id(target_id)
|
341 |
-
|
342 |
-
# 먼저 전체 순위에서 찾기
|
343 |
if normalized_target_id in model_data:
|
344 |
model_info = {
|
345 |
'id': target_id,
|
@@ -349,34 +343,18 @@ def get_models_data(progress=gr.Progress()):
|
|
349 |
'title': model_data[normalized_target_id]['title']
|
350 |
}
|
351 |
else:
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
model_info['rank'] = 'Not in top 3000'
|
360 |
-
else:
|
361 |
-
model_info = {
|
362 |
-
'id': target_id,
|
363 |
-
'rank': 'Not in top 3000',
|
364 |
-
'downloads': 0,
|
365 |
-
'likes': 0,
|
366 |
-
'title': 'No Title'
|
367 |
-
}
|
368 |
-
except Exception as e:
|
369 |
-
print(f"Error fetching data for model {target_id}: {str(e)}")
|
370 |
-
model_info = {
|
371 |
-
'id': target_id,
|
372 |
-
'rank': 'Not in top 3000',
|
373 |
-
'downloads': 0,
|
374 |
-
'likes': 0,
|
375 |
-
'title': 'No Title'
|
376 |
-
}
|
377 |
-
|
378 |
filtered_models.append(model_info)
|
379 |
|
|
|
|
|
|
|
380 |
# 순위로 정렬 (순위가 숫자인 경우만)
|
381 |
filtered_models.sort(key=lambda x: (
|
382 |
float('inf') if x['rank'] == 'Not in top 3000' else x['rank']
|
|
|
292 |
"sel303/llama3-diverce-ver1.6": "https://huggingface.co/sel303/llama3-diverce-ver1.6"
|
293 |
}
|
294 |
|
|
|
|
|
295 |
def get_models_data(progress=gr.Progress()):
|
296 |
"""모델 데이터 가져오기"""
|
297 |
def normalize_model_id(model_id):
|
298 |
"""모델 ID를 정규화"""
|
299 |
return model_id.strip().lower()
|
300 |
|
301 |
+
url = "https://huggingface.co/api/models/trending" # trending API로 변경
|
302 |
|
303 |
try:
|
304 |
progress(0, desc="Fetching models data...")
|
305 |
params = {
|
306 |
'full': 'true',
|
307 |
+
'limit': 3000
|
|
|
|
|
308 |
}
|
309 |
|
310 |
headers = {'Accept': 'application/json'}
|
|
|
317 |
|
318 |
models = response.json()
|
319 |
|
320 |
+
# 전체 순위 정보 저장 (trending 순위 기준)
|
321 |
model_ranks = {}
|
322 |
model_data = {} # 모든 모델의 상세 데이터 저장
|
323 |
|
|
|
334 |
filtered_models = []
|
335 |
for target_id in target_models.keys():
|
336 |
normalized_target_id = normalize_model_id(target_id)
|
|
|
|
|
337 |
if normalized_target_id in model_data:
|
338 |
model_info = {
|
339 |
'id': target_id,
|
|
|
343 |
'title': model_data[normalized_target_id]['title']
|
344 |
}
|
345 |
else:
|
346 |
+
model_info = {
|
347 |
+
'id': target_id,
|
348 |
+
'rank': 'Not in trending',
|
349 |
+
'downloads': 'N/A',
|
350 |
+
'likes': 'N/A',
|
351 |
+
'title': 'No Title'
|
352 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
353 |
filtered_models.append(model_info)
|
354 |
|
355 |
+
# trending 순위로 정렬
|
356 |
+
filtered_models.sort(key=lambda x: float('inf') if x['rank'] == 'Not in trending' else x['rank'])
|
357 |
+
|
358 |
# 순위로 정렬 (순위가 숫자인 경우만)
|
359 |
filtered_models.sort(key=lambda x: (
|
360 |
float('inf') if x['rank'] == 'Not in top 3000' else x['rank']
|