Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -291,67 +291,71 @@ target_models = {
|
|
291 |
"sel303/llama3-diverce-ver1.6": "https://huggingface.co/sel303/llama3-diverce-ver1.6"
|
292 |
}
|
293 |
|
|
|
|
|
294 |
def get_models_data(progress=gr.Progress()):
|
295 |
"""๋ชจ๋ธ ๋ฐ์ดํฐ ๊ฐ์ ธ์ค๊ธฐ"""
|
296 |
-
url = "https://huggingface.co/api/models
|
297 |
|
298 |
try:
|
299 |
progress(0, desc="Fetching models data...")
|
300 |
-
params = {
|
301 |
-
'full': 'true',
|
302 |
-
'limit': 1000
|
303 |
-
}
|
304 |
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
print(f"Response: {response.text}")
|
313 |
-
return create_error_plot(), "<div>๋ชจ๋ธ ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์ค๋๋ฐ ์คํจํ์ต๋๋ค.</div>", pd.DataFrame()
|
314 |
-
|
315 |
-
models = response.json()
|
316 |
-
print(f"Total models fetched: {len(models)}")
|
317 |
-
|
318 |
-
# target_models์ ๋งค์นญ
|
319 |
-
filtered_models = []
|
320 |
-
model_ranks = {}
|
321 |
|
322 |
-
|
323 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
324 |
model_id = model.get('id', '')
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
for model in models:
|
329 |
-
if model.get('id', '') in target_models:
|
330 |
-
model['rank'] = model_ranks[model.get('id', '')]
|
331 |
-
filtered_models.append(model)
|
332 |
-
print(f"Found model: {model.get('id', '')} at rank {model['rank']}")
|
333 |
|
334 |
-
#
|
335 |
-
|
336 |
|
337 |
-
|
|
|
|
|
338 |
|
339 |
-
if not
|
340 |
return create_error_plot(), "<div>์ ํ๋ ๋ชจ๋ธ์ ๋ฐ์ดํฐ๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค.</div>", pd.DataFrame()
|
341 |
|
|
|
342 |
progress(0.3, desc="Creating visualization...")
|
343 |
|
344 |
# ์๊ฐํ ์์ฑ
|
345 |
fig = go.Figure()
|
346 |
|
347 |
# ๋ฐ์ดํฐ ์ค๋น
|
348 |
-
ids = [model['id'] for model in
|
349 |
-
ranks = [model['rank'] for model in
|
350 |
-
likes = [model.get('likes', 0) for model in
|
351 |
-
downloads = [model.get('downloads', 0) for model in
|
352 |
|
353 |
-
# Y์ถ ๊ฐ์ ๋ฐ์
|
354 |
y_values = [1001 - r for r in ranks]
|
|
|
355 |
|
356 |
# ๋ง๋ ๊ทธ๋ํ ์์ฑ
|
357 |
fig.add_trace(go.Bar(
|
|
|
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 |
+
url = "https://huggingface.co/api/models" # ๊ธฐ๋ณธ ๋ชจ๋ธ API ์๋ํฌ์ธํธ
|
299 |
|
300 |
try:
|
301 |
progress(0, desc="Fetching models data...")
|
|
|
|
|
|
|
|
|
302 |
|
303 |
+
# ์ฌ๋ฌ ์ ๋ ฌ ๋ฐฉ์์ผ๋ก ์๋
|
304 |
+
all_found_models = []
|
305 |
+
sort_options = [
|
306 |
+
{'sort': 'downloads', 'direction': -1},
|
307 |
+
{'sort': 'lastModified', 'direction': -1},
|
308 |
+
{'sort': 'likes', 'direction': -1}
|
309 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
310 |
|
311 |
+
for sort_params in sort_options:
|
312 |
+
params = {
|
313 |
+
'full': 'true',
|
314 |
+
'limit': 1000,
|
315 |
+
**sort_params
|
316 |
+
}
|
317 |
+
|
318 |
+
headers = {'Accept': 'application/json'}
|
319 |
+
|
320 |
+
response = requests.get(url, params=params, headers=headers)
|
321 |
+
if response.status_code == 200:
|
322 |
+
models = response.json()
|
323 |
+
all_found_models.extend(models)
|
324 |
+
|
325 |
+
# ์ค๋ณต ์ ๊ฑฐ
|
326 |
+
seen_ids = set()
|
327 |
+
unique_models = []
|
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 |
+
unique_models.append(model)
|
|
|
|
|
|
|
|
|
|
|
333 |
|
334 |
+
# ๋ค์ด๋ก๋ ์๋ก ์ ๋ ฌ
|
335 |
+
unique_models.sort(key=lambda x: x.get('downloads', 0), reverse=True)
|
336 |
|
337 |
+
# ์์ ํ ๋น
|
338 |
+
for idx, model in enumerate(unique_models, 1):
|
339 |
+
model['rank'] = idx
|
340 |
|
341 |
+
if not unique_models:
|
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 unique_models]
|
352 |
+
ranks = [model['rank'] for model in unique_models]
|
353 |
+
likes = [model.get('likes', 0) for model in unique_models]
|
354 |
+
downloads = [model.get('downloads', 0) for model in unique_models]
|
355 |
|
356 |
+
# Y์ถ ๊ฐ์ ๋ฐ์
|
357 |
y_values = [1001 - r for r in ranks]
|
358 |
+
|
359 |
|
360 |
# ๋ง๋ ๊ทธ๋ํ ์์ฑ
|
361 |
fig.add_trace(go.Bar(
|