Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -96,75 +96,100 @@ def get_card(item: dict, index: int, card_type: str = "space") -> str:
|
|
96 |
tags = item.get('tags', [])
|
97 |
pipeline_tag = item.get('pipeline_tag', '')
|
98 |
license = item.get('license', '')
|
|
|
99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
# ์นด๋ ํ์
๋ณ ํน์ ์ฒ๋ฆฌ
|
101 |
if card_type == "space":
|
102 |
url = f"https://huggingface.co/spaces/{item_id}"
|
103 |
type_icon = "๐ฏ"
|
104 |
type_label = "SPACE"
|
|
|
|
|
|
|
105 |
bg_content = f"""
|
106 |
-
background-image: url(data:image/png;base64,{
|
107 |
background-size: cover;
|
108 |
background-position: center;
|
109 |
"""
|
110 |
-
meta_html = ""
|
111 |
-
else:
|
112 |
-
# models์ datasets๋ฅผ ์ํ ๋ฉํ๋ฐ์ดํฐ ํ์
|
113 |
-
url = f"https://huggingface.co/{item_id}" if card_type == "model" else f"https://huggingface.co/datasets/{item_id}"
|
114 |
-
type_icon = "๐ค" if card_type == "model" else "๐"
|
115 |
-
type_label = "MODEL" if card_type == "model" else "DATASET"
|
116 |
-
bg_color = "#6e8efb" if card_type == "model" else "#ff6b6b"
|
117 |
|
118 |
-
|
119 |
-
|
120 |
-
padding: 15px;
|
121 |
-
background: rgba(255,255,255,0.1);
|
122 |
-
border-radius: 10px;
|
123 |
-
margin-top: 10px;'>
|
124 |
-
|
125 |
-
<!-- Tags -->
|
126 |
-
<div style='
|
127 |
-
display: flex;
|
128 |
-
flex-wrap: wrap;
|
129 |
-
gap: 5px;
|
130 |
-
margin-bottom: 10px;'>
|
131 |
-
{' '.join([f'''
|
132 |
-
<span style='
|
133 |
-
background: rgba(255,255,255,0.2);
|
134 |
-
padding: 5px 10px;
|
135 |
-
border-radius: 15px;
|
136 |
-
color: white;
|
137 |
-
font-size: 0.8em;'>
|
138 |
-
#{tag}
|
139 |
-
</span>
|
140 |
-
''' for tag in tags[:5]])}
|
141 |
-
</div>
|
142 |
-
|
143 |
-
<!-- Pipeline Tag -->
|
144 |
-
{f'''
|
145 |
-
<div style='
|
146 |
-
color: white;
|
147 |
-
margin-bottom: 5px;
|
148 |
-
font-size: 0.9em;'>
|
149 |
-
๐ง Pipeline: {pipeline_tag}
|
150 |
-
</div>
|
151 |
-
''' if pipeline_tag else ''}
|
152 |
-
|
153 |
-
<!-- License -->
|
154 |
-
{f'''
|
155 |
<div style='
|
|
|
|
|
|
|
|
|
|
|
156 |
color: white;
|
157 |
-
|
158 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
</div>
|
160 |
-
''' if license else ''}
|
161 |
-
</div>
|
162 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
|
|
|
164 |
bg_content = f"""
|
165 |
background: linear-gradient(135deg, {bg_color}, {bg_color}dd);
|
166 |
padding: 15px;
|
167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
"""
|
169 |
|
170 |
return f"""
|
@@ -220,13 +245,13 @@ def get_card(item: dict, index: int, card_type: str = "space") -> str:
|
|
220 |
{type_icon} {type_label}
|
221 |
</div>
|
222 |
|
223 |
-
{
|
224 |
</div>
|
225 |
|
226 |
<!-- ์ฝํ
์ธ ์์ญ -->
|
227 |
<div style='
|
228 |
padding: 20px;
|
229 |
-
background:
|
230 |
border-radius: 0 0 20px 20px;'>
|
231 |
<h3 style='
|
232 |
margin: 0 0 15px 0;
|
|
|
96 |
tags = item.get('tags', [])
|
97 |
pipeline_tag = item.get('pipeline_tag', '')
|
98 |
license = item.get('license', '')
|
99 |
+
sdk = item.get('sdk', 'N/A')
|
100 |
|
101 |
+
# ํ๋์จ์ด ์๊ตฌ์ฌํญ ์ฒ๋ฆฌ
|
102 |
+
hardware = item.get('hardware', {})
|
103 |
+
cpu_info = hardware.get('cpu', 'Standard')
|
104 |
+
gpu_info = hardware.get('gpu', 'None')
|
105 |
+
if isinstance(gpu_info, dict):
|
106 |
+
gpu_type = gpu_info.get('type', 'N/A')
|
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 |
url = f"https://huggingface.co/spaces/{item_id}"
|
113 |
type_icon = "๐ฏ"
|
114 |
type_label = "SPACE"
|
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 |
+
else:
|
146 |
+
# Models์ Datasets ์ฒ๋ฆฌ
|
147 |
+
url = f"https://huggingface.co/{item_id}" if card_type == "model" else f"https://huggingface.co/datasets/{item_id}"
|
148 |
+
type_icon = "๐ค" if card_type == "model" else "๐"
|
149 |
+
type_label = "MODEL" if card_type == "model" else "DATASET"
|
150 |
+
bg_color = "#6e8efb" if card_type == "model" else "#ff6b6b"
|
151 |
|
152 |
+
# ํ๊ทธ ๊ธฐ๋ฐ ๋ฐฐ๊ฒฝ
|
153 |
bg_content = f"""
|
154 |
background: linear-gradient(135deg, {bg_color}, {bg_color}dd);
|
155 |
padding: 15px;
|
156 |
+
"""
|
157 |
+
|
158 |
+
# ํ๊ทธ์ ๋ฉํ๋ฐ์ดํฐ ํ์
|
159 |
+
hardware_overlay = f"""
|
160 |
+
<div style='
|
161 |
+
padding: 15px;
|
162 |
+
background: rgba(255,255,255,0.1);
|
163 |
+
border-radius: 10px;
|
164 |
+
color: white;'>
|
165 |
+
|
166 |
+
<div style='
|
167 |
+
display: flex;
|
168 |
+
flex-wrap: wrap;
|
169 |
+
gap: 5px;
|
170 |
+
margin-bottom: 10px;'>
|
171 |
+
{' '.join([f'''
|
172 |
+
<span style='
|
173 |
+
background: rgba(255,255,255,0.2);
|
174 |
+
padding: 5px 10px;
|
175 |
+
border-radius: 15px;
|
176 |
+
font-size: 0.8em;'>
|
177 |
+
#{tag}
|
178 |
+
</span>
|
179 |
+
''' for tag in tags[:5]])}
|
180 |
+
</div>
|
181 |
+
|
182 |
+
<div style='
|
183 |
+
display: grid;
|
184 |
+
grid-template-columns: repeat(2, 1fr);
|
185 |
+
gap: 8px;
|
186 |
+
font-size: 0.9em;'>
|
187 |
+
<div>๐ป {cpu_info}</div>
|
188 |
+
<div>๐ฎ {gpu_info}</div>
|
189 |
+
{f'<div>๐ง Pipeline: {pipeline_tag}</div>' if pipeline_tag else ''}
|
190 |
+
{f'<div>๐ License: {license}</div>' if license else ''}
|
191 |
+
</div>
|
192 |
+
</div>
|
193 |
"""
|
194 |
|
195 |
return f"""
|
|
|
245 |
{type_icon} {type_label}
|
246 |
</div>
|
247 |
|
248 |
+
{hardware_overlay}
|
249 |
</div>
|
250 |
|
251 |
<!-- ์ฝํ
์ธ ์์ญ -->
|
252 |
<div style='
|
253 |
padding: 20px;
|
254 |
+
background: #f5f5f5;
|
255 |
border-radius: 0 0 20px 20px;'>
|
256 |
<h3 style='
|
257 |
margin: 0 0 15px 0;
|