Spaces:
Sleeping
Sleeping
Commit
·
4fe4bfa
1
Parent(s):
20700c3
Debug: tensour access
Browse files
yolov8.py
CHANGED
@@ -35,13 +35,10 @@ def draw_detections(boxes, colors, names, img):
|
|
35 |
|
36 |
def generate_cam_image(model, target_layers, tensor, rgb_img, boxes):
|
37 |
cam = EigenCAM(model, target_layers)
|
38 |
-
|
|
|
39 |
img_float = np.float32(rgb_img) / 255
|
40 |
-
|
41 |
-
# Generate Grad-CAM
|
42 |
cam_image = show_cam_on_image(img_float, grayscale_cam, use_rgb=True)
|
43 |
-
|
44 |
-
# Renormalize Grad-CAM inside bounding boxes
|
45 |
renormalized_cam = np.zeros(grayscale_cam.shape, dtype=np.float32)
|
46 |
for x1, y1, x2, y2 in boxes:
|
47 |
renormalized_cam[y1:y2, x1:x2] = scale_cam_image(grayscale_cam[y1:y2, x1:x2].copy())
|
|
|
35 |
|
36 |
def generate_cam_image(model, target_layers, tensor, rgb_img, boxes):
|
37 |
cam = EigenCAM(model, target_layers)
|
38 |
+
model_output = model(tensor)[0] # Adjust based on output structure
|
39 |
+
grayscale_cam = cam(tensor, targets=model_output)[0, :, :]
|
40 |
img_float = np.float32(rgb_img) / 255
|
|
|
|
|
41 |
cam_image = show_cam_on_image(img_float, grayscale_cam, use_rgb=True)
|
|
|
|
|
42 |
renormalized_cam = np.zeros(grayscale_cam.shape, dtype=np.float32)
|
43 |
for x1, y1, x2, y2 in boxes:
|
44 |
renormalized_cam[y1:y2, x1:x2] = scale_cam_image(grayscale_cam[y1:y2, x1:x2].copy())
|