Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
kennymckormick committed Mar 22, 2024
1 parent 393da76 commit 24acd90
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion vlmeval/vlm/llava.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,16 @@ def generate(self, image_path, prompt, dataset=None):
inputs = self.processor(prompt_wtmpl, image, return_tensors='pt').to('cuda')
output = self.model.generate(**inputs, **self.kwargs)
answer = self.processor.decode(output[0], skip_special_token=True)
if '<s>' in answer:
answer = answer.replace('<s>', '')
answer = answer.strip()

lt = len(prompt_wtmpl)
if prompt_wtmpl == answer[:lt]:
answer = answer[lt:]
answer = answer.split('</s>')[0]

if '</s>' in answer:
answer = answer.split('</s>')[0]
answer = answer.strip()

return answer

0 comments on commit 24acd90

Please sign in to comment.