Another GPU test
Browse files- handler.py +2 -2
handler.py
CHANGED
|
@@ -19,12 +19,12 @@ class EndpointHandler():
|
|
| 19 |
image_input = inputs["image"] if "image" in inputs else None
|
| 20 |
|
| 21 |
if text_input:
|
| 22 |
-
processor = self.processor(text=text_input, return_tensors="pt", padding=True)
|
| 23 |
with torch.no_grad():
|
| 24 |
return self.text_model(**processor).pooler_output.tolist()
|
| 25 |
elif image_input:
|
| 26 |
image = Image.open(BytesIO(base64.b64decode(image_input)))
|
| 27 |
-
processor = self.processor(images=image, return_tensors="pt")
|
| 28 |
with torch.no_grad():
|
| 29 |
return self.image_model(**processor).image_embeds.tolist()
|
| 30 |
else:
|
|
|
|
| 19 |
image_input = inputs["image"] if "image" in inputs else None
|
| 20 |
|
| 21 |
if text_input:
|
| 22 |
+
processor = self.processor(text=text_input, return_tensors="pt", padding=True).to(device)
|
| 23 |
with torch.no_grad():
|
| 24 |
return self.text_model(**processor).pooler_output.tolist()
|
| 25 |
elif image_input:
|
| 26 |
image = Image.open(BytesIO(base64.b64decode(image_input)))
|
| 27 |
+
processor = self.processor(images=image, return_tensors="pt").to(device)
|
| 28 |
with torch.no_grad():
|
| 29 |
return self.image_model(**processor).image_embeds.tolist()
|
| 30 |
else:
|