Update modeling_gpt2vision.py
Browse files- modeling_gpt2vision.py +2 -2
modeling_gpt2vision.py
CHANGED
|
@@ -63,7 +63,7 @@ class GPT2Vision(PreTrainedModel):
|
|
| 63 |
text,
|
| 64 |
padding='max_length',
|
| 65 |
truncation=True,
|
| 66 |
-
max_length=
|
| 67 |
return_tensors="pt",
|
| 68 |
).to(device)
|
| 69 |
|
|
@@ -98,7 +98,7 @@ class GPT2Vision(PreTrainedModel):
|
|
| 98 |
|
| 99 |
|
| 100 |
def generate(self, question, image, max_new_tokens=30, **kwargs):
|
| 101 |
-
prompt = f"\
|
| 102 |
batch = {"image": [image], "text": prompt}
|
| 103 |
encoded_batch = self.tokenize_encode(batch, self.device)
|
| 104 |
inputs_embeds, attention_mask = self.preprocess_inputs(encoded_batch)
|
|
|
|
| 63 |
text,
|
| 64 |
padding='max_length',
|
| 65 |
truncation=True,
|
| 66 |
+
max_length=384,
|
| 67 |
return_tensors="pt",
|
| 68 |
).to(device)
|
| 69 |
|
|
|
|
| 98 |
|
| 99 |
|
| 100 |
def generate(self, question, image, max_new_tokens=30, **kwargs):
|
| 101 |
+
prompt = f"\nQuestion:<image>{question}\nAnswer:"
|
| 102 |
batch = {"image": [image], "text": prompt}
|
| 103 |
encoded_batch = self.tokenize_encode(batch, self.device)
|
| 104 |
inputs_embeds, attention_mask = self.preprocess_inputs(encoded_batch)
|