xzl12306 commited on
Commit
ec5bfbc
·
verified ·
1 Parent(s): 328b8f6

Update tinychart/mm_utils.py

Browse files
Files changed (1) hide show
  1. tinychart/mm_utils.py +3 -3
tinychart/mm_utils.py CHANGED
@@ -33,7 +33,7 @@ def process_images(images, image_processor, model_cfg):
33
  if image_aspect_ratio == 'pad':
34
  for image in images:
35
  image = expand2square(image, tuple(int(x*255) for x in image_processor.image_mean))
36
- image = image_processor.preprocess(image, return_tensors='pt', padding=True)['pixel_values'][0]
37
  new_images.append(image)
38
  elif image_aspect_ratio == "anyres":
39
  for image in images:
@@ -41,8 +41,8 @@ def process_images(images, image_processor, model_cfg):
41
  new_images.append(image)
42
  else:
43
  return image_processor(images, return_tensors='pt')['pixel_values']
44
- if all(x.shape == new_images[0].shape for x in new_images):
45
- new_images = torch.stack(new_images, dim=0)
46
  return new_images
47
 
48
 
 
33
  if image_aspect_ratio == 'pad':
34
  for image in images:
35
  image = expand2square(image, tuple(int(x*255) for x in image_processor.image_mean))
36
+ image = image_processor.preprocess(image, return_tensors='pt')['pixel_values'][0]
37
  new_images.append(image)
38
  elif image_aspect_ratio == "anyres":
39
  for image in images:
 
41
  new_images.append(image)
42
  else:
43
  return image_processor(images, return_tensors='pt')['pixel_values']
44
+ # if all(x.shape == new_images[0].shape for x in new_images):
45
+ new_images = torch.stack(new_images, dim=0)
46
  return new_images
47
 
48