ckandemir commited on
Commit
9098bd2
·
1 Parent(s): c4fb714

Update handler.py

Browse files
Files changed (1) hide show
  1. 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
- encoded_images = data.get("images")
 
20
 
21
  if not encoded_images:
22
  return {"captions": [], "error": "No images provided"}
23
 
24
- texts = data.get("texts", ["a photography of"] * len(encoded_images))
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)}