Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -437,22 +437,20 @@ def get_trending_spaces(progress=gr.Progress()) -> Tuple[str, str]:
|
|
437 |
progress(0, desc="Fetching spaces data...")
|
438 |
params = {
|
439 |
'full': 'true',
|
440 |
-
'limit': 10
|
|
|
441 |
}
|
442 |
response = requests.get(url, params=params)
|
443 |
response.raise_for_status()
|
444 |
spaces = response.json()
|
445 |
|
446 |
-
# μμ 10κ°λ§ μ ν
|
447 |
-
top_spaces = spaces[:10]
|
448 |
-
|
449 |
progress(0.1, desc="Creating gallery...")
|
450 |
html_content = """
|
451 |
<div style='padding: 20px; background: #f5f5f5;'>
|
452 |
<div style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;'>
|
453 |
"""
|
454 |
|
455 |
-
for idx, space in enumerate(
|
456 |
html_content += get_card(space, idx, "space")
|
457 |
progress((0.1 + 0.9 * idx/10), desc=f"Loading space {idx+1}/10...")
|
458 |
|
@@ -471,34 +469,23 @@ def get_models(progress=gr.Progress()) -> Tuple[str, str]:
|
|
471 |
|
472 |
try:
|
473 |
progress(0, desc="Fetching models data...")
|
474 |
-
|
|
|
|
|
|
|
|
|
|
|
475 |
response.raise_for_status()
|
476 |
models = response.json()
|
477 |
|
478 |
-
# μμ 10κ°λ§ μ ν
|
479 |
-
top_models = models[:10]
|
480 |
-
|
481 |
progress(0.1, desc="Creating gallery...")
|
482 |
-
|
483 |
html_content = """
|
484 |
<div style='padding: 20px; background: #f5f5f5;'>
|
485 |
<div style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;'>
|
486 |
"""
|
487 |
|
488 |
-
for idx, model in enumerate(
|
489 |
-
model_id = model.get('id', '')
|
490 |
-
author = model_id.split('/')[0]
|
491 |
-
title = model_id.split('/')[-1]
|
492 |
-
likes = format(model.get('likes', 0), ',')
|
493 |
-
downloads = format(model.get('downloads', 0), ',')
|
494 |
-
created = model.get('createdAt', '').split('T')[0]
|
495 |
-
url = f"https://huggingface.co/{model_id}"
|
496 |
-
|
497 |
-
screenshot = get_cached_screenshot(url)
|
498 |
html_content += get_card(model, idx, "model")
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
progress((0.1 + 0.9 * idx/10), desc=f"Loading model {idx+1}/10...")
|
503 |
|
504 |
html_content += "</div></div>"
|
@@ -516,33 +503,23 @@ def get_datasets(progress=gr.Progress()) -> Tuple[str, str]:
|
|
516 |
|
517 |
try:
|
518 |
progress(0, desc="Fetching datasets data...")
|
519 |
-
|
|
|
|
|
|
|
|
|
|
|
520 |
response.raise_for_status()
|
521 |
datasets = response.json()
|
522 |
|
523 |
-
# μμ 10κ°λ§ μ ν
|
524 |
-
top_datasets = datasets[:10]
|
525 |
-
|
526 |
progress(0.1, desc="Creating gallery...")
|
527 |
html_content = """
|
528 |
<div style='padding: 20px; background: #f5f5f5;'>
|
529 |
<div style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;'>
|
530 |
"""
|
531 |
|
532 |
-
for idx, dataset in enumerate(
|
533 |
-
dataset_id = dataset.get('id', '')
|
534 |
-
author = dataset_id.split('/')[0]
|
535 |
-
title = dataset_id.split('/')[-1]
|
536 |
-
likes = format(dataset.get('likes', 0), ',')
|
537 |
-
downloads = format(dataset.get('downloads', 0), ',')
|
538 |
-
created = dataset.get('createdAt', '').split('T')[0]
|
539 |
-
url = f"https://huggingface.co/datasets/{dataset_id}"
|
540 |
-
|
541 |
-
screenshot = get_cached_screenshot(url)
|
542 |
html_content += get_card(dataset, idx, "dataset")
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
progress((0.1 + 0.9 * idx/10), desc=f"Loading dataset {idx+1}/10...")
|
547 |
|
548 |
html_content += "</div></div>"
|
@@ -562,7 +539,7 @@ def create_interface():
|
|
562 |
with gr.Tabs() as tabs:
|
563 |
# Spaces ν
|
564 |
with gr.Tab("π― Trending Spaces"):
|
565 |
-
gr.Markdown("Shows top
|
566 |
with gr.Row():
|
567 |
spaces_refresh_btn = gr.Button("Refresh Spaces", variant="primary")
|
568 |
spaces_gallery = gr.HTML()
|
@@ -570,7 +547,7 @@ def create_interface():
|
|
570 |
|
571 |
# Models ν
|
572 |
with gr.Tab("π€ Trending Models"):
|
573 |
-
gr.Markdown("Shows top 10 trending models
|
574 |
with gr.Row():
|
575 |
models_refresh_btn = gr.Button("Refresh Models", variant="primary")
|
576 |
models_gallery = gr.HTML()
|
@@ -578,7 +555,7 @@ def create_interface():
|
|
578 |
|
579 |
# Datasets ν
|
580 |
with gr.Tab("π Trending Datasets"):
|
581 |
-
gr.Markdown("Shows top 10 trending datasets
|
582 |
with gr.Row():
|
583 |
datasets_refresh_btn = gr.Button("Refresh Datasets", variant="primary")
|
584 |
datasets_gallery = gr.HTML()
|
|
|
437 |
progress(0, desc="Fetching spaces data...")
|
438 |
params = {
|
439 |
'full': 'true',
|
440 |
+
'limit': 10, # μμ 10κ°λ§ κ°μ Έμ€λλ‘ μμ
|
441 |
+
'sort': 'likes' # μ’μμ μμΌλ‘ μ λ ¬
|
442 |
}
|
443 |
response = requests.get(url, params=params)
|
444 |
response.raise_for_status()
|
445 |
spaces = response.json()
|
446 |
|
|
|
|
|
|
|
447 |
progress(0.1, desc="Creating gallery...")
|
448 |
html_content = """
|
449 |
<div style='padding: 20px; background: #f5f5f5;'>
|
450 |
<div style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;'>
|
451 |
"""
|
452 |
|
453 |
+
for idx, space in enumerate(spaces):
|
454 |
html_content += get_card(space, idx, "space")
|
455 |
progress((0.1 + 0.9 * idx/10), desc=f"Loading space {idx+1}/10...")
|
456 |
|
|
|
469 |
|
470 |
try:
|
471 |
progress(0, desc="Fetching models data...")
|
472 |
+
params = {
|
473 |
+
'full': 'true',
|
474 |
+
'limit': 10, # μμ 10κ°λ§ κ°μ Έμ€λλ‘ μμ
|
475 |
+
'sort': 'likes' # μ’μμ μμΌλ‘ μ λ ¬
|
476 |
+
}
|
477 |
+
response = requests.get(url, params=params)
|
478 |
response.raise_for_status()
|
479 |
models = response.json()
|
480 |
|
|
|
|
|
|
|
481 |
progress(0.1, desc="Creating gallery...")
|
|
|
482 |
html_content = """
|
483 |
<div style='padding: 20px; background: #f5f5f5;'>
|
484 |
<div style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;'>
|
485 |
"""
|
486 |
|
487 |
+
for idx, model in enumerate(models):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
488 |
html_content += get_card(model, idx, "model")
|
|
|
|
|
|
|
489 |
progress((0.1 + 0.9 * idx/10), desc=f"Loading model {idx+1}/10...")
|
490 |
|
491 |
html_content += "</div></div>"
|
|
|
503 |
|
504 |
try:
|
505 |
progress(0, desc="Fetching datasets data...")
|
506 |
+
params = {
|
507 |
+
'full': 'true',
|
508 |
+
'limit': 10, # μμ 10κ°λ§ κ°μ Έμ€λλ‘ μμ
|
509 |
+
'sort': 'likes' # μ’μμ μμΌλ‘ μ λ ¬
|
510 |
+
}
|
511 |
+
response = requests.get(url, params=params)
|
512 |
response.raise_for_status()
|
513 |
datasets = response.json()
|
514 |
|
|
|
|
|
|
|
515 |
progress(0.1, desc="Creating gallery...")
|
516 |
html_content = """
|
517 |
<div style='padding: 20px; background: #f5f5f5;'>
|
518 |
<div style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;'>
|
519 |
"""
|
520 |
|
521 |
+
for idx, dataset in enumerate(datasets):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
522 |
html_content += get_card(dataset, idx, "dataset")
|
|
|
|
|
|
|
523 |
progress((0.1 + 0.9 * idx/10), desc=f"Loading dataset {idx+1}/10...")
|
524 |
|
525 |
html_content += "</div></div>"
|
|
|
539 |
with gr.Tabs() as tabs:
|
540 |
# Spaces ν
|
541 |
with gr.Tab("π― Trending Spaces"):
|
542 |
+
gr.Markdown("Shows top 10 trending spaces with AI ratings")
|
543 |
with gr.Row():
|
544 |
spaces_refresh_btn = gr.Button("Refresh Spaces", variant="primary")
|
545 |
spaces_gallery = gr.HTML()
|
|
|
547 |
|
548 |
# Models ν
|
549 |
with gr.Tab("π€ Trending Models"):
|
550 |
+
gr.Markdown("Shows top 10 trending models with AI ratings")
|
551 |
with gr.Row():
|
552 |
models_refresh_btn = gr.Button("Refresh Models", variant="primary")
|
553 |
models_gallery = gr.HTML()
|
|
|
555 |
|
556 |
# Datasets ν
|
557 |
with gr.Tab("π Trending Datasets"):
|
558 |
+
gr.Markdown("Shows top 10 trending datasets with AI ratings")
|
559 |
with gr.Row():
|
560 |
datasets_refresh_btn = gr.Button("Refresh Datasets", variant="primary")
|
561 |
datasets_gallery = gr.HTML()
|