It seems you’ve wrapped all modules into an nn.Sequential block.
If that’s the case, you are removing the flattening, which is used here 107 directly in the forward method.
You could keep the original architecture and change both layers by reassigning the new layers:
model = models.resnet18()
model.conv1 = ...

Or by adding an nn.Flatten() module inside the nn.Sequential.