junyanz / pytorch-CycleGAN-and-pix2pix

Image-to-Image Translation in PyTorch
Other
22.93k stars 6.31k forks source link

Setting "--norm" to "none" #1237

Open lizard24 opened 3 years ago

lizard24 commented 3 years ago

Hi,

I am trying to train a cycleGAN with impaired 128x128 greyscale images that I pre-processed already.

When I am setting the "--norm" parameter to "none", "idt" and "fake" images are completely empty during training, while the "real" images are fine. If I keep the default setting for "--norm", this is not a problem.

Also, setting "preprocess" to "none" doesn't work for some reason, the training doesn't start (it works if I keep it in default and set "--load_size" and "crop_size" to "128").

I noticed that the images that are put out during the training are RGB images although I changed "--input_nc" and "--output_nc" to "1". Why?

My guess is I don't completely understand what "--preprocess" and "--norm" do. Could someone please explain so that I understand what the problem is? Alternatively, can anyone point me to a resource where the parameters are explained in more detail (other than the options python scripts)?

Many thanks, Lisa

icelandno1 commented 2 years ago

Very good question, I have the same problem and await guidance.

junyanz commented 2 years ago

--norm refers to using instance normalization or batch normalization [instance | batch | none]. See this line. You probably don't want to touch it.

--preprocess is for data preprocessing. See this line.

--preprocess None doesn't work for every dataset. If your image comes in different sizes, you might crash the training.

taesungp commented 2 years ago

When we save images for visualization, we convert the image to a 3-channel tensor, even if --input_nc and --output_nc are 1. (link). This could be the reason?

This is a guess, but if --norm is set to "none", there is no adjustment on scaling. And CycleGAN networks are initialized with a small variance closed to zero. Therefore, the final output of the generator network may be very small (very small weights are multiplied at every layer without normalization) and it may appear "empty". Could you try setting --init_gain 1.0 and see if the outputs look less empty?