File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 )
You can’t perform that action at this time.
0 commit comments