Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -444,30 +444,34 @@ def get_trending_spaces(search_query="", sort_by="rank", progress=gr.Progress())
|
|
444 |
progress(0, desc="Fetching spaces data...")
|
445 |
params = {
|
446 |
'full': 'true',
|
447 |
-
'limit':
|
448 |
-
'search': search_query
|
449 |
}
|
450 |
|
451 |
response = requests.get(url, params=params)
|
452 |
response.raise_for_status()
|
453 |
spaces = response.json()
|
454 |
|
455 |
-
# ๊ฒ์์ด๋ก ํํฐ๋ง
|
456 |
if search_query:
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
|
|
|
|
|
|
|
|
|
|
471 |
|
472 |
progress(0.1, desc="Creating gallery...")
|
473 |
html_content = """
|
@@ -496,29 +500,33 @@ def get_models(search_query="", sort_by="rank", progress=gr.Progress()) -> Tuple
|
|
496 |
progress(0, desc="Fetching models data...")
|
497 |
params = {
|
498 |
'full': 'true',
|
499 |
-
'limit':
|
500 |
-
'search': search_query
|
501 |
}
|
502 |
response = requests.get(url, params=params)
|
503 |
response.raise_for_status()
|
504 |
models = response.json()
|
505 |
|
506 |
-
# ๊ฒ์์ด๋ก ํํฐ๋ง
|
507 |
if search_query:
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
|
|
|
|
|
|
|
|
|
|
522 |
|
523 |
progress(0.1, desc="Creating gallery...")
|
524 |
html_content = """
|
@@ -547,29 +555,33 @@ def get_datasets(search_query="", sort_by="rank", progress=gr.Progress()) -> Tup
|
|
547 |
progress(0, desc="Fetching datasets data...")
|
548 |
params = {
|
549 |
'full': 'true',
|
550 |
-
'limit':
|
551 |
-
'search': search_query
|
552 |
}
|
553 |
response = requests.get(url, params=params)
|
554 |
response.raise_for_status()
|
555 |
datasets = response.json()
|
556 |
|
557 |
-
# ๊ฒ์์ด๋ก ํํฐ๋ง
|
558 |
if search_query:
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
|
|
|
|
|
|
|
|
|
|
573 |
|
574 |
progress(0.1, desc="Creating gallery...")
|
575 |
html_content = """
|
|
|
444 |
progress(0, desc="Fetching spaces data...")
|
445 |
params = {
|
446 |
'full': 'true',
|
447 |
+
'limit': 10 # ๊ธฐ๋ณธ 300๊ฐ ์ ์ง
|
|
|
448 |
}
|
449 |
|
450 |
response = requests.get(url, params=params)
|
451 |
response.raise_for_status()
|
452 |
spaces = response.json()
|
453 |
|
454 |
+
# ๊ฒ์์ด๋ก ํํฐ๋ง (๊ฒ์์ด๊ฐ ์๋ ๊ฒฝ์ฐ์๋ง)
|
455 |
if search_query:
|
456 |
+
filtered_spaces = []
|
457 |
+
# ์ถ๊ฐ ๋ฐ์ดํฐ ๊ฐ์ ธ์ค๊ธฐ (๊ฒ์์ฉ)
|
458 |
+
params['limit'] = 1000
|
459 |
+
response = requests.get(url, params=params)
|
460 |
+
all_spaces = response.json()
|
461 |
+
|
462 |
+
filtered_spaces = [space for space in all_spaces if search_query.lower() in
|
463 |
+
(space.get('id', '') + space.get('title', '')).lower()]
|
464 |
+
spaces = filtered_spaces[:300] # ์์ 300๊ฐ๋ง ์ ์ง
|
465 |
+
|
466 |
+
# ์ ๋ ฌ (rank๊ฐ ์๋ ๊ฒฝ์ฐ์๋ง)
|
467 |
+
if sort_by != "rank": # rank์ธ ๊ฒฝ์ฐ ๊ธฐ์กด ์์ ์ ์ง
|
468 |
+
if sort_by == "rising_rate":
|
469 |
+
spaces.sort(key=lambda x: calculate_rising_rate(x.get('createdAt', ''), 0), reverse=True)
|
470 |
+
elif sort_by == "popularity":
|
471 |
+
spaces.sort(key=lambda x: get_popularity_grade(
|
472 |
+
int(str(x.get('likes', '0')).replace(',', '')),
|
473 |
+
calculate_rising_rate(x.get('createdAt', ''), 0))[1],
|
474 |
+
reverse=True)
|
475 |
|
476 |
progress(0.1, desc="Creating gallery...")
|
477 |
html_content = """
|
|
|
500 |
progress(0, desc="Fetching models data...")
|
501 |
params = {
|
502 |
'full': 'true',
|
503 |
+
'limit': 300 # ๊ธฐ๋ณธ 300๊ฐ ์ ์ง
|
|
|
504 |
}
|
505 |
response = requests.get(url, params=params)
|
506 |
response.raise_for_status()
|
507 |
models = response.json()
|
508 |
|
509 |
+
# ๊ฒ์์ด๋ก ํํฐ๋ง (๊ฒ์์ด๊ฐ ์๋ ๊ฒฝ์ฐ์๋ง)
|
510 |
if search_query:
|
511 |
+
filtered_models = []
|
512 |
+
# ์ถ๊ฐ ๋ฐ์ดํฐ ๊ฐ์ ธ์ค๊ธฐ (๊ฒ์์ฉ)
|
513 |
+
params['limit'] = 1000
|
514 |
+
response = requests.get(url, params=params)
|
515 |
+
all_models = response.json()
|
516 |
+
|
517 |
+
filtered_models = [model for model in all_models if search_query.lower() in
|
518 |
+
(model.get('id', '') + model.get('title', '')).lower()]
|
519 |
+
models = filtered_models[:300] # ์์ 300๊ฐ๋ง ์ ์ง
|
520 |
+
|
521 |
+
# ์ ๋ ฌ (rank๊ฐ ์๋ ๊ฒฝ์ฐ์๋ง)
|
522 |
+
if sort_by != "rank": # rank์ธ ๊ฒฝ์ฐ ๊ธฐ์กด ์์ ์ ์ง
|
523 |
+
if sort_by == "rising_rate":
|
524 |
+
models.sort(key=lambda x: calculate_rising_rate(x.get('createdAt', ''), 0), reverse=True)
|
525 |
+
elif sort_by == "popularity":
|
526 |
+
models.sort(key=lambda x: get_popularity_grade(
|
527 |
+
int(str(x.get('likes', '0')).replace(',', '')),
|
528 |
+
calculate_rising_rate(x.get('createdAt', ''), 0))[1],
|
529 |
+
reverse=True)
|
530 |
|
531 |
progress(0.1, desc="Creating gallery...")
|
532 |
html_content = """
|
|
|
555 |
progress(0, desc="Fetching datasets data...")
|
556 |
params = {
|
557 |
'full': 'true',
|
558 |
+
'limit': 300 # ๊ธฐ๋ณธ 300๊ฐ ์ ์ง
|
|
|
559 |
}
|
560 |
response = requests.get(url, params=params)
|
561 |
response.raise_for_status()
|
562 |
datasets = response.json()
|
563 |
|
564 |
+
# ๊ฒ์์ด๋ก ํํฐ๋ง (๊ฒ์์ด๊ฐ ์๋ ๊ฒฝ์ฐ์๋ง)
|
565 |
if search_query:
|
566 |
+
filtered_datasets = []
|
567 |
+
# ์ถ๊ฐ ๋ฐ์ดํฐ ๊ฐ์ ธ์ค๊ธฐ (๊ฒ์์ฉ)
|
568 |
+
params['limit'] = 1000
|
569 |
+
response = requests.get(url, params=params)
|
570 |
+
all_datasets = response.json()
|
571 |
+
|
572 |
+
filtered_datasets = [dataset for dataset in all_datasets if search_query.lower() in
|
573 |
+
(dataset.get('id', '') + dataset.get('title', '')).lower()]
|
574 |
+
datasets = filtered_datasets[:300] # ์์ 300๊ฐ๋ง ์ ์ง
|
575 |
+
|
576 |
+
# ์ ๋ ฌ (rank๊ฐ ์๋ ๊ฒฝ์ฐ์๋ง)
|
577 |
+
if sort_by != "rank": # rank์ธ ๊ฒฝ์ฐ ๊ธฐ์กด ์์ ์ ์ง
|
578 |
+
if sort_by == "rising_rate":
|
579 |
+
datasets.sort(key=lambda x: calculate_rising_rate(x.get('createdAt', ''), 0), reverse=True)
|
580 |
+
elif sort_by == "popularity":
|
581 |
+
datasets.sort(key=lambda x: get_popularity_grade(
|
582 |
+
int(str(x.get('likes', '0')).replace(',', '')),
|
583 |
+
calculate_rising_rate(x.get('createdAt', ''), 0))[1],
|
584 |
+
reverse=True)
|
585 |
|
586 |
progress(0.1, desc="Creating gallery...")
|
587 |
html_content = """
|