Skip to content

Commit c837cfb

Browse files
authored
[Bugfix] Fix handling of encode_video output in vllm.py so each frame’s Base64 (#754)
* Fix handling of encode_video output in vllm.py so each frame’s Base64 is sent correctly * Update vllm.py * Update vllm.py
1 parent ad31c4c commit c837cfb

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

lmms_eval/models/vllm.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,10 @@ def encode_video(self, video_path):
150150
def flatten(self, input):
151151
new_list = []
152152
for i in input:
153-
for j in i:
154-
new_list.append(j)
153+
if isinstance(i, (list, tuple)):
154+
new_list.extend(i)
155+
else:
156+
new_list.append(i)
155157
return new_list
156158

157159
def generate_until(self, requests) -> List[str]:
@@ -203,7 +205,7 @@ def generate_until(self, requests) -> List[str]:
203205
messages = [{"role": "user", "content": []}]
204206
# When there is no image token in the context, append the image to the text
205207
messages[0]["content"].append({"type": "text", "text": contexts})
206-
for img in imgs:
208+
for img in self.flatten(imgs):
207209
messages[0]["content"].append({"type": "image_url", "image_url": {"url": f"data:image/png;base64,{img}"}})
208210

209211
batched_messages.append(messages)

0 commit comments

Comments
 (0)