Allow to use PIL Image in chat function

#34
by akshayballal - opened
Files changed (1) hide show
  1. modeling_GOT.py +7 -4
modeling_GOT.py CHANGED
@@ -469,11 +469,14 @@ class GOTQwenForCausalLM(Qwen2ForCausalLM):
469
  config.im_start_token, config.im_end_token = 151857, 151858
470
 
471
  def load_image(self, image_file):
472
- if image_file.startswith('http') or image_file.startswith('https'):
473
- response = requests.get(image_file)
474
- image = Image.open(BytesIO(response.content)).convert('RGB')
 
 
 
475
  else:
476
- image = Image.open(image_file).convert('RGB')
477
  return image
478
 
479
  def disable_torch_init(self):
 
469
  config.im_start_token, config.im_end_token = 151857, 151858
470
 
471
  def load_image(self, image_file):
472
+ if isinstance(image_file, str):
473
+ if image_file.startswith('http') or image_file.startswith('https'):
474
+ response = requests.get(image_file)
475
+ image = Image.open(BytesIO(response.content)).convert('RGB')
476
+ else:
477
+ image = Image.open(image_file).convert('RGB')
478
  else:
479
+ image = image_file
480
  return image
481
 
482
  def disable_torch_init(self):