debugging error not seen locally
Browse files- handler.py +5 -0
handler.py
CHANGED
|
@@ -15,14 +15,19 @@ class EndpointHandler():
|
|
| 15 |
|
| 16 |
def __call__(self, data):
|
| 17 |
inputs = data.pop("inputs", None)
|
|
|
|
| 18 |
text_input = inputs["text"] if "text" in inputs else None
|
| 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():
|
|
|
|
| 15 |
|
| 16 |
def __call__(self, data):
|
| 17 |
inputs = data.pop("inputs", None)
|
| 18 |
+
print(inputs)
|
| 19 |
text_input = inputs["text"] if "text" in inputs else None
|
| 20 |
image_input = inputs["image"] if "image" in inputs else None
|
| 21 |
|
| 22 |
if text_input:
|
| 23 |
+
print("in text mode")
|
| 24 |
+
print(text_input)
|
| 25 |
processor = self.processor(text=text_input, return_tensors="pt", padding=True)
|
| 26 |
with torch.no_grad():
|
| 27 |
return self.text_model(**processor).pooler_output.tolist()
|
| 28 |
elif image_input:
|
| 29 |
+
print("in image mode")
|
| 30 |
+
print(image_input)
|
| 31 |
image = Image.open(BytesIO(base64.b64decode(image_input)))
|
| 32 |
processor = self.processor(images=image, return_tensors="pt")
|
| 33 |
with torch.no_grad():
|