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

Update gradio_utils.py

Browse files
Files changed (1) hide show
  1. gradio_utils.py +7 -2
gradio_utils.py CHANGED
@@ -206,6 +206,8 @@ def upload_image_inference(img, transparency):
206
 
207
  grayscale_cam = cam(input_tensor=img, targets=targets)
208
  grayscale_cam = grayscale_cam[0, :]
 
 
209
 
210
  renormalized_cam = np.zeros(grayscale_cam.shape, dtype=np.float32)
211
 
@@ -213,8 +215,11 @@ def upload_image_inference(img, transparency):
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]])
 
 
 
220
 
 
206
 
207
  grayscale_cam = cam(input_tensor=img, targets=targets)
208
  grayscale_cam = grayscale_cam[0, :]
209
+
210
+ visualization = show_cam_on_image(img_copy/255, grayscale_cam, use_rgb=False, image_weight=transparency)
211
 
212
  renormalized_cam = np.zeros(grayscale_cam.shape, dtype=np.float32)
213
 
 
215
  renormalized_cam[y1:y2, x1:x2] = scale_cam_image(grayscale_cam[y1:y2, x1:x2].copy())
216
 
217
  renormalized_cam = scale_cam_image(renormalized_cam)
218
+ eigencam_image_renormalized = show_cam_on_image(np.float32(img_copy)/255, renormalized_cam, use_rgb=True, image_weight=transparency)
219
 
220
  return([[img_copy, annotations],
221
+ [grayscale_cam,
222
+ renormalized_cam
223
+ visualization,
224
+ eigencam_image_renormalized]])
225