brucechou1983 / CheXNet-Keras

This project is a tool to build CheXNet-like models, written in Keras.
MIT License
294 stars 145 forks source link

Output of Cam doesn't match the bounding box #29

Open sriniwaas opened 6 years ago

sriniwaas commented 6 years ago

@brucechou1983 : After training, using cam.py, I am getting the predicted cam output and bounding box mismatch. Please help.

screen shot 2018-03-20 at 1 44 55 pm
walterwang commented 6 years ago

were u able to find a solution on this?

jennyzu commented 5 years ago

I have the same issue. Does anybody have a solution or idea?

Sadam1195 commented 5 years ago

@jennyzu @walterwang I don't see any normalization (with imagenet_mean and imagenet_std values) in cam.py since transform_batch_images is not called. I think due to this test.py and cam.py return different predictions for same images hence the box doesn't fit right on heatmap. As I understand this normalization is a part of input pipeline during training, so this function should be called in cam.py, too. When you include transform_batch_images in cam.py output will be correct heatmap so you'll get correct bounding box.

gmarceca commented 5 years ago

In addition to @Sadam1195 comment I am afraid there is a bug here https://github.com/brucechou1983/CheXNet-Keras/blob/master/cam.py#L54 and class_weights[index] should be replaced by class_weights[:, index] in order to sum across all last conv layer filters (1024) for a given index. You can see an example here https://github.com/jacobgil/keras-cam/blob/master/cam.py#L34

monteiro141 commented 2 years ago

In addition to @Sadam1195 comment I am afraid there is a bug here https://github.com/brucechou1983/CheXNet-Keras/blob/master/cam.py#L54 and class_weights[index] should be replaced by class_weights[:, index] in order to sum across all last conv layer filters (1024) for a given index. You can see an example here https://github.com/jacobgil/keras-cam/blob/master/cam.py#L34

By adding class_weights[:, index] my final grad cam is weird

image