openfree commited on
Commit
3127fda
โ€ข
1 Parent(s): fe2f52f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +75 -92
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
- 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
-
146
- # Spaces์šฉ ํŒŒ์Šคํ…”ํ†ค ๊ทธ๋ผ๋ฐ์ด์…˜ ๋ฐฐ๊ฒฝ
147
- content_bg = """
148
- background: linear-gradient(135deg,
149
- rgba(255, 182, 193, 0.7), /* ํŒŒ์Šคํ…” ํ•‘ํฌ */
150
- rgba(173, 216, 230, 0.7), /* ํŒŒ์Šคํ…” ๋ธ”๋ฃจ */
151
- rgba(255, 218, 185, 0.7) /* ํŒŒ์Šคํ…” ํ”ผ์น˜ */
152
- );
153
- backdrop-filter: blur(10px);
154
  """
155
- else:
156
- # Models์™€ Datasets ์ฒ˜๋ฆฌ
157
- url = f"https://huggingface.co/{item_id}" if card_type == "model" else f"https://huggingface.co/datasets/{item_id}"
158
- type_icon = "๐Ÿค–" if card_type == "model" else "๐Ÿ“Š"
159
- type_label = "MODEL" if card_type == "model" else "DATASET"
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
- hardware_overlay = f"""
171
- <div style='
172
- padding: 15px;
173
- background: rgba(255,255,255,0.1);
174
- border-radius: 10px;
175
- color: white;'>
176
-
177
- <div style='
178
- display: flex;
179
- flex-wrap: wrap;
180
- gap: 5px;
181
- margin-bottom: 10px;'>
182
- {' '.join([f'''
183
- <span style='
184
- background: rgba(255,255,255,0.2);
185
- padding: 5px 10px;
186
- border-radius: 15px;
187
- font-size: 0.8em;'>
188
- #{tag}
189
- </span>
190
- ''' for tag in tags[:5]])}
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
- {hardware_overlay}
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 10 trending spaces on Hugging Face")
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()