The problem is that the model that you build is not dynamic for different size of images, you have to calculate the flatten size to connect the conv layer with the fully connected layer… Because you will  never know it unless you see your input image, x…
I forgot how TensorFlow deal with this, but obviously, this is not very practical to generalize the model for any image…
Best