Skip to content

Commit

Permalink
Merge pull request #61 from tupini07/patch-1
Browse files Browse the repository at this point in the history
Fix typo in Qwen-VL that was causing "reference before assignment"
  • Loading branch information
Luodian authored Apr 23, 2024
2 parents 3dcd015 + ed17129 commit d8a3a99
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lmms_eval/models/qwen_vl.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,21 +228,25 @@ def _collate(x):
until = [until]
elif not isinstance(until, list):
raise ValueError(f"Expected `gen_kwargs['until']` to be of type Union[str,list] but got {type(until)}")

if isinstance(contexts, tuple):
contexts = list(contexts)

for i in range(len(contexts)):
if "<image>" in contexts[i]:
context[i] = contexts[i].replace("<image>", "")
questions = [self.prompt.format(visual_path, context) for visual_path, context in zip(visual_paths, contexts)]
contexts[i] = contexts[i].replace("<image>", "")

# Similar to llava, is visual paths has len 0
# Then nothing will be executed
query = []
for visual_path, context in zip(visual_paths, contexts):
query.append({"image": visual_path})
query.append({"text": context})

if len(visual_paths) == 0:
for context in contexts:
query.append({"text": context})
else:
for visual_path, context in zip(visual_paths, contexts):
query.append({"image": visual_path})
query.append({"text": context})


questions = self.tokenizer.from_list_format(query)
input_ids = self.tokenizer(questions, return_tensors="pt", padding="longest")
Expand Down

0 comments on commit d8a3a99

Please sign in to comment.