m7mdal7aj commited on
Commit
54d3921
1 Parent(s): 7553f0c

Update my_model/captioner/image_captioning.py

Browse files
my_model/captioner/image_captioning.py CHANGED
@@ -71,6 +71,9 @@ class ImageCaptioningModel:
71
  # If it's a file path or file-like object, open it as a PIL Image
72
  image = Image.open(image_path)
73
 
 
 
 
74
  image = self.resize_image(image)
75
  inputs = self.processor(image, self.prompt, return_tensors="pt").to("cuda", self.torch_dtype)
76
  outputs = self.model.generate(**inputs, min_length=self.min_length, max_new_tokens=self.max_new_tokens)
 
71
  # If it's a file path or file-like object, open it as a PIL Image
72
  image = Image.open(image_path)
73
 
74
+ elif isinstance(image_path, Image.Image):
75
+ image = image_path
76
+
77
  image = self.resize_image(image)
78
  inputs = self.processor(image, self.prompt, return_tensors="pt").to("cuda", self.torch_dtype)
79
  outputs = self.model.generate(**inputs, min_length=self.min_length, max_new_tokens=self.max_new_tokens)