From 85c536fb8414a3a62ea929e51b6b26a48777a4b8 Mon Sep 17 00:00:00 2001 From: Luxun Huang Date: Fri, 12 Oct 2018 18:27:27 +0800 Subject: [PATCH] Add type bytes, then You can read image file by yourself. --- cognitive_face/util.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cognitive_face/util.py b/cognitive_face/util.py index d506ad8..5549ff9 100644 --- a/cognitive_face/util.py +++ b/cognitive_face/util.py @@ -134,6 +134,10 @@ def parse_image(image): headers = {'Content-Type': 'application/octet-stream'} data = open(image, 'rb').read() return headers, data, None + elif type(image) == bytes: # You can read image file by yourself. + headers = {'Content-Type': 'application/octet-stream'} + data = image + return headers, data, None else: # Default treat it as a URL (string). headers = {'Content-Type': 'application/json'} json = {'url': image}