Upload handler.py
Browse files- handler.py +5 -5
handler.py
CHANGED
@@ -28,12 +28,12 @@ class EndpointHandler():
|
|
28 |
# }
|
29 |
|
30 |
inputs = data.get("inputs")
|
31 |
-
|
32 |
text = inputs.get("text")
|
33 |
-
print(imageURL)
|
34 |
-
print(text)
|
35 |
-
image = Image.open(requests.get(imageURL, stream=True).raw)
|
36 |
-
|
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()
|