I'm building a flask image classification service and I'm trying to use cv2 to read the POSTed image.
Here's the postman post setup:
On the server side, I have
@app.route("/inference", methods=["POST"])
def inference():
img = request.files["img"]
img = cv2.imread(str(img))[...,::-1] # 1
img = cv2.imread(img)[...,::-1] # 2
...
I wanted to use cv2 because I will needed to resize the image later. However, I'm getting errors:
for "# 1", I'm getting:
TypeError: bad argument type for built-in operation
for "# 2", I'm getting:
TypeError: 'NoneType' object is not subscriptable
Note that cv2.imread()
is working fine on my local, and I suspect it's the file/class type of the request object.
Any help is appreciated!