drhead commited on
Commit
b0673d8
·
verified ·
1 Parent(s): bc968aa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -246,7 +246,7 @@ def create_cam_visualization_pil(image_pil, cam, alpha=0.6, vis_threshold=0.2):
246
  cam_alpha = (cam >= vis_threshold).astype(np.float32) * alpha # Alpha mask
247
  cam_rgba = np.dstack((cam_rgb, cam_alpha)) # Shape: (H, W, 4)
248
 
249
- # Resize CAM to match image
250
  cam_pil = Image.fromarray((cam_rgba * 255).astype(np.uint8), mode="RGBA")
251
  cam_pil = cam_pil.resize((216,216), resample=Image.Resampling.NEAREST)
252
 
@@ -255,7 +255,7 @@ def create_cam_visualization_pil(image_pil, cam, alpha=0.6, vis_threshold=0.2):
255
  cam_pil = transforms.CenterCrop((h, w))(cam_pil)
256
 
257
  # Composite over original
258
- composite = Image.alpha_composite(image_pil, cam_image)
259
 
260
  return composite
261
 
 
246
  cam_alpha = (cam >= vis_threshold).astype(np.float32) * alpha # Alpha mask
247
  cam_rgba = np.dstack((cam_rgb, cam_alpha)) # Shape: (H, W, 4)
248
 
249
+ # Coarse upscale for CAM output -- keeps "blocky" effect that is truer to what is measured
250
  cam_pil = Image.fromarray((cam_rgba * 255).astype(np.uint8), mode="RGBA")
251
  cam_pil = cam_pil.resize((216,216), resample=Image.Resampling.NEAREST)
252
 
 
255
  cam_pil = transforms.CenterCrop((h, w))(cam_pil)
256
 
257
  # Composite over original
258
+ composite = Image.alpha_composite(image_pil, cam_pil)
259
 
260
  return composite
261