openfree commited on
Commit
5739ca3
ยท
verified ยท
1 Parent(s): 444537c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -37
app.py CHANGED
@@ -322,25 +322,9 @@ def get_korea_models():
322
  def get_all_models(limit=1000):
323
  """๋ชจ๋“  ๋ชจ๋ธ๊ณผ Korea ๊ด€๋ จ ๋ชจ๋ธ ๊ฐ€์ ธ์˜ค๊ธฐ"""
324
  all_models = []
 
325
 
326
- # 1. ์ผ๋ฐ˜ ๋ชจ๋ธ ๋ฆฌ์ŠคํŠธ ๊ฐ€์ ธ์˜ค๊ธฐ
327
- params = {
328
- "limit": limit,
329
- "full": "True",
330
- "config": "True"
331
- }
332
-
333
- response = requests.get(
334
- "https://huggingface.co/api/models",
335
- headers={'Accept': 'application/json'},
336
- params=params
337
- )
338
-
339
- if response.status_code == 200:
340
- all_models.extend(response.json())
341
- print(f"Fetched {len(all_models)} general models")
342
-
343
- # 2. Korea ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ ๊ฐ€์ ธ์˜ค๊ธฐ
344
  korea_params = {
345
  "search": "korea",
346
  "full": "True",
@@ -356,16 +340,14 @@ def get_all_models(limit=1000):
356
 
357
  if korea_response.status_code == 200:
358
  korea_models = korea_response.json()
359
- print(f"Fetched {len(korea_models)} Korea-related models")
360
-
361
- # ์ค‘๋ณต ์ œ๊ฑฐํ•˜๋ฉด์„œ Korea ๋ชจ๋ธ ์ถ”๊ฐ€
362
- existing_ids = {model.get('id', '') for model in all_models}
363
  for model in korea_models:
364
- if model.get('id', '') not in existing_ids:
 
365
  all_models.append(model)
366
- existing_ids.add(model.get('id', ''))
367
 
368
- # 3. Korean ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ ๊ฐ€์ ธ์˜ค๊ธฐ
369
  korean_params = {
370
  "search": "korean",
371
  "full": "True",
@@ -381,13 +363,33 @@ def get_all_models(limit=1000):
381
 
382
  if korean_response.status_code == 200:
383
  korean_models = korean_response.json()
384
- print(f"Fetched {len(korean_models)} Korean-related models")
385
-
386
- # ์ค‘๋ณต ์ œ๊ฑฐํ•˜๋ฉด์„œ Korean ๋ชจ๋ธ ์ถ”๊ฐ€
387
  for model in korean_models:
388
- if model.get('id', '') not in existing_ids:
 
389
  all_models.append(model)
390
- existing_ids.add(model.get('id', ''))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
391
 
392
  print(f"Total unique models: {len(all_models)}")
393
  return all_models[:limit]
@@ -476,12 +478,11 @@ def get_models_data(progress=gr.Progress()):
476
  likes = [m['likes'] for m in valid_models]
477
  downloads = [m['downloads'] for m in valid_models]
478
 
479
- # Y์ถ• ๊ฐ’์„ ๋ฐ˜์ „ (๋†’์€ ์ˆœ์œ„๊ฐ€ ์œ„๋กœ ๊ฐ€๋„๋ก)
480
- y_values = [1001 - r for r in ranks]
481
-
482
  fig.add_trace(go.Bar(
483
  x=ids,
484
- y=y_values,
 
485
  text=[f"Global Rank: #{r}<br>Downloads: {format(d, ',')}<br>Likes: {format(l, ',')}"
486
  for r, d, l in zip(ranks, downloads, likes)],
487
  textposition='auto',
@@ -498,10 +499,12 @@ def get_models_data(progress=gr.Progress()):
498
  'yanchor': 'top'
499
  },
500
  xaxis_title='Model ID',
501
- yaxis_title='Global Rank',
502
  yaxis=dict(
503
- ticktext=[f"#{i}" for i in range(1, 1001, 50)],
504
- tickvals=[1001 - i for i in range(1, 1001, 50)],
 
 
505
  range=[0, 1000]
506
  ),
507
  height=800,
 
322
  def get_all_models(limit=1000):
323
  """๋ชจ๋“  ๋ชจ๋ธ๊ณผ Korea ๊ด€๋ จ ๋ชจ๋ธ ๊ฐ€์ ธ์˜ค๊ธฐ"""
324
  all_models = []
325
+ existing_ids = set()
326
 
327
+ # 1. Korea ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ ๊ฐ€์ ธ์˜ค๊ธฐ
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
328
  korea_params = {
329
  "search": "korea",
330
  "full": "True",
 
340
 
341
  if korea_response.status_code == 200:
342
  korea_models = korea_response.json()
343
+ print(f"Found {len(korea_models)} Korea-related models")
 
 
 
344
  for model in korea_models:
345
+ model_id = model.get('id', '')
346
+ if model_id not in existing_ids:
347
  all_models.append(model)
348
+ existing_ids.add(model_id)
349
 
350
+ # 2. Korean ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ ๊ฐ€์ ธ์˜ค๊ธฐ
351
  korean_params = {
352
  "search": "korean",
353
  "full": "True",
 
363
 
364
  if korean_response.status_code == 200:
365
  korean_models = korean_response.json()
366
+ print(f"Found {len(korean_models)} Korean-related models")
 
 
367
  for model in korean_models:
368
+ model_id = model.get('id', '')
369
+ if model_id not in existing_ids:
370
  all_models.append(model)
371
+ existing_ids.add(model_id)
372
+
373
+ # 3. ์ผ๋ฐ˜ ๋ชจ๋ธ ๋ฆฌ์ŠคํŠธ ๊ฐ€์ ธ์˜ค๊ธฐ
374
+ params = {
375
+ "limit": limit,
376
+ "full": "True",
377
+ "config": "True"
378
+ }
379
+
380
+ response = requests.get(
381
+ "https://huggingface.co/api/models",
382
+ headers={'Accept': 'application/json'},
383
+ params=params
384
+ )
385
+
386
+ if response.status_code == 200:
387
+ general_models = response.json()
388
+ for model in general_models:
389
+ model_id = model.get('id', '')
390
+ if model_id not in existing_ids:
391
+ all_models.append(model)
392
+ existing_ids.add(model_id)
393
 
394
  print(f"Total unique models: {len(all_models)}")
395
  return all_models[:limit]
 
478
  likes = [m['likes'] for m in valid_models]
479
  downloads = [m['downloads'] for m in valid_models]
480
 
481
+ # ๋ง‰๋Œ€ ๊ทธ๋ž˜ํ”„ ์ƒ์„ฑ (๊ฐ ์ˆœ์œ„์—์„œ 1000๊นŒ์ง€์˜ ๊ธธ์ด๋กœ ๋ง‰๋Œ€ ์ƒ์„ฑ)
 
 
482
  fig.add_trace(go.Bar(
483
  x=ids,
484
+ y=ranks, # ์‹ค์ œ ์ˆœ์œ„ ์‚ฌ์šฉ
485
+ base=1000, # ๋ง‰๋Œ€์˜ ๊ธฐ์ค€์ ์„ 1000์œผ๋กœ ์„ค์ •
486
  text=[f"Global Rank: #{r}<br>Downloads: {format(d, ',')}<br>Likes: {format(l, ',')}"
487
  for r, d, l in zip(ranks, downloads, likes)],
488
  textposition='auto',
 
499
  'yanchor': 'top'
500
  },
501
  xaxis_title='Model ID',
502
+ yaxis_title='Rank',
503
  yaxis=dict(
504
+ autorange='reversed', # Y์ถ•์„ ๋ฐ˜์ „
505
+ tickmode='linear',
506
+ tick0=0,
507
+ dtick=50,
508
  range=[0, 1000]
509
  ),
510
  height=800,