Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -87,26 +87,62 @@ def take_screenshot(url):
|
|
87 |
|
88 |
def get_hardware_info(item: dict) -> tuple:
|
89 |
"""ํ๋์จ์ด ์ ๋ณด ์ถ์ถ"""
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
elif isinstance(gpu_info, str):
|
102 |
-
gpu_info = gpu_info if gpu_info else "None"
|
103 |
-
else:
|
104 |
gpu_info = "None"
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
|
111 |
def get_card(item: dict, index: int, card_type: str = "space") -> str:
|
112 |
"""ํตํฉ ์นด๋ HTML ์์ฑ"""
|
@@ -346,19 +382,26 @@ def get_card(item: dict, index: int, card_type: str = "space") -> str:
|
|
346 |
</div>
|
347 |
</div>
|
348 |
"""
|
349 |
-
|
350 |
-
|
351 |
def get_trending_spaces(progress=gr.Progress()) -> Tuple[str, str]:
|
352 |
"""ํธ๋ ๋ฉ ์คํ์ด์ค ๊ฐ์ ธ์ค๊ธฐ"""
|
353 |
url = "https://huggingface.co/api/spaces"
|
354 |
|
355 |
try:
|
356 |
progress(0, desc="Fetching spaces data...")
|
357 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
358 |
response.raise_for_status()
|
359 |
spaces = response.json()
|
360 |
|
361 |
-
#
|
|
|
|
|
|
|
362 |
top_spaces = spaces[:10]
|
363 |
|
364 |
progress(0.1, desc="Creating gallery...")
|
|
|
87 |
|
88 |
def get_hardware_info(item: dict) -> tuple:
|
89 |
"""ํ๋์จ์ด ์ ๋ณด ์ถ์ถ"""
|
90 |
+
try:
|
91 |
+
# ๋๋ฒ๊ทธ์ฉ ์ถ๋ ฅ
|
92 |
+
print("Hardware Info:", item.get('hardware', {}))
|
93 |
+
|
94 |
+
hardware = item.get('hardware', {})
|
95 |
+
resources = item.get('resources', {}) # resources ํ๋๋ ํ์ธ
|
96 |
+
|
97 |
+
# CPU ์ ๋ณด ์ฒ๋ฆฌ
|
98 |
+
cpu_info = hardware.get('cpu', 'Standard')
|
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:
|
148 |
"""ํตํฉ ์นด๋ HTML ์์ฑ"""
|
|
|
382 |
</div>
|
383 |
</div>
|
384 |
"""
|
|
|
|
|
385 |
def get_trending_spaces(progress=gr.Progress()) -> Tuple[str, str]:
|
386 |
"""ํธ๋ ๋ฉ ์คํ์ด์ค ๊ฐ์ ธ์ค๊ธฐ"""
|
387 |
url = "https://huggingface.co/api/spaces"
|
388 |
|
389 |
try:
|
390 |
progress(0, desc="Fetching spaces data...")
|
391 |
+
# ๋ ์์ธํ ์ ๋ณด๋ฅผ ํฌํจํ๋๋ก ํ๋ผ๋ฏธํฐ ์ถ๊ฐ
|
392 |
+
params = {
|
393 |
+
'full': 'true',
|
394 |
+
'limit': 10,
|
395 |
+
'hardware': 'true'
|
396 |
+
}
|
397 |
+
response = requests.get(url, params=params)
|
398 |
response.raise_for_status()
|
399 |
spaces = response.json()
|
400 |
|
401 |
+
# ๋๋ฒ๊ทธ์ฉ ์ถ๋ ฅ
|
402 |
+
print("First space hardware info:", spaces[0].get('hardware', {}))
|
403 |
+
|
404 |
+
# ์์ 10๊ฐ๋ง ์ ํ
|
405 |
top_spaces = spaces[:10]
|
406 |
|
407 |
progress(0.1, desc="Creating gallery...")
|