Grayscale input to the wgan of lesson 7

I am trying for more than 4 hours to make the very simple thing of parametrising the wgan of lesson 7 (for bedrooms) so that it uses only the 1 channel of my images (as they are grayscale) and 1 channel input noise.

I have a folder of png images and I am running it inside a script and have version 1.0.60

My get_data function look like this:

def get_data(path, bs, size, padding_size):
    def _rgb_to_gs(x):
        return x[1, :, :]
    rgb_to_gs = TfmPixel(_rgb_to_gs, order=1)
    return (GANItemList.from_folder(path, noise_sz=100, convert_mode='L')
               .transform(ds_tfms=rgb_to_gs, tfms=[[pad(padding=padding_size, mode='border')], []], size=size)

and my model is defined as

generator = basic_generator(in_size=int(args.size), n_channels=1, n_extra_layers=3)
critic = basic_critic(in_size=int(args.size), n_channels=1, n_extra_layers=3)
learn = GANLearner.wgan(data, generator, critic, switch_eval=False, opt_func = partial(optim.Adam, betas = (0.,0.99)), wd=0.)

I get the error:
RuntimeError: Given groups=1, weight of size 64 1 4 4, expected input[1, 3, 214, 155] to have 1 channels, but got 3 channels instead

I have tried it all (together):

  • defaults.cmap = ‘binary’
  • convert_mode = ‘L’
  • and I even made a TfmPixel accurately placed at ds_tfms (which I think is not at all executed as I had a print function inside)

Can you please help?
Thanks in advance

1 Like

Having the same problem too.