BhumikaMak commited on
Commit
7991981
·
1 Parent(s): d4cd198

Fix: interface layout

Browse files
Files changed (1) hide show
  1. app.py +42 -43
app.py CHANGED
@@ -84,49 +84,48 @@ def process_image(choice, yolo_versions=["yolov5"]):
84
  with gr.Blocks() as interface:
85
  gr.Markdown("# XAI: Visualize Object Detection of Your Models")
86
  gr.Markdown("Select a sample image or upload your own image to visualize object detection.")
87
-
88
- # Default sample image selection
89
- default_sample = "Sample 1"
90
-
91
- with gr.Column(): # Column layout for the image selection section
92
- # Radio button with default value set
93
- sample_selection = gr.Radio(
94
- choices=list(sample_images.keys()),
95
- label="Select a Sample Image",
96
- type="value",
97
- value=default_sample, # Set default selection
98
- )
99
- # Display the selected or uploaded image
100
- image_display = gr.Image(
101
- value=load_sample_image(default_sample), # Load default sample image
102
- label="Selected/Uploaded Image",
103
- )
104
-
105
- # File upload for custom images (placed below the sample selection)
106
- uploaded_image = gr.Image(type="numpy", label="Upload an Image")
107
-
108
- # Update display when sample selection changes
109
- sample_selection.change(
110
- fn=load_sample_image,
111
- inputs=sample_selection,
112
- outputs=image_display,
113
- )
114
-
115
- uploaded_image.change(
116
- fn=lambda img: img,
117
- inputs=uploaded_image,
118
- outputs=image_display,
119
- )
120
-
121
- # Place the "Select Model(s)" below the image selection block
122
- with gr.Column(): # Column layout for model selection
123
- selected_models = gr.CheckboxGroup(
124
- choices=["yolov5", "yolov8s"],
125
- value=["yolov5"],
126
- label="Select Model(s)",
127
- )
128
-
129
- result_gallery = gr.Gallery(label="Results", elem_id="gallery", rows=2, height=500)
130
 
131
  # Use the uploaded image if available, otherwise the selected sample
132
  gr.Button("Run").click(
 
84
  with gr.Blocks() as interface:
85
  gr.Markdown("# XAI: Visualize Object Detection of Your Models")
86
  gr.Markdown("Select a sample image or upload your own image to visualize object detection.")
87
+ with gr.Row(): # Row layout to divide the screen into two sections
88
+ with gr.Column(): # Left section for image selection and upload
89
+ # Radio button with default value set
90
+ sample_selection = gr.Radio(
91
+ choices=list(sample_images.keys()),
92
+ label="Select a Sample Image",
93
+ type="value",
94
+ value="Sample 1", # Set default selection
95
+ )
96
+ # Display the selected or uploaded image
97
+ image_display = gr.Image(
98
+ value=load_sample_image("Sample 1"), # Load default sample image
99
+ label="Selected/Uploaded Image",
100
+ )
101
+
102
+ # File upload for custom images (placed below the sample selection)
103
+ uploaded_image = gr.Image(type="numpy", label="Upload an Image")
104
+
105
+ # Update display when sample selection changes
106
+ sample_selection.change(
107
+ fn=load_sample_image,
108
+ inputs=sample_selection,
109
+ outputs=image_display,
110
+ )
111
+
112
+ # Update display when an image is uploaded
113
+ uploaded_image.change(
114
+ fn=lambda img: img,
115
+ inputs=uploaded_image,
116
+ outputs=image_display,
117
+ )
118
+
119
+ # Model selection below the image options
120
+ selected_models = gr.CheckboxGroup(
121
+ choices=["yolov5", "yolov8s"],
122
+ value=["yolov5"],
123
+ label="Select Model(s)",
124
+ )
125
+
126
+ # Right section for image display
127
+ with gr.Column():
128
+ result_gallery = gr.Gallery(label="Results", elem_id="gallery", rows=2, height=500)
 
129
 
130
  # Use the uploaded image if available, otherwise the selected sample
131
  gr.Button("Run").click(