Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -88,60 +88,37 @@ def take_screenshot(url):
|
|
| 88 |
def get_hardware_info(item: dict) -> tuple:
|
| 89 |
"""ํ๋์จ์ด ์ ๋ณด ์ถ์ถ"""
|
| 90 |
try:
|
| 91 |
-
#
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
hardware = item.get('hardware', {})
|
| 95 |
-
resources = item.get('resources', {}) # resources ํ๋๋ ํ์ธ
|
| 96 |
|
| 97 |
# CPU ์ ๋ณด ์ฒ๋ฆฌ
|
| 98 |
-
cpu_info =
|
| 99 |
|
| 100 |
-
# GPU ์ ๋ณด ์ฒ๋ฆฌ
|
| 101 |
gpu_info = "None"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
|
| 103 |
-
# 1. hardware.gpu์์ ํ์ธ
|
| 104 |
-
if 'gpu' in hardware:
|
| 105 |
-
gpu_data = hardware['gpu']
|
| 106 |
-
if isinstance(gpu_data, dict):
|
| 107 |
-
gpu_name = gpu_data.get('name', '')
|
| 108 |
-
gpu_memory = gpu_data.get('memory', '')
|
| 109 |
-
if gpu_name or gpu_memory:
|
| 110 |
-
gpu_info = f"{gpu_name} ({gpu_memory}GB)" if gpu_memory else gpu_name
|
| 111 |
-
elif isinstance(gpu_data, str) and gpu_data:
|
| 112 |
-
gpu_info = gpu_data
|
| 113 |
-
|
| 114 |
-
# 2. resources.gpu์์ ํ์ธ
|
| 115 |
-
if gpu_info == "None" and 'gpu' in resources:
|
| 116 |
-
gpu_data = resources['gpu']
|
| 117 |
-
if isinstance(gpu_data, dict):
|
| 118 |
-
gpu_name = gpu_data.get('name', '')
|
| 119 |
-
gpu_memory = gpu_data.get('memory', '')
|
| 120 |
-
if gpu_name or gpu_memory:
|
| 121 |
-
gpu_info = f"{gpu_name} ({gpu_memory}GB)" if gpu_memory else gpu_name
|
| 122 |
-
elif isinstance(gpu_data, str) and gpu_data:
|
| 123 |
-
gpu_info = gpu_data
|
| 124 |
-
|
| 125 |
-
# 3. runtime.gpu์์ ํ์ธ
|
| 126 |
-
runtime = item.get('runtime', {})
|
| 127 |
-
if gpu_info == "None" and 'gpu' in runtime:
|
| 128 |
-
gpu_data = runtime['gpu']
|
| 129 |
-
if isinstance(gpu_data, dict):
|
| 130 |
-
gpu_name = gpu_data.get('name', '')
|
| 131 |
-
gpu_memory = gpu_data.get('memory', '')
|
| 132 |
-
if gpu_name or gpu_memory:
|
| 133 |
-
gpu_info = f"{gpu_name} ({gpu_memory}GB)" if gpu_memory else gpu_name
|
| 134 |
-
elif isinstance(gpu_data, str) and gpu_data:
|
| 135 |
-
gpu_info = gpu_data
|
| 136 |
-
|
| 137 |
# SDK ์ ๋ณด ์ฒ๋ฆฌ
|
| 138 |
sdk = item.get('sdk', 'N/A')
|
| 139 |
|
|
|
|
|
|
|
|
|
|
| 140 |
return cpu_info, gpu_info, sdk
|
| 141 |
|
| 142 |
except Exception as e:
|
| 143 |
print(f"Error parsing hardware info: {str(e)}")
|
| 144 |
-
print(f"Item data: {item}")
|
| 145 |
return 'Standard', 'None', 'N/A'
|
| 146 |
|
| 147 |
def get_card(item: dict, index: int, card_type: str = "space") -> str:
|
|
@@ -382,6 +359,7 @@ def get_card(item: dict, index: int, card_type: str = "space") -> str:
|
|
| 382 |
</div>
|
| 383 |
</div>
|
| 384 |
"""
|
|
|
|
| 385 |
def get_trending_spaces(progress=gr.Progress()) -> Tuple[str, str]:
|
| 386 |
"""ํธ๋ ๋ฉ ์คํ์ด์ค ๊ฐ์ ธ์ค๊ธฐ"""
|
| 387 |
url = "https://huggingface.co/api/spaces"
|
|
@@ -392,17 +370,24 @@ def get_trending_spaces(progress=gr.Progress()) -> Tuple[str, str]:
|
|
| 392 |
params = {
|
| 393 |
'full': 'true',
|
| 394 |
'limit': 10,
|
| 395 |
-
'hardware': 'true'
|
|
|
|
|
|
|
|
|
|
|
|
|
| 396 |
}
|
| 397 |
-
|
|
|
|
| 398 |
response.raise_for_status()
|
| 399 |
spaces = response.json()
|
| 400 |
|
| 401 |
# ๋๋ฒ๊ทธ์ฉ ์ถ๋ ฅ
|
| 402 |
-
print("First space
|
| 403 |
|
| 404 |
# ์์ 10๊ฐ๋ง ์ ํ
|
| 405 |
top_spaces = spaces[:10]
|
|
|
|
|
|
|
| 406 |
|
| 407 |
progress(0.1, desc="Creating gallery...")
|
| 408 |
html_content = """
|
|
|
|
| 88 |
def get_hardware_info(item: dict) -> tuple:
|
| 89 |
"""ํ๋์จ์ด ์ ๋ณด ์ถ์ถ"""
|
| 90 |
try:
|
| 91 |
+
# runtime ์ ๋ณด ํ์ธ
|
| 92 |
+
runtime = item.get('runtime', {})
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
# CPU ์ ๋ณด ์ฒ๋ฆฌ
|
| 95 |
+
cpu_info = runtime.get('cpu', 'Standard')
|
| 96 |
|
| 97 |
+
# GPU ์ ๋ณด ์ฒ๋ฆฌ
|
| 98 |
gpu_info = "None"
|
| 99 |
+
if runtime.get('accelerator') == "gpu":
|
| 100 |
+
gpu_type = runtime.get('gpu', {}).get('name', '')
|
| 101 |
+
gpu_memory = runtime.get('gpu', {}).get('memory', '')
|
| 102 |
+
if gpu_type:
|
| 103 |
+
gpu_info = f"{gpu_type}"
|
| 104 |
+
if gpu_memory:
|
| 105 |
+
gpu_info += f" ({gpu_memory}GB)"
|
| 106 |
+
|
| 107 |
+
# spaces decorator ํ์ธ
|
| 108 |
+
if '@spaces.GPU' in str(item.get('sdk_version', '')):
|
| 109 |
+
if gpu_info == "None":
|
| 110 |
+
gpu_info = "GPU Enabled"
|
| 111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
# SDK ์ ๋ณด ์ฒ๋ฆฌ
|
| 113 |
sdk = item.get('sdk', 'N/A')
|
| 114 |
|
| 115 |
+
print(f"Debug - Runtime Info: {runtime}") # ๋๋ฒ๊ทธ ์ถ๋ ฅ
|
| 116 |
+
print(f"Debug - GPU Info: {gpu_info}") # ๋๋ฒ๊ทธ ์ถ๋ ฅ
|
| 117 |
+
|
| 118 |
return cpu_info, gpu_info, sdk
|
| 119 |
|
| 120 |
except Exception as e:
|
| 121 |
print(f"Error parsing hardware info: {str(e)}")
|
|
|
|
| 122 |
return 'Standard', 'None', 'N/A'
|
| 123 |
|
| 124 |
def get_card(item: dict, index: int, card_type: str = "space") -> str:
|
|
|
|
| 359 |
</div>
|
| 360 |
</div>
|
| 361 |
"""
|
| 362 |
+
|
| 363 |
def get_trending_spaces(progress=gr.Progress()) -> Tuple[str, str]:
|
| 364 |
"""ํธ๋ ๋ฉ ์คํ์ด์ค ๊ฐ์ ธ์ค๊ธฐ"""
|
| 365 |
url = "https://huggingface.co/api/spaces"
|
|
|
|
| 370 |
params = {
|
| 371 |
'full': 'true',
|
| 372 |
'limit': 10,
|
| 373 |
+
'hardware': 'true',
|
| 374 |
+
'runtime': 'true' # runtime ์ ๋ณด ํฌํจ
|
| 375 |
+
}
|
| 376 |
+
headers = {
|
| 377 |
+
'Accept': 'application/json'
|
| 378 |
}
|
| 379 |
+
|
| 380 |
+
response = requests.get(url, params=params, headers=headers)
|
| 381 |
response.raise_for_status()
|
| 382 |
spaces = response.json()
|
| 383 |
|
| 384 |
# ๋๋ฒ๊ทธ์ฉ ์ถ๋ ฅ
|
| 385 |
+
print("First space full info:", spaces[0])
|
| 386 |
|
| 387 |
# ์์ 10๊ฐ๋ง ์ ํ
|
| 388 |
top_spaces = spaces[:10]
|
| 389 |
+
|
| 390 |
+
|
| 391 |
|
| 392 |
progress(0.1, desc="Creating gallery...")
|
| 393 |
html_content = """
|