You are setting the input channels of the first convolution to a single channel in these lines of code:
conv = nn.Conv2d(3, 64, kernel_size=5, stride=2, padding=3, bias=False)
w = (m.features.conv0.weight.sum(1)).unsqueeze(1)
conv.weight = nn.Parameter(w)

while you are passing an input with 3 channels.
Either leave the convolution as it is with in_channels=3 or change the number of channels in your input tensor to a single channel, e.g. by slicing.