gabrieldemarmiesse / heatmaps

MIT License
60 stars 17 forks source link

Issues with target size #8

Closed abdualhag closed 6 years ago

abdualhag commented 6 years ago

Hi, I am not sure if I understand the target size segment of the code correctly or not.


    # The quality is reduced.
    # If you have more than 8GB of RAM, you can try to increase it.
    img = image.load_img(img_path, target_size=(800, 1280))

My thought are that this is the size of the output image, heat-map. This does not appear to be the case however as the target size is always 640*480 pixels regardless of the input image size or how you change the numbers. Hence my question, is there a way to get the heat-map to be the same dimensions as the input image with no distortion?

I am looking forward to hear back from you. Thanks.

gabrieldemarmiesse commented 6 years ago

Hi! This line:

img = image.load_img(img_path, target_size=(800, 1280))

loads the image at img_path and put it in a numpy array. The target size resizes this image, in our case to 800x1280. It's then after this resizing that the image is passed through the network.

Due to the topologie of common neural networks, the image is downsampled a lot, commonly because of the max poolings.

This is why, for VGG16 for example, if the size of the image that you give to the neural network is 800x1280, you end up with a heatmap of size 37x67.

In your case, if you want a high resolution heatmaps (640x480 for example), I would advise not to use this repository. You would prefer to make your own neural network and train it for a segmentation task. This way, you can have a full control of the size of the heatmap when designing the network.

Here are some resources to get you started:

https://github.com/jocicmarko/ultrasound-nerve-segmentation https://lmb.informatik.uni-freiburg.de/people/ronneber/u-net/

If you look around in google, know that the task you're looking for is commonly called "segmentation".

abdualhag commented 6 years ago

Thanks, I must have understood this whole thing wrong. It appears that the heat-map image when saved, is saved with resolution of 640*480 regardless of the model. This however appear to have nothing to do with the real output of the heat-map code as you said as that only depends on the max pooling of the model. That being the case, it would be great if you have a link where I can find the size associated with different models.

gabrieldemarmiesse commented 6 years ago

Sure. I'll put a table on the main page.

abdualhag commented 6 years ago

Really appreciated. Thanks.

gabrieldemarmiesse commented 6 years ago

Happy to help!