Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -107,101 +107,83 @@ def get_card(item: dict, index: int, card_type: str = "space") -> str:
|
|
107 |
gpu_memory = gpu_info.get('memory', 'N/A')
|
108 |
gpu_info = f"{gpu_type} ({gpu_memory}GB)"
|
109 |
|
110 |
-
# ์นด๋ ํ์
๋ณ
|
111 |
if card_type == "space":
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
# ์คํฌ๋ฆฐ์ท ๋ฐฐ๊ฒฝ
|
117 |
-
screenshot = get_cached_screenshot(url)
|
118 |
-
bg_content = f"""
|
119 |
-
background-image: url(data:image/png;base64,{screenshot if screenshot else ''});
|
120 |
-
background-size: cover;
|
121 |
-
background-position: center;
|
122 |
-
"""
|
123 |
-
|
124 |
-
# ํ๋์จ์ด ์ ๋ณด ์ค๋ฒ๋ ์ด
|
125 |
-
hardware_overlay = f"""
|
126 |
-
<div style='
|
127 |
-
position: absolute;
|
128 |
-
bottom: 10px;
|
129 |
-
left: 10px;
|
130 |
-
right: 10px;
|
131 |
-
background: rgba(0,0,0,0.7);
|
132 |
-
color: white;
|
133 |
-
padding: 8px 15px;
|
134 |
-
border-radius: 10px;
|
135 |
-
font-size: 0.8em;
|
136 |
-
backdrop-filter: blur(5px);
|
137 |
-
display: flex;
|
138 |
-
justify-content: space-between;
|
139 |
-
gap: 10px;'>
|
140 |
-
<span>๐ป {cpu_info}</span>
|
141 |
-
<span>๐ฎ {gpu_info}</span>
|
142 |
-
<span>๐ ๏ธ {sdk}</span>
|
143 |
-
</div>
|
144 |
"""
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
rgba(173, 216, 230, 0.7), /* ํ์คํ
๋ธ๋ฃจ */
|
151 |
-
rgba(255, 218, 185, 0.7) /* ํ์คํ
ํผ์น */
|
152 |
-
);
|
153 |
-
backdrop-filter: blur(10px);
|
154 |
"""
|
155 |
-
else:
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
bg_color = "#6e8efb" if card_type == "model" else "#ff6b6b"
|
161 |
-
content_bg = "background: #f5f5f5;"
|
162 |
-
|
163 |
-
# ํ๊ทธ ๊ธฐ๋ฐ ๋ฐฐ๊ฒฝ
|
164 |
-
bg_content = f"""
|
165 |
-
background: linear-gradient(135deg, {bg_color}, {bg_color}dd);
|
166 |
-
padding: 15px;
|
167 |
"""
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
</div>
|
192 |
-
|
193 |
-
<div style='
|
194 |
-
display: grid;
|
195 |
-
grid-template-columns: repeat(2, 1fr);
|
196 |
-
gap: 8px;
|
197 |
-
font-size: 0.9em;'>
|
198 |
-
<div>๐ป {cpu_info}</div>
|
199 |
-
<div>๐ฎ {gpu_info}</div>
|
200 |
-
{f'<div>๐ง Pipeline: {pipeline_tag}</div>' if pipeline_tag else ''}
|
201 |
-
{f'<div>๐ License: {license}</div>' if license else ''}
|
202 |
-
</div>
|
203 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
204 |
"""
|
|
|
|
|
205 |
|
206 |
return f"""
|
207 |
<div class="card" style='
|
@@ -256,7 +238,7 @@ def get_card(item: dict, index: int, card_type: str = "space") -> str:
|
|
256 |
{type_icon} {type_label}
|
257 |
</div>
|
258 |
|
259 |
-
{
|
260 |
</div>
|
261 |
|
262 |
<!-- ์ฝํ
์ธ ์์ญ -->
|
@@ -283,7 +265,6 @@ def get_card(item: dict, index: int, card_type: str = "space") -> str:
|
|
283 |
display: grid;
|
284 |
grid-template-columns: repeat(2, 1fr);
|
285 |
gap: 10px;
|
286 |
-
margin-bottom: 20px;
|
287 |
font-size: 0.9em;
|
288 |
background: rgba(255,255,255,0.3);
|
289 |
padding: 10px;
|
@@ -298,6 +279,8 @@ def get_card(item: dict, index: int, card_type: str = "space") -> str:
|
|
298 |
<span style='margin-right: 5px;'>๐
</span> {created}
|
299 |
</div>
|
300 |
</div>
|
|
|
|
|
301 |
</div>
|
302 |
</div>
|
303 |
"""
|
@@ -432,7 +415,7 @@ def create_interface():
|
|
432 |
with gr.Tabs() as tabs:
|
433 |
# Spaces ํญ
|
434 |
with gr.Tab("๐ฏ Trending Spaces"):
|
435 |
-
gr.Markdown("Shows top
|
436 |
with gr.Row():
|
437 |
spaces_refresh_btn = gr.Button("Refresh Spaces", variant="primary")
|
438 |
spaces_gallery = gr.HTML()
|
|
|
107 |
gpu_memory = gpu_info.get('memory', 'N/A')
|
108 |
gpu_info = f"{gpu_type} ({gpu_memory}GB)"
|
109 |
|
110 |
+
# ์นด๋ ํ์
๋ณ ๊ทธ๋ผ๋ฐ์ด์
์ค์
|
111 |
if card_type == "space":
|
112 |
+
gradient_colors = """
|
113 |
+
rgba(255, 182, 193, 0.7), /* ํ์คํ
ํํฌ */
|
114 |
+
rgba(173, 216, 230, 0.7), /* ํ์คํ
๋ธ๋ฃจ */
|
115 |
+
rgba(255, 218, 185, 0.7) /* ํ์คํ
ํผ์น */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
"""
|
117 |
+
elif card_type == "model":
|
118 |
+
gradient_colors = """
|
119 |
+
rgba(110, 142, 251, 0.7), /* ๋ชจ๋ธ ๋ธ๋ฃจ */
|
120 |
+
rgba(130, 158, 251, 0.7),
|
121 |
+
rgba(150, 174, 251, 0.7)
|
|
|
|
|
|
|
|
|
122 |
"""
|
123 |
+
else: # dataset
|
124 |
+
gradient_colors = """
|
125 |
+
rgba(255, 107, 107, 0.7), /* ๋ฐ์ดํฐ์
๋ ๋ */
|
126 |
+
rgba(255, 127, 127, 0.7),
|
127 |
+
rgba(255, 147, 147, 0.7)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
"""
|
129 |
+
|
130 |
+
content_bg = f"""
|
131 |
+
background: linear-gradient(135deg, {gradient_colors});
|
132 |
+
backdrop-filter: blur(10px);
|
133 |
+
"""
|
134 |
+
|
135 |
+
# ํ๋์จ์ด ์ ๋ณด HTML (๋ชจ๋ ์นด๋ ํ์
์ ๋ํด ๋์ผํ๊ฒ ์ ์ฉ)
|
136 |
+
hardware_info = f"""
|
137 |
+
<div style='
|
138 |
+
margin-top: 15px;
|
139 |
+
padding: 10px;
|
140 |
+
background: rgba(255,255,255,0.3);
|
141 |
+
border-radius: 10px;
|
142 |
+
font-size: 0.9em;'>
|
143 |
+
<div style='
|
144 |
+
display: grid;
|
145 |
+
grid-template-columns: repeat(3, 1fr);
|
146 |
+
gap: 10px;'>
|
147 |
+
<div style='color: #444;'>
|
148 |
+
<span style='margin-right: 5px;'>๐ป</span> {cpu_info}
|
149 |
+
</div>
|
150 |
+
<div style='color: #444;'>
|
151 |
+
<span style='margin-right: 5px;'>๐ฎ</span> {gpu_info}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
</div>
|
153 |
+
<div style='color: #444;'>
|
154 |
+
<span style='margin-right: 5px;'>๐ ๏ธ</span> {sdk}
|
155 |
+
</div>
|
156 |
+
</div>
|
157 |
+
</div>
|
158 |
+
"""
|
159 |
+
|
160 |
+
# ํ๊ทธ ํ์ (models์ datasets์ฉ)
|
161 |
+
if card_type != "space":
|
162 |
+
tags_html = f"""
|
163 |
+
<div style='
|
164 |
+
position: absolute;
|
165 |
+
top: 50%;
|
166 |
+
left: 50%;
|
167 |
+
transform: translate(-50%, -50%);
|
168 |
+
display: flex;
|
169 |
+
flex-wrap: wrap;
|
170 |
+
gap: 5px;
|
171 |
+
justify-content: center;
|
172 |
+
width: 90%;'>
|
173 |
+
{' '.join([f'''
|
174 |
+
<span style='
|
175 |
+
background: rgba(255,255,255,0.2);
|
176 |
+
padding: 5px 10px;
|
177 |
+
border-radius: 15px;
|
178 |
+
color: white;
|
179 |
+
font-size: 0.8em;'>
|
180 |
+
#{tag}
|
181 |
+
</span>
|
182 |
+
''' for tag in tags[:5]])}
|
183 |
+
</div>
|
184 |
"""
|
185 |
+
else:
|
186 |
+
tags_html = ""
|
187 |
|
188 |
return f"""
|
189 |
<div class="card" style='
|
|
|
238 |
{type_icon} {type_label}
|
239 |
</div>
|
240 |
|
241 |
+
{tags_html}
|
242 |
</div>
|
243 |
|
244 |
<!-- ์ฝํ
์ธ ์์ญ -->
|
|
|
265 |
display: grid;
|
266 |
grid-template-columns: repeat(2, 1fr);
|
267 |
gap: 10px;
|
|
|
268 |
font-size: 0.9em;
|
269 |
background: rgba(255,255,255,0.3);
|
270 |
padding: 10px;
|
|
|
279 |
<span style='margin-right: 5px;'>๐
</span> {created}
|
280 |
</div>
|
281 |
</div>
|
282 |
+
|
283 |
+
{hardware_info}
|
284 |
</div>
|
285 |
</div>
|
286 |
"""
|
|
|
415 |
with gr.Tabs() as tabs:
|
416 |
# Spaces ํญ
|
417 |
with gr.Tab("๐ฏ Trending Spaces"):
|
418 |
+
gr.Markdown("Shows top 300 trending spaces on Hugging Face")
|
419 |
with gr.Row():
|
420 |
spaces_refresh_btn = gr.Button("Refresh Spaces", variant="primary")
|
421 |
spaces_gallery = gr.HTML()
|