What are the dimensions in your [4, 1, 224, 224] input? They should be NCHW (batch size, number of channels, height, width).
If that’s the case, then it means you have 4 examples in your batch, 1 channel (grayscale image) and 224x224 images. If you want the code to work, you need to change either your input to have 3 channels (duplicate the gray channel for RGB) or change the model to accept 1 channel images. For the second solution you need to modify the model code (e.g. by copying the source in your own codebase and changing what you need).
As seen in the Densenet source code 163, the first convolution expects 3 channels as input.