jeff-RQ commited on
Commit
7ef77ff
·
1 Parent(s): c4f59b2

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +6 -3
handler.py CHANGED
@@ -19,10 +19,13 @@ class EndpointHandler:
19
  data = data.pop("inputs", data)
20
  text = data.pop("text", data)
21
 
22
- image_string = base64.b64decode(data["image"])
23
- image = Image.open(io.BytesIO(image_string))
24
 
25
- inputs = self.processor(images=image, text=text, return_tensors="pt").to(self.device, torch.float16)
 
 
 
26
  generated_ids = self.model.generate(**inputs)
27
  generated_text = self.processor.batch_decode(generated_ids, skip_special_tokens=True)[0].strip()
28
 
 
19
  data = data.pop("inputs", data)
20
  text = data.pop("text", data)
21
 
22
+ image_string_1 = base64.b64decode(data["image1"])
23
+ image_1 = Image.open(io.BytesIO(image_string_1))
24
 
25
+ image_string_2 = base64.b64decode(data["image2"])
26
+ image_2 = Image.open(io.BytesIO(image_string_2))
27
+
28
+ inputs = self.processor(images=[image_1, image_2], text=text, return_tensors="pt").to(self.device, torch.float16)
29
  generated_ids = self.model.generate(**inputs)
30
  generated_text = self.processor.batch_decode(generated_ids, skip_special_tokens=True)[0].strip()
31