HenriquesLab / ZeroCostDL4Mic

ZeroCostDL4Mic: A Google Colab based no-cost toolbox to explore Deep-Learning in Microscopy
MIT License
558 stars 129 forks source link

pix2pix flags number of channels, dataset_mode #224

Closed JohannaRahm closed 1 year ago

JohannaRahm commented 1 year ago

Hi together,

I started using some notebooks in ZeroCost and love how low barrier it is to use all these amazing tools!

Here an error I came across while using pix2pix:

Number of channels

the number of channels for training/inferring with pix2pix is set to 3 by default. When using the notebook with grayscale images (=1 channel), color is predicted (see attached image). Setting the number of channels to 1 for grayscale data fixes this problem. In both cases a RGB image is saved, but with 1 channel the values remain the same throughout the channels (what we want), whereas for 3 channels the values differ (what we don't want). I also found a discussion by the authors that point out this flag.

grafik

Dataset mode

the default dataset_mode is "unaligned", which matches cyclegan network with non-matching source and target images. Pix2pix requires "aligned" images, see here.

In this PR I added --input_nc --output_nc and --dataset_mode flags to all training and prediction calls. The number of channels is set by the user by selecting grayscale or rgb from a dropdown menu in training, qc, and prediction.

Let me know what you think!

Best, Johanna

JohannaRahm commented 1 year ago

In this update I changed the naming of the added parameter and inserted a description.

The previous naming scheme was choosing between RGB and grayscale image inputs. However, if an RGB image is used as input and number of channels is set to "grayscale"/"1" the RGB image is converted to grayscale in the preprocessing functions of pix2pix, see here. This is why I adapted the name to choose the "number of channels" to predict. "1" means predicting grayscale images. In the case of RGB as input a grayscale image is predicted with the same values across the RGB channels. In the case of choosing "3" a color image is predicted, where different values across channels are predicted. "1" is set as default option, as this will probably be more relevant for the users.

JohannaRahm commented 1 year ago

Hi @guijacquemet, just wanted to remind you to take a look at my PRs (here and #225) - looking forward to your feedback!

guijacquemet commented 1 year ago

Hi @JohannaRahm , Thanks a lot for the excellent additions and all the bug fixes!

JohannaRahm commented 1 year ago

Sure! Thanks for creating this great platform 😄