enpaiva commited on
Commit
a9cca16
Β·
verified Β·
1 Parent(s): fc642fe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -37
app.py CHANGED
@@ -271,27 +271,6 @@ def reset_interface():
271
  """Reset all interface components."""
272
  return gr.update(value=None), gr.update(value=None), gr.update(value="")
273
 
274
- def create_legend_html():
275
- """Create HTML for the class legend."""
276
- cmap = colormap(N=len(classes_map), normalized=False)
277
- legend_items = []
278
-
279
- for class_id, class_name in classes_map.items():
280
- color_rgb = cmap[class_id % len(cmap)]
281
- color_hex = f"#{color_rgb[0]:02x}{color_rgb[1]:02x}{color_rgb[2]:02x}"
282
- legend_items.append(f"""
283
- <div style='display: flex; align-items: center; padding: 8px; margin: 4px; background-color: #f8f9fa; border-radius: 6px;'>
284
- <div style='width: 24px; height: 24px; background-color: {color_hex}; margin-right: 12px; border: 2px solid #dee2e6; border-radius: 4px;'></div>
285
- <span style='font-weight: 500; color: #495057;'>{class_name}</span>
286
- </div>
287
- """)
288
-
289
- return f"""
290
- <div style='display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; padding: 16px; background-color: #ffffff; border-radius: 8px; border: 1px solid #e9ecef;'>
291
- {''.join(legend_items)}
292
- </div>
293
- """
294
-
295
  if __name__ == "__main__":
296
  print(f"πŸš€ Starting Document Layout Analysis App")
297
  print(f"πŸ“± Device: {device}")
@@ -430,17 +409,6 @@ if __name__ == "__main__":
430
  label="Overlay Transparency",
431
  info="Transparency of detection overlays"
432
  )
433
-
434
- # Visualization Options Section
435
- with gr.Group(elem_classes=["control-section"]):
436
- gr.HTML("<h3>🎨 Visualization Options</h3>")
437
-
438
- show_labels_checkbox = gr.Checkbox(
439
- value=True,
440
- label="Show Class Labels",
441
- info="Display class names and confidence scores on detections",
442
- interactive=True
443
- )
444
 
445
  # RIGHT COLUMN - Results and Output
446
  with gr.Column(scale=1, elem_classes=["panel-right"]):
@@ -463,11 +431,17 @@ if __name__ == "__main__":
463
  lines=3,
464
  placeholder="Detection results will appear here..."
465
  )
466
-
467
- # Legend Section (Full Width)
468
- with gr.Group():
469
- with gr.Accordion("πŸ“‹ Class Legend - All Detectable Elements", open=False):
470
- gr.HTML(create_legend_html())
 
 
 
 
 
 
471
 
472
  # Event Handlers
473
  load_btn.click(
 
271
  """Reset all interface components."""
272
  return gr.update(value=None), gr.update(value=None), gr.update(value="")
273
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
274
  if __name__ == "__main__":
275
  print(f"πŸš€ Starting Document Layout Analysis App")
276
  print(f"πŸ“± Device: {device}")
 
409
  label="Overlay Transparency",
410
  info="Transparency of detection overlays"
411
  )
 
 
 
 
 
 
 
 
 
 
 
412
 
413
  # RIGHT COLUMN - Results and Output
414
  with gr.Column(scale=1, elem_classes=["panel-right"]):
 
431
  lines=3,
432
  placeholder="Detection results will appear here..."
433
  )
434
+
435
+ # Visualization Options Section
436
+ with gr.Group(elem_classes=["control-section"]):
437
+ gr.HTML("<h3>🎨 Visualization Options</h3>")
438
+
439
+ show_labels_checkbox = gr.Checkbox(
440
+ value=True,
441
+ label="Show Class Labels",
442
+ info="Display class names and confidence scores on detections",
443
+ interactive=True
444
+ )
445
 
446
  # Event Handlers
447
  load_btn.click(