Sijuade commited on
Commit
28681a7
·
1 Parent(s): ea6f52d

Update gradio_utils.py

Browse files
Files changed (1) hide show
  1. gradio_utils.py +4 -6
gradio_utils.py CHANGED
@@ -71,8 +71,8 @@ def infer_transform(IMAGE_SIZE=config.INFERENCE_IMAGE_SIZE):
71
  A.PadIfNeeded(
72
  min_height=IMAGE_SIZE, min_width=IMAGE_SIZE, border_mode=cv2.BORDER_CONSTANT
73
  ),
74
- A.Normalize(mean=[0,0,0],
75
- std=[1,1,1],
76
  max_pixel_value=255,),
77
  ToTensorV2(),
78
  ]
@@ -195,12 +195,11 @@ def upload_image_inference(img, transparency):
195
  config.PASCAL_CLASSES[class_prediction]])
196
 
197
 
 
198
  objs = [b[1] for b in nms_boxes_output[0]]
199
  bbox_coord = [b[2:] for b in nms_boxes_output[0]]
200
  targets = [FasterRCNNBoxScoreTarget(objs, bbox_coord)]
201
 
202
- new_bboxes = [a[0] for a in annotations]
203
-
204
  cam = EigenCAM(model=model,
205
  target_layers=[model.model],
206
  reshape_transform=yolov3_reshape_transform)
@@ -213,9 +212,8 @@ def upload_image_inference(img, transparency):
213
  for x1, y1, x2, y2 in new_bboxes:
214
  renormalized_cam[y1:y2, x1:x2] = scale_cam_image(grayscale_cam[y1:y2, x1:x2].copy())
215
 
216
- img_copy= np.float32(img_copy) / 255
217
  renormalized_cam = scale_cam_image(renormalized_cam)
218
- eigencam_image_renormalized = show_cam_on_image(img_copy, renormalized_cam, use_rgb=True)
219
 
220
  return([[img_copy, annotations],
221
  [grayscale_cam, eigencam_image_renormalized]])
 
71
  A.PadIfNeeded(
72
  min_height=IMAGE_SIZE, min_width=IMAGE_SIZE, border_mode=cv2.BORDER_CONSTANT
73
  ),
74
+ A.Normalize(mean=[0.45484068, 0.43406072, 0.40103856],
75
+ std=[0.23936155, 0.23471538, 0.23876129],
76
  max_pixel_value=255,),
77
  ToTensorV2(),
78
  ]
 
195
  config.PASCAL_CLASSES[class_prediction]])
196
 
197
 
198
+ new_bboxes = [a[0] for a in annotations]
199
  objs = [b[1] for b in nms_boxes_output[0]]
200
  bbox_coord = [b[2:] for b in nms_boxes_output[0]]
201
  targets = [FasterRCNNBoxScoreTarget(objs, bbox_coord)]
202
 
 
 
203
  cam = EigenCAM(model=model,
204
  target_layers=[model.model],
205
  reshape_transform=yolov3_reshape_transform)
 
212
  for x1, y1, x2, y2 in new_bboxes:
213
  renormalized_cam[y1:y2, x1:x2] = scale_cam_image(grayscale_cam[y1:y2, x1:x2].copy())
214
 
 
215
  renormalized_cam = scale_cam_image(renormalized_cam)
216
+ eigencam_image_renormalized = show_cam_on_image(np.float32(img_copy)/255, renormalized_cam, use_rgb=True)
217
 
218
  return([[img_copy, annotations],
219
  [grayscale_cam, eigencam_image_renormalized]])