Update app.py
Browse files
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 |
-
|
| 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)
|