Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cam_full_arr[k+1] = v out of bounds #44

Closed
shifan-Z opened this issue Nov 9, 2022 · 2 comments
Closed

cam_full_arr[k+1] = v out of bounds #44

shifan-Z opened this issue Nov 9, 2022 · 2 comments

Comments

@shifan-Z
Copy link

shifan-Z commented Nov 9, 2022

Thanks for posting your excellent code!
I met some problems when using the code. In line95, the npy files store the information of classes in a training sample. The max k in line 98 is 21 for the VOC dataset, because the VOC dataset contains 21 categories. In line 99, the index will out of the bound, because k+1 can vbe 22 But cam_full_arr's size is 21. How can I do to solve the error?
And what does the line 100 mean? What is filled in the cam_full_arr[0]? I am confused.

SEAM/infer_aff.py

Lines 95 to 100 in 3212261

cam = np.load(os.path.join(args.cam_dir, name + '.npy'), allow_pickle=True).item()
cam_full_arr = np.zeros((21, orig_shape[2], orig_shape[3]), np.float32)
for k, v in cam.items():
cam_full_arr[k+1] = v
cam_full_arr[0] = (1 - np.max(cam_full_arr[1:], (0), keepdims=False))**args.alpha

Looking forward to your reply.

@YudeWang
Copy link
Owner

YudeWang commented Nov 9, 2022

Hi @shifan-Z ,
The channel number of saved CAM is 20 instead of 21.

SEAM/infer_SEAM.py

Lines 79 to 85 in 3212261

cam_dict = {}
for i in range(20):
if label[i] > 1e-5:
cam_dict[i] = norm_cam[i]
if args.out_cam is not None:
np.save(os.path.join(args.out_cam, img_name + '.npy'), cam_dict)

@shifan-Z
Copy link
Author

shifan-Z commented Nov 10, 2022

Thank you so much! So is the cam_full_arr[0] for the background?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants