Runtime Error : Given groups=1, weight of size [64, 3, 7, 7], expected input[1, 4, 224, 224] to have 3 channels, but got 4 channels instead

This is my model , i used transfer learning , densenet121 , but when i tried to deploy with flask i keep getting the above error after i upload the picture.
Any help would be highly appreciated.


It seems that [64, 3, 7, 7] is the first conv layer in the network. It receives the input with channel_in=3, but in your use case, the shape of input is [1, 4, 224, 224].

You could check the shape of your input, or having a modification on your network to fit the input size.