Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -92,6 +92,11 @@ def get_card(item: dict, index: int, card_type: str = "space") -> str:
|
|
92 |
likes = format(item.get('likes', 0), ',')
|
93 |
created = item.get('createdAt', '').split('T')[0]
|
94 |
|
|
|
|
|
|
|
|
|
|
|
95 |
# μΉ΄λ νμ
λ³ νΉμ μ²λ¦¬
|
96 |
if card_type == "space":
|
97 |
url = f"https://huggingface.co/spaces/{item_id}"
|
@@ -102,52 +107,65 @@ def get_card(item: dict, index: int, card_type: str = "space") -> str:
|
|
102 |
background-size: cover;
|
103 |
background-position: center;
|
104 |
"""
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
padding: 15px;
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
color: white;
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
bg_content = f"""
|
134 |
-
background: linear-gradient(135deg,
|
135 |
-
display: flex;
|
136 |
-
flex-wrap: wrap;
|
137 |
-
gap: 5px;
|
138 |
padding: 15px;
|
139 |
-
|
140 |
"""
|
141 |
-
tag_html = ''.join([f"""
|
142 |
-
<span style='
|
143 |
-
background: rgba(255,255,255,0.2);
|
144 |
-
padding: 5px 10px;
|
145 |
-
border-radius: 15px;
|
146 |
-
color: white;
|
147 |
-
font-size: 0.8em;'>
|
148 |
-
#{tag}
|
149 |
-
</span>
|
150 |
-
""" for tag in tags])
|
151 |
|
152 |
return f"""
|
153 |
<div class="card" style='
|
@@ -202,11 +220,14 @@ def get_card(item: dict, index: int, card_type: str = "space") -> str:
|
|
202 |
{type_icon} {type_label}
|
203 |
</div>
|
204 |
|
205 |
-
{
|
206 |
</div>
|
207 |
|
208 |
<!-- μ½ν
μΈ μμ -->
|
209 |
-
<div style='
|
|
|
|
|
|
|
210 |
<h3 style='
|
211 |
margin: 0 0 15px 0;
|
212 |
color: #333;
|
@@ -239,7 +260,6 @@ def get_card(item: dict, index: int, card_type: str = "space") -> str:
|
|
239 |
</div>
|
240 |
</div>
|
241 |
"""
|
242 |
-
|
243 |
|
244 |
|
245 |
def get_trending_spaces(progress=gr.Progress()) -> Tuple[str, str]:
|
|
|
92 |
likes = format(item.get('likes', 0), ',')
|
93 |
created = item.get('createdAt', '').split('T')[0]
|
94 |
|
95 |
+
# λ©νλ°μ΄ν° μ²λ¦¬
|
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}"
|
|
|
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 |
+
meta_html = f"""
|
119 |
+
<div style='
|
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 |
+
font-size: 0.9em;'>
|
158 |
+
π License: {license}
|
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 |
+
color: white;
|
168 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
|
170 |
return f"""
|
171 |
<div class="card" style='
|
|
|
220 |
{type_icon} {type_label}
|
221 |
</div>
|
222 |
|
223 |
+
{meta_html}
|
224 |
</div>
|
225 |
|
226 |
<!-- μ½ν
μΈ μμ -->
|
227 |
+
<div style='
|
228 |
+
padding: 20px;
|
229 |
+
background: {("#f5f5f5" if card_type == "space" else "white")};
|
230 |
+
border-radius: 0 0 20px 20px;'>
|
231 |
<h3 style='
|
232 |
margin: 0 0 15px 0;
|
233 |
color: #333;
|
|
|
260 |
</div>
|
261 |
</div>
|
262 |
"""
|
|
|
263 |
|
264 |
|
265 |
def get_trending_spaces(progress=gr.Progress()) -> Tuple[str, str]:
|