sooh-j commited on
Commit
ebceac4
1 Parent(s): ee0d8ea

Update handler.py

Browse files
Files changed (1) hide show
  1. 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
- try:
64
- imageBase64 = inputs["image"]
65
- # image = Image.open(BytesIO(base64.b64decode(imageBase64.split(",")[1].encode())))
66
- image = Image.open(BytesIO(base64.b64decode(imageBase64)))
67
-
68
- except:
69
- image_url = inputs['image']
70
- image = Image.open(requests.get(image_url, stream=True).raw).convert('RGB')
 
 
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