Update modeling_gpt2vision.py
Browse files- modeling_gpt2vision.py +4 -1
modeling_gpt2vision.py
CHANGED
|
@@ -75,7 +75,7 @@ class GPT2Vision(PreTrainedModel):
|
|
| 75 |
|
| 76 |
# Tokenize the question
|
| 77 |
prompt = f"{IMAGE_TOKEN}Question: {question}\nAnswer:"
|
| 78 |
-
encoded_input = self.tokenizer(prompt, return_tensors="pt", padding=True, truncation=True)
|
| 79 |
|
| 80 |
batch = {
|
| 81 |
"pixel_values": img_embs,
|
|
@@ -84,6 +84,9 @@ class GPT2Vision(PreTrainedModel):
|
|
| 84 |
}
|
| 85 |
|
| 86 |
inputs_embeds, attention_mask, input_ids = self.preprocess_inputs(batch)
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
output_sequences = self.language_model.generate(
|
| 89 |
inputs_embeds=inputs_embeds,
|
|
|
|
| 75 |
|
| 76 |
# Tokenize the question
|
| 77 |
prompt = f"{IMAGE_TOKEN}Question: {question}\nAnswer:"
|
| 78 |
+
encoded_input = self.tokenizer(prompt, return_tensors="pt", padding=True, truncation=True,max_length=720)
|
| 79 |
|
| 80 |
batch = {
|
| 81 |
"pixel_values": img_embs,
|
|
|
|
| 84 |
}
|
| 85 |
|
| 86 |
inputs_embeds, attention_mask, input_ids = self.preprocess_inputs(batch)
|
| 87 |
+
|
| 88 |
+
print("inputs_embeds",inputs_embeds.size())
|
| 89 |
+
print("attention_mask",attention_mask.size())
|
| 90 |
|
| 91 |
output_sequences = self.language_model.generate(
|
| 92 |
inputs_embeds=inputs_embeds,
|