enpaiva commited on
Commit
62ca522
Β·
verified Β·
1 Parent(s): 584b383

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +101 -95
app.py CHANGED
@@ -328,110 +328,116 @@ if __name__ == "__main__":
328
  <p style='margin: 10px 0 0 0; font-size: 1.2em; opacity: 0.9;'>Compact interface for advanced document structure detection</p>
329
  </div>
330
  """)
 
 
 
331
 
332
- # Controls Section
333
- with gr.Group(elem_classes=["controls-container"]):
334
- # 1. Image Upload (First)
335
- gr.HTML("<h3 style='margin-top: 0;'>πŸ“„ Upload Document</h3>")
336
- input_img = gr.Image(
337
- label="Document Image",
338
- type="pil",
339
- height=300,
340
- interactive=True
341
- )
342
-
343
- # Divider
344
- gr.HTML("<div class='section-divider'></div>")
345
-
346
- # 2. Model Selection (Second)
347
- gr.HTML("<h3>πŸ€– Model Selection</h3>")
348
- model_dropdown = gr.Dropdown(
349
- choices=list(MODELS.keys()),
350
- value="Egret XLarge",
351
- label="AI Model",
352
- info="Model will load automatically when analyzing",
353
- interactive=True
354
- )
355
-
356
- # Divider
357
- gr.HTML("<div class='section-divider'></div>")
358
-
359
- # 3. Detection Parameters (Third)
360
- gr.HTML("<h3>βš™οΈ Detection Settings</h3>")
361
-
362
- with gr.Row():
363
- conf_threshold = gr.Slider(
364
- minimum=0.0,
365
- maximum=1.0,
366
- value=0.6,
367
- step=0.05,
368
- label="Confidence Threshold",
369
- info="Minimum confidence for detections"
370
  )
371
 
372
- iou_threshold = gr.Slider(
373
- minimum=0.0,
374
- maximum=1.0,
375
- value=0.5,
376
- step=0.05,
377
- label="NMS IoU Threshold",
378
- info="Non-maximum suppression threshold"
 
 
 
 
379
  )
380
-
381
- with gr.Row():
382
- nms_method = gr.Radio(
383
- choices=["Custom IoMin", "Standard IoU"],
384
- value="Custom IoMin",
385
- label="NMS Algorithm",
386
- info="Choose suppression method"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
387
  )
388
 
389
- alpha_slider = gr.Slider(
390
- minimum=0.0,
391
- maximum=1.0,
392
- value=0.3,
393
- step=0.1,
394
- label="Overlay Transparency",
395
- info="Transparency of detection overlays"
 
 
396
  )
397
-
398
- show_labels_checkbox = gr.Checkbox(
399
- value=True,
400
- label="Show Class Labels and Confidence Scores",
401
- info="Display detection labels on the output image",
402
- interactive=True
403
- )
404
-
405
- # Divider
406
- gr.HTML("<div class='section-divider'></div>")
407
-
408
- # 4. Analyze Button (Last)
409
- detect_btn = gr.Button(
410
- "πŸ” Analyze Document",
411
- variant="primary",
412
- size="lg",
413
- elem_classes=["analyze-btn"]
414
- )
415
 
416
- # Results Section
417
- with gr.Group(elem_classes=["results-container"]):
418
- gr.HTML("<h3 style='margin-top: 0;'>🎯 Analysis Results</h3>")
419
-
420
- output_img = gr.Image(
421
- label="Analyzed Document",
422
- type="numpy",
423
- height=600,
424
- interactive=False
425
- )
 
 
 
 
 
 
 
 
426
 
427
- detection_info = gr.Textbox(
428
- label="Detection Summary",
429
- value="Ready for analysis. Upload an image and click 'Analyze Document'.",
430
- interactive=False,
431
- lines=2,
432
- show_copy_button=True
433
- )
434
-
435
  # Event Handler
436
  detect_btn.click(
437
  fn=process_image,
 
328
  <p style='margin: 10px 0 0 0; font-size: 1.2em; opacity: 0.9;'>Compact interface for advanced document structure detection</p>
329
  </div>
330
  """)
331
+
332
+ # LEFT COLUMN - Controls and Input
333
+ with gr.Column(scale=1):
334
 
335
+ # Controls Section
336
+ with gr.Group(elem_classes=["controls-container"]):
337
+ # 1. Image Upload (First)
338
+ gr.HTML("<h3 style='margin-top: 0;'>πŸ“„ Upload Document</h3>")
339
+ input_img = gr.Image(
340
+ label="Document Image",
341
+ type="pil",
342
+ height=300,
343
+ interactive=True
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
344
  )
345
 
346
+ # Divider
347
+ gr.HTML("<div class='section-divider'></div>")
348
+
349
+ # 2. Model Selection (Second)
350
+ gr.HTML("<h3>πŸ€– Model Selection</h3>")
351
+ model_dropdown = gr.Dropdown(
352
+ choices=list(MODELS.keys()),
353
+ value="Egret XLarge",
354
+ label="AI Model",
355
+ info="Model will load automatically when analyzing",
356
+ interactive=True
357
  )
358
+
359
+ # Divider
360
+ gr.HTML("<div class='section-divider'></div>")
361
+
362
+ # 3. Detection Parameters (Third)
363
+ gr.HTML("<h3>βš™οΈ Detection Settings</h3>")
364
+
365
+ with gr.Row():
366
+ conf_threshold = gr.Slider(
367
+ minimum=0.0,
368
+ maximum=1.0,
369
+ value=0.6,
370
+ step=0.05,
371
+ label="Confidence Threshold",
372
+ info="Minimum confidence for detections"
373
+ )
374
+
375
+ iou_threshold = gr.Slider(
376
+ minimum=0.0,
377
+ maximum=1.0,
378
+ value=0.5,
379
+ step=0.05,
380
+ label="NMS IoU Threshold",
381
+ info="Non-maximum suppression threshold"
382
+ )
383
+
384
+ with gr.Row():
385
+ nms_method = gr.Radio(
386
+ choices=["Custom IoMin", "Standard IoU"],
387
+ value="Custom IoMin",
388
+ label="NMS Algorithm",
389
+ info="Choose suppression method"
390
+ )
391
+
392
+ alpha_slider = gr.Slider(
393
+ minimum=0.0,
394
+ maximum=1.0,
395
+ value=0.3,
396
+ step=0.1,
397
+ label="Overlay Transparency",
398
+ info="Transparency of detection overlays"
399
+ )
400
+
401
+ show_labels_checkbox = gr.Checkbox(
402
+ value=True,
403
+ label="Show Class Labels and Confidence Scores",
404
+ info="Display detection labels on the output image",
405
+ interactive=True
406
  )
407
 
408
+ # Divider
409
+ gr.HTML("<div class='section-divider'></div>")
410
+
411
+ # 4. Analyze Button (Last)
412
+ detect_btn = gr.Button(
413
+ "πŸ” Analyze Document",
414
+ variant="primary",
415
+ size="lg",
416
+ elem_classes=["analyze-btn"]
417
  )
418
+
419
+ # RIGHT COLUMN - Results and Output
420
+ with gr.Column(scale=1):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
421
 
422
+ # Results Section
423
+ with gr.Group(elem_classes=["results-container"]):
424
+ gr.HTML("<h3 style='margin-top: 0;'>🎯 Analysis Results</h3>")
425
+
426
+ output_img = gr.Image(
427
+ label="Analyzed Document",
428
+ type="numpy",
429
+ height=600,
430
+ interactive=False
431
+ )
432
+
433
+ detection_info = gr.Textbox(
434
+ label="Detection Summary",
435
+ value="Ready for analysis. Upload an image and click 'Analyze Document'.",
436
+ interactive=False,
437
+ lines=2,
438
+ show_copy_button=True
439
+ )
440
 
 
 
 
 
 
 
 
 
441
  # Event Handler
442
  detect_btn.click(
443
  fn=process_image,