piyushgrover commited on
Commit
d1be1c8
·
1 Parent(s): 91788b1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -103,7 +103,7 @@ with gr.Blocks() as app:
103
  with gr.Row(visible=True) as top_pred_cls_col:
104
  with gr.Column():
105
  example_images = gr.Gallery(allow_preview=False, label='Select image ', info='',
106
- value=[img[0] for img in sample_images], columns=7, rows=2)
107
 
108
  with gr.Column():
109
  with gr.Row():
@@ -111,7 +111,7 @@ with gr.Blocks() as app:
111
 
112
  with gr.Row():
113
  if_show_grad_cam = gr.Checkbox(value=True, label='Show Class Activation Map (What the model sees)?')
114
-
115
  with gr.Row():
116
  top_class_btn = gr.Button("Submit", variant='primary')
117
  tc_clear_btn = gr.ClearButton()
@@ -226,10 +226,9 @@ with gr.Blocks() as app:
226
  if not show_cam:
227
  return [plotted_img, None]
228
 
229
- grayscale_cam = cam(transformed_image)[0, :, :]
230
- img = cv2.resize(transformed_image, (cfg.IMAGE_SIZE, cfg.IMAGE_SIZE))
231
- #img = np.float32(img) / 255
232
- cam_image = show_cam_on_image(img, grayscale_cam, use_rgb=True, image_weight=transparency)
233
  return [plotted_img, cam_image]
234
 
235
 
 
103
  with gr.Row(visible=True) as top_pred_cls_col:
104
  with gr.Column():
105
  example_images = gr.Gallery(allow_preview=False, label='Select image ', info='',
106
+ value=[img[0] for img in sample_images], columns=6, rows=2)
107
 
108
  with gr.Column():
109
  with gr.Row():
 
111
 
112
  with gr.Row():
113
  if_show_grad_cam = gr.Checkbox(value=True, label='Show Class Activation Map (What the model sees)?')
114
+
115
  with gr.Row():
116
  top_class_btn = gr.Button("Submit", variant='primary')
117
  tc_clear_btn = gr.ClearButton()
 
226
  if not show_cam:
227
  return [plotted_img, None]
228
 
229
+ grayscale_cam = cam(transformed_image)
230
+ img = np.array(transformed_image[0], np.float16).transpose(1, 2, 0)
231
+ cam_image = show_cam_on_image(img, grayscale_cam.transpose(1, 2, 0), use_rgb=True, image_weight=transparency)
 
232
  return [plotted_img, cam_image]
233
 
234