AI Agent commited on
Commit
620247d
·
1 Parent(s): c32cbba

Premium UI: gradient title, larger gallery (scale=3), hover effects, download buttons, Inter font, orange theme

Browse files
Files changed (1) hide show
  1. app.py +108 -9
app.py CHANGED
@@ -244,17 +244,116 @@ def extract_assets(input_image):
244
  sys.stdout.flush()
245
  return []
246
 
247
- with gr.Blocks(title="SAM 3 Asset Extractor") as demo:
248
- gr.Markdown("# SAM 3 Concept Asset Extractor")
249
- gr.Markdown("Upload a presentation slide to automatically extract all distinct elements (charts, shapes, icons, text blocks) as transparent PNGs using Meta's Segment Anything 3 Promptable Concept Segmentation.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
250
 
251
- with gr.Row():
252
- with gr.Column(scale=1):
253
- input_image = gr.Image(label="Upload Slide", type="numpy")
254
- submit_btn = gr.Button("Extract Assets", variant="primary")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
255
 
256
- with gr.Column(scale=2):
257
- output_gallery = gr.Gallery(label="Extracted Assets", columns=4, object_fit="contain", height="auto")
 
 
 
 
 
 
 
 
 
258
 
259
  submit_btn.click(fn=extract_assets, inputs=[input_image], outputs=[output_gallery])
260
 
 
244
  sys.stdout.flush()
245
  return []
246
 
247
+ custom_css = """
248
+ /* ── Premium Dark Theme ─────────────────────────────── */
249
+ .gradio-container {
250
+ max-width: 1400px !important;
251
+ margin: auto;
252
+ }
253
+ #app-title {
254
+ text-align: center;
255
+ background: linear-gradient(135deg, #667eea 0%, #f97316 100%);
256
+ -webkit-background-clip: text;
257
+ -webkit-text-fill-color: transparent;
258
+ font-size: 2.2rem !important;
259
+ font-weight: 800 !important;
260
+ margin-bottom: 0 !important;
261
+ }
262
+ #app-subtitle {
263
+ text-align: center;
264
+ color: #94a3b8 !important;
265
+ font-size: 0.95rem !important;
266
+ margin-top: 0 !important;
267
+ }
268
+ /* Gallery: large, prominent, with hover download */
269
+ .gallery-container {
270
+ min-height: 650px !important;
271
+ }
272
+ .gallery-container .gallery-item {
273
+ position: relative;
274
+ border-radius: 12px;
275
+ overflow: hidden;
276
+ transition: transform 0.2s ease, box-shadow 0.2s ease;
277
+ background: #1e293b;
278
+ }
279
+ .gallery-container .gallery-item:hover {
280
+ transform: scale(1.03);
281
+ box-shadow: 0 8px 32px rgba(102, 126, 234, 0.3);
282
+ }
283
+ /* Download icon always visible */
284
+ .gallery-container .gallery-item button.download {
285
+ opacity: 1 !important;
286
+ }
287
+ /* Extract button styling */
288
+ #extract-btn {
289
+ background: linear-gradient(135deg, #f97316 0%, #ea580c 100%) !important;
290
+ border: none !important;
291
+ font-weight: 700 !important;
292
+ font-size: 1.1rem !important;
293
+ padding: 14px 0 !important;
294
+ border-radius: 12px !important;
295
+ transition: all 0.3s ease !important;
296
+ }
297
+ #extract-btn:hover {
298
+ transform: translateY(-2px) !important;
299
+ box-shadow: 0 6px 24px rgba(249, 115, 22, 0.4) !important;
300
+ }
301
+ /* Upload area */
302
+ #upload-area {
303
+ border: 2px dashed #475569 !important;
304
+ border-radius: 12px !important;
305
+ transition: border-color 0.3s ease !important;
306
+ }
307
+ #upload-area:hover {
308
+ border-color: #667eea !important;
309
+ }
310
+ """
311
+
312
+ with gr.Blocks(title="SAM 3 Asset Extractor", css=custom_css, theme=gr.themes.Soft(
313
+ primary_hue="orange",
314
+ secondary_hue="blue",
315
+ neutral_hue="slate",
316
+ font=gr.themes.GoogleFont("Inter"),
317
+ )) as demo:
318
+ gr.Markdown("# SAM 3 Concept Asset Extractor", elem_id="app-title")
319
+ gr.Markdown(
320
+ "Upload a presentation slide to automatically extract all distinct elements "
321
+ "(charts, shapes, icons, text blocks) as **transparent PNGs** using "
322
+ "Meta's Segment Anything 3 Promptable Concept Segmentation.",
323
+ elem_id="app-subtitle"
324
+ )
325
 
326
+ with gr.Row(equal_height=False):
327
+ with gr.Column(scale=1, min_width=320):
328
+ input_image = gr.Image(
329
+ label="📤 Upload Slide",
330
+ type="numpy",
331
+ elem_id="upload-area",
332
+ height=400,
333
+ )
334
+ submit_btn = gr.Button(
335
+ "🔍 Extract Assets",
336
+ variant="primary",
337
+ elem_id="extract-btn",
338
+ size="lg",
339
+ )
340
+ gr.Markdown(
341
+ "**Detected Concepts:** charts · diagrams · graphs · tables · "
342
+ "icons · logos · shapes · text blocks · images · illustrations",
343
+ elem_id="concept-list"
344
+ )
345
 
346
+ with gr.Column(scale=3):
347
+ output_gallery = gr.Gallery(
348
+ label="🎨 Extracted Assets — Click any image to download as PNG",
349
+ columns=3,
350
+ object_fit="contain",
351
+ height=650,
352
+ show_download_button=True,
353
+ show_share_button=False,
354
+ elem_classes=["gallery-container"],
355
+ preview=True,
356
+ )
357
 
358
  submit_btn.click(fn=extract_assets, inputs=[input_image], outputs=[output_gallery])
359