Testys commited on
Commit
cb816fd
1 Parent(s): 380880b

Trying another method for image loading

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