Fastai v2: pretrained UNet with different number of channels

Aha. I think my problem was that I wasn’t passing normalize=False. When I do pass that, the unet is created without a problem. So, in my case (1 input channel, 2 output channels), this is working:

learn = unet_learner(dls = dls, 
                     arch = resnet18, 
                     pretrained = True,
                     normalize = False,
                     n_in=1, 
                     n_out=2, 
                     loss_func = fastai.losses.MSELossFlat())
2 Likes