Update handler.py
Browse files- handler.py +2 -2
handler.py
CHANGED
|
@@ -18,7 +18,7 @@ class EndpointHandler():
|
|
| 18 |
if "image" in inputs:
|
| 19 |
# decode base64 image to PIL
|
| 20 |
image = Image.open(BytesIO(base64.b64decode(inputs['image'])))
|
| 21 |
-
inputs = self.processor(images=image, text=None, return_tensors="pt", padding=True)
|
| 22 |
|
| 23 |
image_embeds = self.model.get_image_features(
|
| 24 |
pixel_values=inputs["pixel_values"]
|
|
@@ -27,7 +27,7 @@ class EndpointHandler():
|
|
| 27 |
return image_embeds[0].tolist()
|
| 28 |
if "text" in inputs:
|
| 29 |
text = inputs['text']
|
| 30 |
-
inputs = self.processor(images=None, text=text, return_tensors="pt", padding=True)
|
| 31 |
|
| 32 |
text_embeds = self.model.get_text_features(
|
| 33 |
input_ids=inputs["input_ids"], attention_mask=inputs["attention_mask"]
|
|
|
|
| 18 |
if "image" in inputs:
|
| 19 |
# decode base64 image to PIL
|
| 20 |
image = Image.open(BytesIO(base64.b64decode(inputs['image'])))
|
| 21 |
+
inputs = self.processor(images=image, text=None, return_tensors="pt", padding=True).to(device)
|
| 22 |
|
| 23 |
image_embeds = self.model.get_image_features(
|
| 24 |
pixel_values=inputs["pixel_values"]
|
|
|
|
| 27 |
return image_embeds[0].tolist()
|
| 28 |
if "text" in inputs:
|
| 29 |
text = inputs['text']
|
| 30 |
+
inputs = self.processor(images=None, text=text, return_tensors="pt", padding=True).to(device)
|
| 31 |
|
| 32 |
text_embeds = self.model.get_text_features(
|
| 33 |
input_ids=inputs["input_ids"], attention_mask=inputs["attention_mask"]
|