cv2.imread failing when deployed to aws beanstalk

asked 2018-07-01 16:03:24 -0500

saikiran236 gravatar image

The following is my code, where I read an image file (using opencv) and do face recognition (dlib) and face swapping using opencv.

My Server Setup: Elastic beasnktalk (flask) OPENCV 3.4.1 AND PYTHON VERSION 3.6.5

import cv2
from flask import Flask
import os

def handleHTTPPostRequest():
    imagePath = f'{os.getcwd()}/input.png'
    print('image path is', imagePath)
    im = cv2.imread(imagePath,cv2.IMREAD_COLOR)
#Do face recognition and faceswapping

return 'success'

This is giving expected output on my local machine(Ubuntu 18.04) no matter how many times I execute it.

I moved this to elastic beanstalk(CentOS) with necessary setup. The request runs fine only for the first time. The successive POST calls always get stuck at cv2.imread and doesn’t throw any error (print(im) never gets printed)

I have restarted the server multiple times, looks like the post call only works the very first time and cv2.imread() is stuck after the first post call.What am I missing

edit retag flag offensive close merge delete