Update handler.py
Browse files- handler.py +11 -9
handler.py
CHANGED
@@ -59,15 +59,17 @@ class EndpointHandler():
|
|
59 |
# })
|
60 |
inputs = data.pop("inputs", data)
|
61 |
parameters = data.pop("parameters", {})
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
|
|
|
|
71 |
|
72 |
question = inputs["question"]
|
73 |
|
|
|
59 |
# })
|
60 |
inputs = data.pop("inputs", data)
|
61 |
parameters = data.pop("parameters", {})
|
62 |
+
if isinstance(inputs, Image.Image):
|
63 |
+
image = [inputs]
|
64 |
+
else:
|
65 |
+
try:
|
66 |
+
imageBase64 = inputs["image"]
|
67 |
+
# image = Image.open(BytesIO(base64.b64decode(imageBase64.split(",")[1].encode())))
|
68 |
+
image = Image.open(BytesIO(base64.b64decode(imageBase64)))
|
69 |
+
|
70 |
+
except:
|
71 |
+
image_url = inputs['image']
|
72 |
+
image = Image.open(requests.get(image_url, stream=True).raw).convert('RGB')
|
73 |
|
74 |
question = inputs["question"]
|
75 |
|