drhead commited on
Commit
ebf9327
·
verified ·
1 Parent(s): f554333

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -4
app.py CHANGED
@@ -255,11 +255,9 @@ def create_cam_visualization_pil(image_pil, cam, alpha=0.6, vis_threshold=0.2):
255
  cam_rgba = np.dstack((cam_colored, cam_alpha)) # Shape: (H, W, 4)
256
 
257
  # Resize CAM to match image
258
- cam_resized = Image.fromarray(cam_rgba).resize((size, size), resample=Image.Resampling.BILINEAR)
259
 
260
- cam_resized = transforms.CenterCrop((h, w))(cam_resized).numpy()
261
-
262
- cam_image = Image.fromarray((cam_resized * 255).astype(np.uint8), mode="RGBA")
263
 
264
  # Composite over original
265
  composite = Image.alpha_composite(image_pil, cam_image)
 
255
  cam_rgba = np.dstack((cam_colored, cam_alpha)) # Shape: (H, W, 4)
256
 
257
  # Resize CAM to match image
258
+ cam_resized = Image.fromarray((cam_rgba * 255).astype(np.uint8), mode="RGBA").resize((size, size), resample=Image.Resampling.BILINEAR)
259
 
260
+ cam_image = transforms.CenterCrop((h, w))(cam_resized)
 
 
261
 
262
  # Composite over original
263
  composite = Image.alpha_composite(image_pil, cam_image)