openfree commited on
Commit
c9933ea
β€’
1 Parent(s): ea1c9c1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +64 -44
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
- elif card_type == "model":
106
- url = f"https://huggingface.co/{item_id}"
107
- type_icon = "πŸ€–"
108
- type_label = "MODEL"
109
- tags = item.get('tags', [])[:3] # μƒμœ„ 3개 νƒœκ·Έλ§Œ ν‘œμ‹œ
110
- bg_content = f"""
111
- background: linear-gradient(135deg, #6e8efb, #4a6cf7);
112
- display: flex;
113
- flex-wrap: wrap;
114
- gap: 5px;
115
  padding: 15px;
116
- align-content: flex-start;
117
- """
118
- tag_html = ''.join([f"""
119
- <span style='
120
- background: rgba(255,255,255,0.2);
121
- padding: 5px 10px;
122
- border-radius: 15px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  color: white;
124
- font-size: 0.8em;'>
125
- #{tag}
126
- </span>
127
- """ for tag in tags])
128
- else: # dataset
129
- url = f"https://huggingface.co/datasets/{item_id}"
130
- type_icon = "πŸ“Š"
131
- type_label = "DATASET"
132
- tags = item.get('tags', [])[:3]
 
 
 
 
 
 
 
 
133
  bg_content = f"""
134
- background: linear-gradient(135deg, #ff6b6b, #ff8787);
135
- display: flex;
136
- flex-wrap: wrap;
137
- gap: 5px;
138
  padding: 15px;
139
- align-content: flex-start;
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
- {tag_html if card_type != "space" else ""}
206
  </div>
207
 
208
  <!-- μ½˜ν…μΈ  μ˜μ—­ -->
209
- <div style='padding: 20px;'>
 
 
 
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]: