DurgaDeepak commited on
Commit
9438399
·
verified ·
1 Parent(s): 0a46f13

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +72 -51
app.py CHANGED
@@ -433,64 +433,84 @@ def handle(mode, media_upload, url, run_det, det_model, det_confidence, run_seg,
433
  log_runtime(start_time)
434
  return None, format_error("Invalid input. Please check your upload or URL."), None
435
 
 
436
  # Gradio Interface
437
  with gr.Blocks() as demo:
438
  gr.Markdown("## Unified Visual Intelligence System (UVIS)")
439
-
440
- # Input Mode Toggle
441
- mode = gr.Radio(["Upload", "URL"], value="Upload", label="Input Mode")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
442
 
443
- # File upload: accepts multiple images or one video (user chooses wisely)
444
- media_upload = gr.File(
445
- label="Upload Images (1–5) or 1 Video",
446
- file_types=["image", ".mp4", ".mov", ".avi"],
447
- file_count="multiple"
448
- )
449
 
450
- # URL input
451
- url = gr.Textbox(label="URL (Image/Video)", visible=False)
 
 
 
 
 
 
 
 
 
 
 
452
 
453
- # Toggle visibility
454
- def toggle_inputs(selected_mode):
455
- return [
456
- gr.update(visible=(selected_mode == "Upload")), # media_upload
457
- gr.update(visible=(selected_mode == "URL")) # url
458
- ]
459
-
460
- mode.change(toggle_inputs, inputs=mode, outputs=[media_upload, url])
461
-
462
 
463
- # Task Selection with parameters
464
- with gr.Accordion("Object Detection Settings", open=False):
465
- run_det = gr.Checkbox(label="Enable Object Detection")
466
- det_model = gr.Dropdown(list(DETECTION_MODEL_MAP), label="Detection Model", visible=False)
467
- det_confidence = gr.Slider(0.1, 1.0, 0.5, label="Detection Confidence Threshold", visible=False)
468
 
469
- with gr.Accordion("Semantic Segmentation Settings", open=False):
470
- run_seg = gr.Checkbox(label="Enable Segmentation")
471
- seg_model = gr.Dropdown(list(SEGMENTATION_MODEL_MAP), label="Segmentation Model", visible=False)
472
-
473
- with gr.Accordion("Depth Estimation Settings", open=False):
474
- run_depth = gr.Checkbox(label="Enable Depth Estimation")
475
- depth_model = gr.Dropdown(list(DEPTH_MODEL_MAP), label="Depth Model", visible=False)
476
-
477
- blend = gr.Slider(0.0, 1.0, 0.5, label="Overlay Blend")
478
-
479
- # Run Button
480
- run = gr.Button("Run Analysis")
481
-
482
- # Output Tabs
483
- with gr.Tab("Scene JSON"):
484
- json_out = gr.JSON()
485
- with gr.Tab("Scene Blueprint"):
486
- img_out = gr.Image()
487
- with gr.Tab("Download"):
488
- zip_out = gr.File()
489
-
490
- # Attach Visibility Logic
491
- run_det.change(toggle_visibility, run_det, [det_model, det_confidence])
492
- run_seg.change(toggle_visibility, run_seg, [seg_model])
493
- run_depth.change(toggle_visibility, run_depth, [depth_model])
494
 
495
  # Button Click Event
496
  run.click(
@@ -505,7 +525,7 @@ with gr.Blocks() as demo:
505
  """
506
  <div style='text-align: center; font-size: 14px;'>
507
  Built by <b>Durga Deepak Valluri</b><br>
508
- <a href="https://github.com/DurgaDeepakValluri/UVIS" target="_blank">GitHub</a> |
509
  <a href="https://deecoded.io" target="_blank">Website</a> |
510
  <a href="https://www.linkedin.com/in/durga-deepak-valluri" target="_blank">LinkedIn</a>
511
  </div>
@@ -514,3 +534,4 @@ with gr.Blocks() as demo:
514
 
515
  # Launch the Gradio App
516
  demo.launch()
 
 
433
  log_runtime(start_time)
434
  return None, format_error("Invalid input. Please check your upload or URL."), None
435
 
436
+ # Gradio Interface
437
  # Gradio Interface
438
  with gr.Blocks() as demo:
439
  gr.Markdown("## Unified Visual Intelligence System (UVIS)")
440
+ with gr.Row():
441
+ with gr.Column(scale=2):
442
+ # Input Mode Toggle
443
+ mode = gr.Radio(["Upload", "URL"], value="Upload", label="Input Mode")
444
+
445
+ # File upload: accepts multiple images or one video (user chooses wisely)
446
+ media_upload = gr.File(
447
+ label="Upload Images (1–5) or 1 Video",
448
+ file_types=["image", ".mp4", ".mov", ".avi"],
449
+ file_count="multiple"
450
+ )
451
+
452
+ # URL input
453
+ url = gr.Textbox(label="URL (Image/Video)", visible=False)
454
+
455
+ # Toggle visibility
456
+ def toggle_inputs(selected_mode):
457
+ return [
458
+ gr.update(visible=(selected_mode == "Upload")), # media_upload
459
+ gr.update(visible=(selected_mode == "URL")) # url
460
+ ]
461
+
462
+ mode.change(toggle_inputs, inputs=mode, outputs=[media_upload, url])
463
+
464
+
465
+ run_det = gr.Checkbox(label="Object Detection")
466
+ run_seg = gr.Checkbox(label="Semantic Segmentation")
467
+ run_depth = gr.Checkbox(label="Depth Estimation")
468
+
469
+ det_model = gr.Dropdown(choices=list(DETECTION_MODEL_MAP), label="Detection Model", visible=False)
470
+ seg_model = gr.Dropdown(choices=list(SEGMENTATION_MODEL_MAP), label="Segmentation Model", visible=False)
471
+ depth_model = gr.Dropdown(choices=list(DEPTH_MODEL_MAP), label="Depth Model", visible=False)
472
+
473
+ #det_confidence = gr.Slider(0.1, 1.0, 0.5, label="Detection Confidence Threshold", visible=False)
474
+
475
+ # Attach Visibility Logic
476
+ run_det.change(fn=toggle_det, inputs=[run_det], outputs=[det_model, det_confidence])
477
+ run_seg.change(fn=toggle_seg, inputs=[run_seg], outputs=[seg_model])
478
+ run_depth.change(fn=toggle_depth, inputs=[run_depth], outputs=[depth_model])
479
+
480
+ blend = gr.Slider(0.0, 1.0, 0.5, label="Overlay Blend")
481
+
482
+ # Run Button
483
+ run = gr.Button("Run Analysis")
484
+
485
+ #Right panel
486
+ with gr.Column(scale=1):
487
+ # single_img_preview = gr.Image(label="Preview (Image)", visible=False)
488
+ # gallery_preview = gr.Gallery(label="Preview (Gallery)", columns=3, height="auto", visible=False)
489
+ # video_preview = gr.Video(label="Preview (Video)", visible=False)
490
+ img_out = gr.Image(label="Scene Blueprint")
491
+ json_out = gr.JSON(label="Scene JSON")
492
+ zip_out = gr.File(label="Download Results")
493
+
494
 
 
 
 
 
 
 
495
 
496
+ # # Output Tabs
497
+ # with gr.Tab("Scene JSON"):
498
+ # json_out = gr.JSON()
499
+ # with gr.Tab("Scene Blueprint"):
500
+ # img_out = gr.Image()
501
+ # with gr.Tab("Download"):
502
+ # zip_out = gr.File()
503
+
504
+ def toggle_det(checked):
505
+ return [gr.update(visible=checked), gr.update(visible=checked)]
506
+
507
+ def toggle_seg(checked):
508
+ return [gr.update(visible=checked)]
509
 
510
+ def toggle_depth(checked):
511
+ return [gr.update(visible=checked)]
 
 
 
 
 
 
 
512
 
 
 
 
 
 
513
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
514
 
515
  # Button Click Event
516
  run.click(
 
525
  """
526
  <div style='text-align: center; font-size: 14px;'>
527
  Built by <b>Durga Deepak Valluri</b><br>
528
+ <a href="https://github.com/DurgaDeepakValluri" target="_blank">GitHub</a> |
529
  <a href="https://deecoded.io" target="_blank">Website</a> |
530
  <a href="https://www.linkedin.com/in/durga-deepak-valluri" target="_blank">LinkedIn</a>
531
  </div>
 
534
 
535
  # Launch the Gradio App
536
  demo.launch()
537
+