Update handler.py
Browse files- handler.py +6 -2
handler.py
CHANGED
|
@@ -30,8 +30,12 @@ class EndpointHandler():
|
|
| 30 |
"""
|
| 31 |
inputs = data.pop("inputs", data)
|
| 32 |
parameters = data.pop("parameters", {})
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
processed_images = self.processor(images=raw_images, return_tensors="pt")
|
| 37 |
processed_images["pixel_values"] = processed_images["pixel_values"].to(device)
|
|
|
|
| 30 |
"""
|
| 31 |
inputs = data.pop("inputs", data)
|
| 32 |
parameters = data.pop("parameters", {})
|
| 33 |
+
|
| 34 |
+
if isinstance(inputs, Image.Image):
|
| 35 |
+
raw_images = [inputs]
|
| 36 |
+
else:
|
| 37 |
+
inputs = isinstance(inputs, str) and [inputs] or inputs
|
| 38 |
+
raw_images = [Image.open(BytesIO(base64.b64decode(_img))) for _img in inputs]
|
| 39 |
|
| 40 |
processed_images = self.processor(images=raw_images, return_tensors="pt")
|
| 41 |
processed_images["pixel_values"] = processed_images["pixel_values"].to(device)
|