I am running my Flask app on Ubuntu VPS (linode) as server. I am capturing image from android studio sending it to flask server to get response. Image is being sent as base64 string from android studio.
But the response is too slow when using request.form.to_dict()
. Both ubuntu vps and android app are running on different IP.
I've put timestamps on different processes and found this request.form.to_dict()
is the problem taking around 22 to 35 secs.
I am also using image compressing techniques on my android studio code but still too much time.
- Tried on gunicorn with nginx but same.
- threaded = True
- Images are of around 400kb to 500kb size.
Kindly help me to figure out this issue.
Below is my flask code:
@app.route('/predict', methods=['POST', 'GET'])
def predict():
if request.method == 'POST':
file = request.form.to_dict()['upload'] # 22.2491 sec
b64_string = file
image = imread(io.BytesIO(base64.b64decode(b64_string))) #0.0023 sec
image = cv2.cvtColor(np.array(image), cv2.COLOR_BGR2RGB) # 0.000171 sec
.....
.....
.....