BAMresearch / automatic-sem-image-segmentation

Workflow for Simulation and Automatic Semantic Segmentation of Electron Microscopy Images
Other
41 stars 10 forks source link

Array reshape error #2

Open Shailendra-IISc opened 2 years ago

Shailendra-IISc commented 2 years ago

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 commented 2 years ago

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

pramethg commented 2 years ago

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

Shailendra-IISc commented 2 years ago

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.

pramethg commented 2 years ago

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

bruehle commented 2 years ago

@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.