Files changed (1) hide show
  1. handler.py +2 -1
handler.py CHANGED
@@ -4,6 +4,7 @@ from PIL import Image
4
  import torch
5
  import os
6
  from io import BytesIO
 
7
  from transformers import BlipForConditionalGeneration, BlipProcessor
8
  # -
9
 
@@ -34,7 +35,7 @@ class EndpointHandler():
34
  inputs = data.pop("inputs", data)
35
  parameters = data.pop("parameters", {})
36
 
37
- raw_images = [Image.open(BytesIO(_img)) for _img in inputs]
38
 
39
  processed_image = self.processor(images=raw_images, return_tensors="pt")
40
  processed_image["pixel_values"] = processed_image["pixel_values"].to(device)
 
4
  import torch
5
  import os
6
  from io import BytesIO
7
+ import base64
8
  from transformers import BlipForConditionalGeneration, BlipProcessor
9
  # -
10
 
 
35
  inputs = data.pop("inputs", data)
36
  parameters = data.pop("parameters", {})
37
 
38
+ raw_images = [Image.open(BytesIO(base64.b64decode(_img))) for _img in inputs]
39
 
40
  processed_image = self.processor(images=raw_images, return_tensors="pt")
41
  processed_image["pixel_values"] = processed_image["pixel_values"].to(device)