Skip to content

Commit

Permalink
blip.py import and output truncation fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Oscar Lo committed Mar 28, 2024
1 parent c7a5ae5 commit a5378a8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions open_flamingo/eval/eval_models/blip.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import torch

from transformers import Blip2Processor, Blip2ForConditionalGeneration
from models.eval_model import BaseEvalModel
from eval_models.eval_model import BaseEvalModel
from utils import unwrap_model
from transformers.modeling_outputs import CausalLMOutputWithPast

Expand Down Expand Up @@ -92,7 +92,8 @@ def get_outputs(
)

# Extract only the new gnerated tokens
outputs = outputs[:, len(input_ids[0]) :]
if not unwrap_model(self.model).config.is_encoder_decoder:
outputs = outputs[:, len(input_ids[0]) :]

return self.tokenizer.batch_decode(outputs, skip_special_tokens=True)

Expand Down

0 comments on commit a5378a8

Please sign in to comment.