Update handler.py
Browse files- handler.py +4 -3
handler.py
CHANGED
|
@@ -16,12 +16,13 @@ class EndpointHandler():
|
|
| 16 |
self.model.eval()
|
| 17 |
|
| 18 |
def __call__(self, data: Dict[str, Any]) -> Dict[str, Any]:
|
| 19 |
-
|
|
|
|
| 20 |
|
| 21 |
if not encoded_images:
|
| 22 |
return {"captions": [], "error": "No images provided"}
|
| 23 |
|
| 24 |
-
texts =
|
| 25 |
|
| 26 |
try:
|
| 27 |
raw_images = [Image.open(BytesIO(base64.b64decode(img))).convert("RGB") for img in encoded_images]
|
|
@@ -41,4 +42,4 @@ class EndpointHandler():
|
|
| 41 |
return {"captions": captions}
|
| 42 |
except Exception as e:
|
| 43 |
print(f"Error during processing: {str(e)}")
|
| 44 |
-
return {"captions": [], "error": str(e)}
|
|
|
|
| 16 |
self.model.eval()
|
| 17 |
|
| 18 |
def __call__(self, data: Dict[str, Any]) -> Dict[str, Any]:
|
| 19 |
+
input_data = data.get("inputs", {})
|
| 20 |
+
encoded_images = input_data.get("images")
|
| 21 |
|
| 22 |
if not encoded_images:
|
| 23 |
return {"captions": [], "error": "No images provided"}
|
| 24 |
|
| 25 |
+
texts = input_data.get("texts", ["a photography of"] * len(encoded_images))
|
| 26 |
|
| 27 |
try:
|
| 28 |
raw_images = [Image.open(BytesIO(base64.b64decode(img))).convert("RGB") for img in encoded_images]
|
|
|
|
| 42 |
return {"captions": captions}
|
| 43 |
except Exception as e:
|
| 44 |
print(f"Error during processing: {str(e)}")
|
| 45 |
+
return {"captions": [], "error": str(e)}
|