damerajee commited on
Commit
d6792f7
·
verified ·
1 Parent(s): d9a372e

Update modeling_gpt2vision.py

Browse files
Files changed (1) hide show
  1. modeling_gpt2vision.py +1 -2
modeling_gpt2vision.py CHANGED
@@ -69,9 +69,8 @@ class GPT2Vision(PreTrainedModel):
69
  def generate(self, question, image, max_new_tokens=30, **kwargs):
70
  # Process the image
71
  # Convert the image to a tensor and add a batch dimension
72
- image_tensor = self.vision_encoder.image_transform(image).unsqueeze(0).to(self.device)
73
  with torch.no_grad():
74
- img_features = self.vision_encoder(image_tensor,device=self.device)
75
  img_embs = self.mlp(img_features)
76
 
77
  # Tokenize the question
 
69
  def generate(self, question, image, max_new_tokens=30, **kwargs):
70
  # Process the image
71
  # Convert the image to a tensor and add a batch dimension
 
72
  with torch.no_grad():
73
+ img_features = self.vision_encoder(image,device=self.device)
74
  img_embs = self.mlp(img_features)
75
 
76
  # Tokenize the question