vibha-mah commited on
Commit
78ead19
·
1 Parent(s): 51011ea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -165,8 +165,14 @@ def inference(image):
165
  scratch_masks_arr = np.array(scratch_masks)
166
  damage_masks_arr = np.array(damage_masks)
167
  # Resize the scratch and damage masks to match the size of the original image
168
- scratch_mask_resized = cv2.resize(scratch_masks_arr[0].astype(np.uint8), (img.shape[1], img.shape[0]))
169
- damage_mask_resized = cv2.resize(damage_masks_arr[0].astype(np.uint8), (img.shape[1], img.shape[0]))
 
 
 
 
 
 
170
  # Merge the scratch and damage masks into a single binary mask
171
  merged_mask = np.zeros_like(scratch_mask_resized)
172
  merged_mask[(scratch_mask_resized> 0) | (damage_mask_resized > 0)] = 255
@@ -243,6 +249,7 @@ def inference(image):
243
  with gr.Blocks() as demo:
244
  with gr.Row():
245
  with gr.Column():
 
246
  gr.Markdown("## Inputs")
247
  image = gr.Image(type="pil",label="Input")
248
  submit_button = gr.Button(value="Submit", label="Submit")
 
165
  scratch_masks_arr = np.array(scratch_masks)
166
  damage_masks_arr = np.array(damage_masks)
167
  # Resize the scratch and damage masks to match the size of the original image
168
+ if len(scratch_masks_arr) > 0:
169
+ scratch_mask_resized = cv2.resize(scratch_masks_arr[0].astype(np.uint8), (img.shape[1], img.shape[0]))
170
+ else:
171
+ scratch_mask_resized = np.zeros((img.shape[0], img.shape[1]), dtype=np.uint8)
172
+ if len(damage_masks_arr) > 0:
173
+ damage_mask_resized = cv2.resize(damage_masks_arr[0].astype(np.uint8), (img.shape[1], img.shape[0]))
174
+ else:
175
+ damage_mask_resized = np.zeros((img.shape[0], img.shape[1]), dtype=np.uint8)
176
  # Merge the scratch and damage masks into a single binary mask
177
  merged_mask = np.zeros_like(scratch_mask_resized)
178
  merged_mask[(scratch_mask_resized> 0) | (damage_mask_resized > 0)] = 255
 
249
  with gr.Blocks() as demo:
250
  with gr.Row():
251
  with gr.Column():
252
+ gr.HTML("<h1 style='text-align: center;'>Damage Detection Dashboard</h1>")
253
  gr.Markdown("## Inputs")
254
  image = gr.Image(type="pil",label="Input")
255
  submit_button = gr.Button(value="Submit", label="Submit")