Update app.py
Browse files
app.py
CHANGED
@@ -318,53 +318,76 @@ def get_korea_models():
|
|
318 |
return []
|
319 |
|
320 |
def get_all_models(limit=1000):
|
321 |
-
"""
|
322 |
all_models = []
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
}
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
)
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
350 |
|
351 |
-
|
352 |
-
|
|
|
|
|
|
|
|
|
353 |
|
354 |
-
#
|
355 |
-
|
356 |
-
|
|
|
|
|
|
|
|
|
357 |
|
358 |
-
|
359 |
-
|
|
|
|
|
|
|
360 |
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
|
|
|
|
|
|
|
|
366 |
|
367 |
-
print(f"Total models
|
368 |
return all_models[:limit]
|
369 |
|
370 |
def get_models_data(progress=gr.Progress()):
|
@@ -372,7 +395,7 @@ def get_models_data(progress=gr.Progress()):
|
|
372 |
try:
|
373 |
progress(0, desc="Fetching models...")
|
374 |
|
375 |
-
#
|
376 |
all_global_models = get_all_models(limit=1000)
|
377 |
print(f"Actually fetched models count: {len(all_global_models)}")
|
378 |
|
|
|
318 |
return []
|
319 |
|
320 |
def get_all_models(limit=1000):
|
321 |
+
"""모든 모델과 Korea 관련 모델 가져오기"""
|
322 |
all_models = []
|
323 |
+
|
324 |
+
# 1. 일반 모델 리스트 가져오기
|
325 |
+
params = {
|
326 |
+
"limit": limit,
|
327 |
+
"full": "True",
|
328 |
+
"config": "True"
|
329 |
+
}
|
330 |
+
|
331 |
+
response = requests.get(
|
332 |
+
"https://huggingface.co/api/models",
|
333 |
+
headers={'Accept': 'application/json'},
|
334 |
+
params=params
|
335 |
+
)
|
336 |
+
|
337 |
+
if response.status_code == 200:
|
338 |
+
all_models.extend(response.json())
|
339 |
+
print(f"Fetched {len(all_models)} general models")
|
340 |
+
|
341 |
+
# 2. Korea 검색 결과 가져오기
|
342 |
+
korea_params = {
|
343 |
+
"search": "korea",
|
344 |
+
"full": "True",
|
345 |
+
"config": "True",
|
346 |
+
"limit": limit
|
347 |
+
}
|
348 |
+
|
349 |
+
korea_response = requests.get(
|
350 |
+
"https://huggingface.co/api/models",
|
351 |
+
headers={'Accept': 'application/json'},
|
352 |
+
params=korea_params
|
353 |
+
)
|
354 |
+
|
355 |
+
if korea_response.status_code == 200:
|
356 |
+
korea_models = korea_response.json()
|
357 |
+
print(f"Fetched {len(korea_models)} Korea-related models")
|
358 |
|
359 |
+
# 중복 제거하면서 Korea 모델 추가
|
360 |
+
existing_ids = {model.get('id', '') for model in all_models}
|
361 |
+
for model in korea_models:
|
362 |
+
if model.get('id', '') not in existing_ids:
|
363 |
+
all_models.append(model)
|
364 |
+
existing_ids.add(model.get('id', ''))
|
365 |
|
366 |
+
# 3. Korean 검색 결과 가져오기
|
367 |
+
korean_params = {
|
368 |
+
"search": "korean",
|
369 |
+
"full": "True",
|
370 |
+
"config": "True",
|
371 |
+
"limit": limit
|
372 |
+
}
|
373 |
|
374 |
+
korean_response = requests.get(
|
375 |
+
"https://huggingface.co/api/models",
|
376 |
+
headers={'Accept': 'application/json'},
|
377 |
+
params=korean_params
|
378 |
+
)
|
379 |
|
380 |
+
if korean_response.status_code == 200:
|
381 |
+
korean_models = korean_response.json()
|
382 |
+
print(f"Fetched {len(korean_models)} Korean-related models")
|
383 |
+
|
384 |
+
# 중복 제거하면서 Korean 모델 추가
|
385 |
+
for model in korean_models:
|
386 |
+
if model.get('id', '') not in existing_ids:
|
387 |
+
all_models.append(model)
|
388 |
+
existing_ids.add(model.get('id', ''))
|
389 |
|
390 |
+
print(f"Total unique models: {len(all_models)}")
|
391 |
return all_models[:limit]
|
392 |
|
393 |
def get_models_data(progress=gr.Progress()):
|
|
|
395 |
try:
|
396 |
progress(0, desc="Fetching models...")
|
397 |
|
398 |
+
# 모델 가져오기
|
399 |
all_global_models = get_all_models(limit=1000)
|
400 |
print(f"Actually fetched models count: {len(all_global_models)}")
|
401 |
|