Jeney commited on
Commit
1de5e91
1 Parent(s): 781701c

Fix image parsing

Browse files
Files changed (1) hide show
  1. handler.py +3 -0
handler.py CHANGED
@@ -1,6 +1,8 @@
1
  import torch
 
2
 
3
  from typing import Any, Dict
 
4
  from transformers import ViltProcessor, ViltForQuestionAnswering
5
 
6
 
@@ -15,6 +17,7 @@ class EndpointHandler:
15
  # process input
16
  inputs = data.pop("inputs", data)
17
  image = inputs["image"]
 
18
  text = inputs["text"]
19
 
20
  # preprocess
 
1
  import torch
2
+ import io
3
 
4
  from typing import Any, Dict
5
+ from PIL import Image
6
  from transformers import ViltProcessor, ViltForQuestionAnswering
7
 
8
 
 
17
  # process input
18
  inputs = data.pop("inputs", data)
19
  image = inputs["image"]
20
+ image = Image.open(io.BytesIO(eval(image)))
21
  text = inputs["text"]
22
 
23
  # preprocess