Update handler.py
Browse files- handler.py +10 -11
handler.py
CHANGED
@@ -89,18 +89,17 @@ class EndpointHandler:
|
|
89 |
prompt = self.processor.apply_chat_template(
|
90 |
messages, add_generation_prompt=True
|
91 |
)
|
|
|
|
|
|
|
92 |
|
93 |
-
|
94 |
-
processed_inputs =
|
95 |
-
|
96 |
-
|
97 |
-
generated_ids
|
98 |
-
|
99 |
-
|
100 |
-
generated_texts = self.processor.batch_decode(
|
101 |
-
generated_ids,
|
102 |
-
skip_special_tokens=True,
|
103 |
-
)
|
104 |
predictions.append(generated_texts[0])
|
105 |
|
106 |
return {"predictions": predictions}
|
|
|
89 |
prompt = self.processor.apply_chat_template(
|
90 |
messages, add_generation_prompt=True
|
91 |
)
|
92 |
+
processed_inputs = self.processor(
|
93 |
+
text=prompt, images=images, return_tensors="pt"
|
94 |
+
).to(self.model.device)
|
95 |
|
96 |
+
generated_ids = self.model.generate(
|
97 |
+
**processed_inputs, generation_config=generation_config
|
98 |
+
)
|
99 |
+
generated_texts = self.processor.batch_decode(
|
100 |
+
generated_ids,
|
101 |
+
skip_special_tokens=True,
|
102 |
+
)
|
|
|
|
|
|
|
|
|
103 |
predictions.append(generated_texts[0])
|
104 |
|
105 |
return {"predictions": predictions}
|