convert contexts to list if necessary and remove unnecessary construc… · EvolvingLMMs-Lab/lmms-eval@cd87420 (original) (raw)

Original file line number Diff line number Diff line change
@@ -228,10 +228,13 @@ def _collate(x):
228 228 until = [until]
229 229 elif not isinstance(until, list):
230 230 raise ValueError(f"Expected `gen_kwargs['until']` to be of type Union[str,list] but got {type(until)}")
231 +
232 +if isinstance(contexts, tuple):
233 +contexts = list(contexts)
234 +
231 235 for i in range(len(contexts)):
232 236 if "" in contexts[i]:
233 237 contexts[i] = contexts[i].replace("", "")
234 -questions = [self.prompt.format(visual_path, context) for visual_path, context in zip(visual_paths, contexts)]
235 238
236 239 # Similar to llava, is visual paths has len 0
237 240 # Then nothing will be executed