automatic-sem-image-segmentation icon indicating copy to clipboard operation
automatic-sem-image-segmentation copied to clipboard

Array reshape error

Open Shailendra-IISc opened this issue 3 years ago • 5 comments

Hello sir/Ma`am,

Thank you for sharing the important code for scientific research.

I have 21 images with size 1280 x 960 pixels and 13 sample masks with size 64 x 64 pixels. I installed all the dependencies as specified in the 'requirements.txt' file. However, when I run the most recent program, I got the following error message:

File “WassersteinGAN.py”, line 207, in init self.train_images = (self.train_images.reshape((self.train_images.shape[0], 64, 64, 1)).astype(“float32”) – 127.5)/127.5 ValueError: cannot reshape array of size 851968 into shape (52,64,64,1)

Please let me know if I can fix the above error.

Regards, Shailendra Kumar Verma

Shailendra-IISc avatar Jul 14 '22 13:07 Shailendra-IISc

I converted the mask images from 32 bit to 8 bit. Then, the code runs successfully.

Shailendra-IISc avatar Jul 15 '22 18:07 Shailendra-IISc

Dear @Shailendra-IISc Sir, Can you please provide the method by which you have created the 8-bit Image masks. Thank you.

pramethg avatar Jul 21 '22 17:07 pramethg

I used Paint.NET software to save the mask image as 8-bit type. Please make sure that the background is black and the mask is white.

Shailendra-IISc avatar Jul 22 '22 09:07 Shailendra-IISc

In addition to that, while training(the Wasserstein GAN) are you experiencing negative loss corresponding to the Discriminator?

pramethg avatar Jul 22 '22 11:07 pramethg

@Shailendra-IISc : Yes, the masks should be single-channel black&white images (i.e., 8 bit). I should probably add this to the documentation, or just change the code so that it binarizes the masks before attempting to use them for training the WGAN. I am glad it works now for you.

@pramethg: Yes, a negative loss in a Wasserstein GAN with Gradient Penalty is "normal". You can find more detailed information about this loss in general (i.e., the idea behind it, how it is calculated, and how it can be interpreted e.g. for detecting overfitting) in Reference 22 of our paper (Gulrajani, I., Ahmed, F., Arjovsky, M., Dumoulin, V. & Courville, A. in Advances in Neural Information Processing Systems 30 Vol. 30 Advances in Neural Information Processing Systems (eds I. Guyon et al.) (Neural Information Processing Systems (Nips), 2017), or the "corresponding" paper of the same authors on arxiv https://arxiv.org/pdf/1704.00028.pdf ), and you can also see how exactly the loss is implmented by looking at the source code of the WassersteinGAN.py file.

bruehle avatar Jul 22 '22 14:07 bruehle