I have a Flask API that serves a TensorFlow model on a POST request ("/predict"). However, when I call this POST request from the frontend, the request ends up taking more than 5 minutes and times out, resulting in a 504 error.
I understand completely why there is a limit on requests of 5 minutes, but what I don't understand is why my code ends up taking 5 minutes on the PythonAnywhere server wheras on my local machine, it takes at most 1 minute.
After deubbing, I have identified that the last line of code to be executed is the TensorFlow line in my code:
tf.io.read_file(path_to_img)
This apparently ends up taking 5 minutes. However, on my system, this takes no more than 30 seconds.
This line basically reads in a PNG image by downloading it.
What could be wrong with this?