Update handler.py
Browse files- handler.py +3 -2
handler.py
CHANGED
|
@@ -14,10 +14,11 @@ class EndpointHandler:
|
|
| 14 |
|
| 15 |
def __call__(self, data: Dict[str, Any]) -> Dict[str, str]:
|
| 16 |
# process input
|
| 17 |
-
image = data.pop("image", data)
|
| 18 |
text = data.pop("text", data)
|
| 19 |
|
| 20 |
-
|
|
|
|
| 21 |
|
| 22 |
inputs = self.processor(images=image, text=prompt, return_tensors="pt").to(self.device)
|
| 23 |
generated_ids = self.model.generate(**inputs)
|
|
|
|
| 14 |
|
| 15 |
def __call__(self, data: Dict[str, Any]) -> Dict[str, str]:
|
| 16 |
# process input
|
| 17 |
+
# image = data.pop("image", data)
|
| 18 |
text = data.pop("text", data)
|
| 19 |
|
| 20 |
+
image_string = base64.b64decode(data["image"])
|
| 21 |
+
image = Image.open(io.BytesIO(image_string))
|
| 22 |
|
| 23 |
inputs = self.processor(images=image, text=prompt, return_tensors="pt").to(self.device)
|
| 24 |
generated_ids = self.model.generate(**inputs)
|