Thanks for the info.
The batch dimensions are indeed different for your data and target as the error message suggests.
I think your reshape in this line of code seems to create more samples for the data:
X = np.array([i[0] for i in train]).reshape(-1, 1, input_height, input_width) /255

The difference is a factor of 4, so it might be your input_height or input_width are too small?