Skip to content

CAM Mask Shape #27

@oseymour

Description

@oseymour

Hello! I'm encountering the following error:

ValueError
This cell raised an exception: ValueError('operands could not be broadcast together with shapes (982,748,3) (748,982,3) ')

Here's my code:

<relevant imports here>

model = YOLO(<path to torch file>)

target_layers = [model.model.model[-2]]

cam = EigenCAM(model, target_layers, task="cls")
grayscale_cam = cam(
    frame,
    eigen_smooth=True,
)[0, :, :]

cam_image = show_cam_on_image(frame / 255, grayscale_cam, use_rgb=True)
plt.figure()
plt.imshow(cam_image)
plt.show()

My input, frame, has the correct dimensions of (784, 982, 3). When I view the CAM mask on it's own it has the right orientation but the dimensions are not correct. When I try transposing it, the dimensions match but then the orientation is not correct.

For now I'll just resize the CAM mask but I thought you might want to know the output dimensions are not correct.

Let me know if you want my input files or any other info to debug this. It's a project at work so I can't share all details but I can try to find public data that replicates my issue.

Thank you! Your repo is meeting my exact needs!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions