fix variable names
Browse files- handler.py +5 -5
handler.py
CHANGED
@@ -35,15 +35,15 @@ class EndpointHandler():
|
|
35 |
inputs = data.pop("inputs", data)
|
36 |
parameters = data.pop("parameters", {})
|
37 |
|
38 |
-
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
|
44 |
with torch.no_grad():
|
45 |
out = self.model.generate(
|
46 |
-
**
|
47 |
)
|
48 |
captions = self.processor.batch_decode(out, skip_special_tokens=True)
|
49 |
|
|
|
35 |
inputs = data.pop("inputs", data)
|
36 |
parameters = data.pop("parameters", {})
|
37 |
|
38 |
+
raw_images = [Image.open(BytesIO(base64.b64decode(_img))) for _img in inputs]
|
39 |
|
40 |
+
processed_images = self.processor(images=raw_images, return_tensors="pt")
|
41 |
+
processed_images["pixel_values"] = processed_images["pixel_values"].to(device)
|
42 |
+
processed_images = {**processed_images, **parameters}
|
43 |
|
44 |
with torch.no_grad():
|
45 |
out = self.model.generate(
|
46 |
+
**processed_images
|
47 |
)
|
48 |
captions = self.processor.batch_decode(out, skip_special_tokens=True)
|
49 |
|