Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -466,34 +466,27 @@ def get_trending_spaces(search_query="", sort_by="rank", progress=gr.Progress())
|
|
466 |
progress(0, desc="Fetching spaces data...")
|
467 |
params = {
|
468 |
'full': 'true',
|
469 |
-
'limit': 10
|
470 |
}
|
471 |
|
472 |
response = requests.get(url, params=params)
|
473 |
response.raise_for_status()
|
474 |
spaces = response.json()
|
475 |
|
476 |
-
# ๊ฒ์์ด๋ก ํํฐ๋ง
|
477 |
if search_query:
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
spaces
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
if sort_by == "rising_rate":
|
491 |
-
spaces.sort(key=lambda x: calculate_rising_rate(x.get('createdAt', ''), 0), reverse=True)
|
492 |
-
elif sort_by == "popularity":
|
493 |
-
spaces.sort(key=lambda x: get_popularity_grade(
|
494 |
-
int(str(x.get('likes', '0')).replace(',', '')),
|
495 |
-
calculate_rising_rate(x.get('createdAt', ''), 0))[1],
|
496 |
-
reverse=True)
|
497 |
|
498 |
progress(0.1, desc="Creating gallery...")
|
499 |
html_content = """
|
@@ -522,33 +515,26 @@ def get_models(search_query="", sort_by="rank", progress=gr.Progress()) -> Tuple
|
|
522 |
progress(0, desc="Fetching models data...")
|
523 |
params = {
|
524 |
'full': 'true',
|
525 |
-
'limit': 300
|
526 |
}
|
527 |
response = requests.get(url, params=params)
|
528 |
response.raise_for_status()
|
529 |
models = response.json()
|
530 |
|
531 |
-
# ๊ฒ์์ด๋ก ํํฐ๋ง
|
532 |
if search_query:
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
models
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
if sort_by == "rising_rate":
|
546 |
-
models.sort(key=lambda x: calculate_rising_rate(x.get('createdAt', ''), 0), reverse=True)
|
547 |
-
elif sort_by == "popularity":
|
548 |
-
models.sort(key=lambda x: get_popularity_grade(
|
549 |
-
int(str(x.get('likes', '0')).replace(',', '')),
|
550 |
-
calculate_rising_rate(x.get('createdAt', ''), 0))[1],
|
551 |
-
reverse=True)
|
552 |
|
553 |
progress(0.1, desc="Creating gallery...")
|
554 |
html_content = """
|
@@ -577,33 +563,26 @@ def get_datasets(search_query="", sort_by="rank", progress=gr.Progress()) -> Tup
|
|
577 |
progress(0, desc="Fetching datasets data...")
|
578 |
params = {
|
579 |
'full': 'true',
|
580 |
-
'limit': 300
|
581 |
}
|
582 |
response = requests.get(url, params=params)
|
583 |
response.raise_for_status()
|
584 |
datasets = response.json()
|
585 |
|
586 |
-
# ๊ฒ์์ด๋ก ํํฐ๋ง
|
587 |
if search_query:
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
datasets
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
if sort_by == "rising_rate":
|
601 |
-
datasets.sort(key=lambda x: calculate_rising_rate(x.get('createdAt', ''), 0), reverse=True)
|
602 |
-
elif sort_by == "popularity":
|
603 |
-
datasets.sort(key=lambda x: get_popularity_grade(
|
604 |
-
int(str(x.get('likes', '0')).replace(',', '')),
|
605 |
-
calculate_rising_rate(x.get('createdAt', ''), 0))[1],
|
606 |
-
reverse=True)
|
607 |
|
608 |
progress(0.1, desc="Creating gallery...")
|
609 |
html_content = """
|
@@ -671,7 +650,7 @@ def create_interface():
|
|
671 |
padding: 20px;
|
672 |
margin: 10px 0;
|
673 |
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
674 |
-
overflow: visible;
|
675 |
}
|
676 |
.search-box {
|
677 |
border: 2px solid #e1e1e1;
|
@@ -686,79 +665,6 @@ def create_interface():
|
|
686 |
box-shadow: 0 0 0 2px rgba(123,97,255,0.2);
|
687 |
background: linear-gradient(135deg, #ffffff, #f0f3ff);
|
688 |
}
|
689 |
-
/* ์ ๋ ฌ ๋ฒํผ ์ปจํ
์ด๋ ์์ */
|
690 |
-
.sort-radio {
|
691 |
-
display: inline-flex !important;
|
692 |
-
gap: 15px !important;
|
693 |
-
background: transparent !important;
|
694 |
-
padding: 0 !important;
|
695 |
-
overflow: visible !important; /* ์คํฌ๋กค๋ฐ ์ ๊ฑฐ */
|
696 |
-
width: auto !important;
|
697 |
-
min-width: 390px !important; /* 3๊ฐ ๋ฒํผ + ๊ฐ๊ฒฉ */
|
698 |
-
}
|
699 |
-
|
700 |
-
/* ๋ผ๋์ค ๋ฒํผ ๊ทธ๋ฃน ์ปจํ
์ด๋ */
|
701 |
-
.sort-radio > div {
|
702 |
-
display: flex !important;
|
703 |
-
gap: 15px !important;
|
704 |
-
overflow: visible !important; /* ์คํฌ๋กค๋ฐ ์ ๊ฑฐ */
|
705 |
-
}
|
706 |
-
|
707 |
-
/* ๊ฐ ๋ผ๋์ค ๋ฒํผ ํญ๋ชฉ */
|
708 |
-
.sort-radio > div > div {
|
709 |
-
width: 120px !important;
|
710 |
-
height: 80px !important;
|
711 |
-
}
|
712 |
-
|
713 |
-
/* ๋ผ๋์ค ๋ฒํผ์ ๋ฒํผ์ฒ๋ผ ์คํ์ผ๋ง */
|
714 |
-
.sort-radio label {
|
715 |
-
width: 120px !important;
|
716 |
-
height: 80px !important;
|
717 |
-
display: flex !important;
|
718 |
-
align-items: center !important;
|
719 |
-
justify-content: center !important;
|
720 |
-
color: white !important;
|
721 |
-
border: none !important;
|
722 |
-
border-radius: 10px !important;
|
723 |
-
cursor: pointer !important;
|
724 |
-
transition: all 0.3s ease !important;
|
725 |
-
font-size: 1.1em !important;
|
726 |
-
text-align: center !important;
|
727 |
-
padding: 10px !important;
|
728 |
-
box-shadow: 0 4px 6px rgba(0,0,0,0.1) !important;
|
729 |
-
white-space: normal !important; /* ํ
์คํธ ์ค๋ฐ๊ฟ ํ์ฉ */
|
730 |
-
word-break: break-word !important; /* ๊ธด ๋จ์ด ์ค๋ฐ๊ฟ */
|
731 |
-
line-height: 1.2 !important; /* ์ค๊ฐ๊ฒฉ ์กฐ์ */
|
732 |
-
}
|
733 |
-
|
734 |
-
/* ์ฒซ ๋ฒ์งธ ๋ฒํผ (rank) */
|
735 |
-
.sort-radio > div > div:nth-child(1) label {
|
736 |
-
background: linear-gradient(135deg, #4CAF50, #45a049) !important;
|
737 |
-
}
|
738 |
-
|
739 |
-
/* ๋ ๋ฒ์งธ ๋ฒํผ (rising_rate) */
|
740 |
-
.sort-radio > div > div:nth-child(2) label {
|
741 |
-
background: linear-gradient(135deg, #2196F3, #1976D2) !important;
|
742 |
-
}
|
743 |
-
|
744 |
-
/* ์ธ ๋ฒ์งธ ๋ฒํผ (popularity) */
|
745 |
-
.sort-radio > div > div:nth-child(3) label {
|
746 |
-
background: linear-gradient(135deg, #9C27B0, #7B1FA2) !important;
|
747 |
-
}
|
748 |
-
|
749 |
-
/* ํธ๋ฒ ํจ๊ณผ */
|
750 |
-
.sort-radio label:hover {
|
751 |
-
transform: translateY(-2px) !important;
|
752 |
-
box-shadow: 0 6px 12px rgba(0,0,0,0.2) !important;
|
753 |
-
}
|
754 |
-
|
755 |
-
/* ์ ํ๋ ๋ฒํผ ์คํ์ผ */
|
756 |
-
.sort-radio input:checked + label {
|
757 |
-
box-shadow: inset 0 2px 4px rgba(0,0,0,0.2) !important;
|
758 |
-
transform: translateY(1px) !important;
|
759 |
-
}
|
760 |
-
|
761 |
-
/* ๋ฆฌํ๋ ์ ๋ฒํผ ์คํ์ผ */
|
762 |
.refresh-btn {
|
763 |
background: linear-gradient(135deg, #7b61ff, #6366f1);
|
764 |
color: white;
|
@@ -776,7 +682,6 @@ def create_interface():
|
|
776 |
font-size: 1.2em !important;
|
777 |
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
778 |
}
|
779 |
-
|
780 |
.refresh-btn:hover {
|
781 |
transform: translateY(-2px);
|
782 |
box-shadow: 0 6px 12px rgba(0,0,0,0.2);
|
@@ -794,7 +699,6 @@ def create_interface():
|
|
794 |
with gr.Tabs() as tabs:
|
795 |
# Spaces ํญ
|
796 |
with gr.Tab("๐ฏ Trending Spaces"):
|
797 |
-
|
798 |
with gr.Row(elem_classes="search-sort-container"):
|
799 |
with gr.Column(scale=2):
|
800 |
spaces_search = gr.Textbox(
|
@@ -804,13 +708,11 @@ def create_interface():
|
|
804 |
)
|
805 |
with gr.Column(scale=2):
|
806 |
spaces_sort = gr.Radio(
|
807 |
-
choices=["
|
808 |
-
value="
|
809 |
-
label="
|
810 |
-
interactive=True
|
811 |
-
elem_classes="sort-radio"
|
812 |
)
|
813 |
-
|
814 |
with gr.Column(scale=1):
|
815 |
spaces_refresh_btn = gr.Button(
|
816 |
"๐ Refresh",
|
@@ -822,7 +724,6 @@ def create_interface():
|
|
822 |
|
823 |
# Models ํญ
|
824 |
with gr.Tab("๐ค Trending Models"):
|
825 |
-
|
826 |
with gr.Row(elem_classes="search-sort-container"):
|
827 |
with gr.Column(scale=2):
|
828 |
models_search = gr.Textbox(
|
@@ -834,9 +735,8 @@ def create_interface():
|
|
834 |
models_sort = gr.Radio(
|
835 |
choices=["rank", "rising_rate", "popularity"],
|
836 |
value="rank",
|
837 |
-
label="
|
838 |
-
interactive=True
|
839 |
-
elem_classes="sort-radio"
|
840 |
)
|
841 |
with gr.Column(scale=1):
|
842 |
models_refresh_btn = gr.Button(
|
@@ -849,7 +749,6 @@ def create_interface():
|
|
849 |
|
850 |
# Datasets ํญ
|
851 |
with gr.Tab("๐ Trending Datasets"):
|
852 |
-
|
853 |
with gr.Row(elem_classes="search-sort-container"):
|
854 |
with gr.Column(scale=2):
|
855 |
datasets_search = gr.Textbox(
|
@@ -861,9 +760,8 @@ def create_interface():
|
|
861 |
datasets_sort = gr.Radio(
|
862 |
choices=["rank", "rising_rate", "popularity"],
|
863 |
value="rank",
|
864 |
-
label="
|
865 |
-
interactive=True
|
866 |
-
elem_classes="sort-radio"
|
867 |
)
|
868 |
with gr.Column(scale=1):
|
869 |
datasets_refresh_btn = gr.Button(
|
|
|
466 |
progress(0, desc="Fetching spaces data...")
|
467 |
params = {
|
468 |
'full': 'true',
|
469 |
+
'limit': 10
|
470 |
}
|
471 |
|
472 |
response = requests.get(url, params=params)
|
473 |
response.raise_for_status()
|
474 |
spaces = response.json()
|
475 |
|
476 |
+
# ๊ฒ์์ด๋ก ํํฐ๋ง
|
477 |
if search_query:
|
478 |
+
spaces = [space for space in spaces if search_query.lower() in
|
479 |
+
(space.get('id', '') + ' ' + space.get('title', '')).lower()]
|
480 |
+
|
481 |
+
# ์ ๋ ฌ
|
482 |
+
sort_by = sort_by.lower()
|
483 |
+
if sort_by == "rising_rate":
|
484 |
+
spaces.sort(key=lambda x: calculate_rising_rate(x.get('createdAt', ''), 0), reverse=True)
|
485 |
+
elif sort_by == "popularity":
|
486 |
+
spaces.sort(key=lambda x: get_popularity_grade(
|
487 |
+
int(str(x.get('likes', '0')).replace(',', '')),
|
488 |
+
calculate_rising_rate(x.get('createdAt', ''), 0))[1],
|
489 |
+
reverse=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
490 |
|
491 |
progress(0.1, desc="Creating gallery...")
|
492 |
html_content = """
|
|
|
515 |
progress(0, desc="Fetching models data...")
|
516 |
params = {
|
517 |
'full': 'true',
|
518 |
+
'limit': 300
|
519 |
}
|
520 |
response = requests.get(url, params=params)
|
521 |
response.raise_for_status()
|
522 |
models = response.json()
|
523 |
|
524 |
+
# ๊ฒ์์ด๋ก ํํฐ๋ง
|
525 |
if search_query:
|
526 |
+
models = [model for model in models if search_query.lower() in
|
527 |
+
(model.get('id', '') + ' ' + model.get('title', '')).lower()]
|
528 |
+
|
529 |
+
# ์ ๋ ฌ
|
530 |
+
sort_by = sort_by.lower()
|
531 |
+
if sort_by == "rising_rate":
|
532 |
+
models.sort(key=lambda x: calculate_rising_rate(x.get('createdAt', ''), 0), reverse=True)
|
533 |
+
elif sort_by == "popularity":
|
534 |
+
models.sort(key=lambda x: get_popularity_grade(
|
535 |
+
int(str(x.get('likes', '0')).replace(',', '')),
|
536 |
+
calculate_rising_rate(x.get('createdAt', ''), 0))[1],
|
537 |
+
reverse=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
538 |
|
539 |
progress(0.1, desc="Creating gallery...")
|
540 |
html_content = """
|
|
|
563 |
progress(0, desc="Fetching datasets data...")
|
564 |
params = {
|
565 |
'full': 'true',
|
566 |
+
'limit': 300
|
567 |
}
|
568 |
response = requests.get(url, params=params)
|
569 |
response.raise_for_status()
|
570 |
datasets = response.json()
|
571 |
|
572 |
+
# ๊ฒ์์ด๋ก ํํฐ๋ง
|
573 |
if search_query:
|
574 |
+
datasets = [dataset for dataset in datasets if search_query.lower() in
|
575 |
+
(dataset.get('id', '') + ' ' + dataset.get('title', '')).lower()]
|
576 |
+
|
577 |
+
# ์ ๋ ฌ
|
578 |
+
sort_by = sort_by.lower()
|
579 |
+
if sort_by == "rising_rate":
|
580 |
+
datasets.sort(key=lambda x: calculate_rising_rate(x.get('createdAt', ''), 0), reverse=True)
|
581 |
+
elif sort_by == "popularity":
|
582 |
+
datasets.sort(key=lambda x: get_popularity_grade(
|
583 |
+
int(str(x.get('likes', '0')).replace(',', '')),
|
584 |
+
calculate_rising_rate(x.get('createdAt', ''), 0))[1],
|
585 |
+
reverse=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
586 |
|
587 |
progress(0.1, desc="Creating gallery...")
|
588 |
html_content = """
|
|
|
650 |
padding: 20px;
|
651 |
margin: 10px 0;
|
652 |
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
653 |
+
overflow: visible;
|
654 |
}
|
655 |
.search-box {
|
656 |
border: 2px solid #e1e1e1;
|
|
|
665 |
box-shadow: 0 0 0 2px rgba(123,97,255,0.2);
|
666 |
background: linear-gradient(135deg, #ffffff, #f0f3ff);
|
667 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
668 |
.refresh-btn {
|
669 |
background: linear-gradient(135deg, #7b61ff, #6366f1);
|
670 |
color: white;
|
|
|
682 |
font-size: 1.2em !important;
|
683 |
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
684 |
}
|
|
|
685 |
.refresh-btn:hover {
|
686 |
transform: translateY(-2px);
|
687 |
box-shadow: 0 6px 12px rgba(0,0,0,0.2);
|
|
|
699 |
with gr.Tabs() as tabs:
|
700 |
# Spaces ํญ
|
701 |
with gr.Tab("๐ฏ Trending Spaces"):
|
|
|
702 |
with gr.Row(elem_classes="search-sort-container"):
|
703 |
with gr.Column(scale=2):
|
704 |
spaces_search = gr.Textbox(
|
|
|
708 |
)
|
709 |
with gr.Column(scale=2):
|
710 |
spaces_sort = gr.Radio(
|
711 |
+
choices=["rank", "rising_rate", "popularity"],
|
712 |
+
value="rank",
|
713 |
+
label="Sort by",
|
714 |
+
interactive=True
|
|
|
715 |
)
|
|
|
716 |
with gr.Column(scale=1):
|
717 |
spaces_refresh_btn = gr.Button(
|
718 |
"๐ Refresh",
|
|
|
724 |
|
725 |
# Models ํญ
|
726 |
with gr.Tab("๐ค Trending Models"):
|
|
|
727 |
with gr.Row(elem_classes="search-sort-container"):
|
728 |
with gr.Column(scale=2):
|
729 |
models_search = gr.Textbox(
|
|
|
735 |
models_sort = gr.Radio(
|
736 |
choices=["rank", "rising_rate", "popularity"],
|
737 |
value="rank",
|
738 |
+
label="Sort by",
|
739 |
+
interactive=True
|
|
|
740 |
)
|
741 |
with gr.Column(scale=1):
|
742 |
models_refresh_btn = gr.Button(
|
|
|
749 |
|
750 |
# Datasets ํญ
|
751 |
with gr.Tab("๐ Trending Datasets"):
|
|
|
752 |
with gr.Row(elem_classes="search-sort-container"):
|
753 |
with gr.Column(scale=2):
|
754 |
datasets_search = gr.Textbox(
|
|
|
760 |
datasets_sort = gr.Radio(
|
761 |
choices=["rank", "rising_rate", "popularity"],
|
762 |
value="rank",
|
763 |
+
label="Sort by",
|
764 |
+
interactive=True
|
|
|
765 |
)
|
766 |
with gr.Column(scale=1):
|
767 |
datasets_refresh_btn = gr.Button(
|