oscarfu0501 commited on
Commit
6451c94
·
verified ·
1 Parent(s): f542585

Upload handler.py

Browse files
Files changed (1) hide show
  1. handler.py +5 -5
handler.py CHANGED
@@ -28,12 +28,12 @@ class EndpointHandler():
28
  # }
29
 
30
  inputs = data.get("inputs")
31
- imageURL = inputs.get("image")
32
  text = inputs.get("text")
33
- print(imageURL)
34
- print(text)
35
- image = Image.open(requests.get(imageURL, stream=True).raw)
36
- # image = Image.open(BytesIO(base64.b64decode(imageData)))
37
  inputs = self.processor(text=text, images=image, return_tensors="pt", padding=True)
38
  outputs = self.model(**inputs)
39
  embeddings = outputs.image_embeds.detach().numpy().flatten().tolist()
 
28
  # }
29
 
30
  inputs = data.get("inputs")
31
+ imageBase64 = inputs.get("image")
32
  text = inputs.get("text")
33
+ # print(imageURL)
34
+ # print(text)
35
+ # image = Image.open(requests.get(imageURL, stream=True).raw)
36
+ image = Image.open(BytesIO(base64.b64decode(imageBase64.split(",")[1].encode())))
37
  inputs = self.processor(text=text, images=image, return_tensors="pt", padding=True)
38
  outputs = self.model(**inputs)
39
  embeddings = outputs.image_embeds.detach().numpy().flatten().tolist()