zhoubolei / CAM

Class Activation Mapping
http://cnnlocalization.csail.mit.edu/
MIT License
1.85k stars 467 forks source link

There seems an error in mergeTenCrop.m #10

Closed hshustc closed 7 years ago

hshustc commented 7 years ago

As far as I can see, the size of heatmap for each testing image should be 224-224. So in mergeTenCrop.m, the size of input, i.e. CAMmap_crops, is expected to be 224-224-10, not 256-256-10. And the size of cropImgSet should also be changed to 224-224-3-10.

zhoubolei commented 7 years ago

Take a look at https://github.com/metalbubble/CAM/blob/master/prepare_image.m, the 224x224 crops are generated from the original 256x256 image, so in the mergeTenCrop, it will merge the 10 crops back to the 256x256 image, following the same sampling coordinates in the prepare_image.m

hshustc commented 7 years ago

Yes, I have seen that code. Each heatmap corresponds to a 224*224 area of the original input image (256-256). However, the indices in mergeTenCrop.m is actually [1, 1], as a result of which, the output alignImgMean is simply the mean of 10 heatmaps. By contrast, in prepare_image.m', theindices` is [1,33].

zhoubolei commented 7 years ago

Oh, there was a error in the demo.m. I just fixed it, now it could correctly merge the ten crops. Thanks a lot for reporting the error, @hshustc !

hshustc commented 7 years ago

You are welcome. Thanks for sharing the code, which helps me a lot. @metalbubble