Testys commited on
Commit
27880c4
1 Parent(s): 9953c0d

Trying PIL and Image

Browse files
Files changed (1) hide show
  1. utils/caption_utils.py +3 -1
utils/caption_utils.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import torch
2
  from transformers import BlipProcessor, BlipForConditionalGeneration
3
  from utils.image_utils import load_image
@@ -14,7 +15,8 @@ class ImageCaptioning:
14
  def get_caption(self, image):
15
 
16
  # Preprocessing the Image
17
- img = self.processor(image, return_tensors="pt").to(device)
 
18
 
19
  # Generating captions
20
  output = self.model.generate(**img)
 
1
+ from PIL import Image
2
  import torch
3
  from transformers import BlipProcessor, BlipForConditionalGeneration
4
  from utils.image_utils import load_image
 
15
  def get_caption(self, image):
16
 
17
  # Preprocessing the Image
18
+ img = Image.open(image)
19
+ img = self.processor(img, return_tensors="pt").to(device)
20
 
21
  # Generating captions
22
  output = self.model.generate(**img)