xiaohei66 commited on
Commit
e8ede36
·
verified ·
1 Parent(s): 6819afc

Update image_processing_paddleocr_vl.py

Browse files
Files changed (1) hide show
  1. image_processing_paddleocr_vl.py +3 -5
image_processing_paddleocr_vl.py CHANGED
@@ -338,10 +338,12 @@ class PaddleOCRVLImageProcessor(BaseImageProcessor):
338
  """
339
  images = make_list_of_images(images)
340
 
 
 
 
341
  if do_convert_rgb:
342
  images = [convert_to_rgb(image) for image in images]
343
 
344
- # All transformations expect numpy arrays.
345
  images = [to_numpy_array(image) for image in images]
346
 
347
  if is_scaled_image(images[0]) and do_rescale:
@@ -349,14 +351,10 @@ class PaddleOCRVLImageProcessor(BaseImageProcessor):
349
  "It looks like you are trying to rescale already rescaled images. If the input"
350
  " images have pixel values between 0 and 1, set `do_rescale=False` to avoid rescaling them again."
351
  )
352
- if input_data_format is None:
353
- # We assume that all images have the same channel dimension format.
354
- input_data_format = infer_channel_dimension_format(images[0])
355
 
356
  height, width = get_image_size(images[0], channel_dim=input_data_format)
357
  resized_height, resized_width = height, width
358
  processed_images = []
359
-
360
  for image in images:
361
  if do_resize:
362
  resized_height, resized_width = smart_resize(
 
338
  """
339
  images = make_list_of_images(images)
340
 
341
+ if input_data_format is None:
342
+ input_data_format = ChannelDimension.LAST if isinstance(images[0], Image.Image) else infer_channel_dimension_format(images[0])
343
+
344
  if do_convert_rgb:
345
  images = [convert_to_rgb(image) for image in images]
346
 
 
347
  images = [to_numpy_array(image) for image in images]
348
 
349
  if is_scaled_image(images[0]) and do_rescale:
 
351
  "It looks like you are trying to rescale already rescaled images. If the input"
352
  " images have pixel values between 0 and 1, set `do_rescale=False` to avoid rescaling them again."
353
  )
 
 
 
354
 
355
  height, width = get_image_size(images[0], channel_dim=input_data_format)
356
  resized_height, resized_width = height, width
357
  processed_images = []
 
358
  for image in images:
359
  if do_resize:
360
  resized_height, resized_width = smart_resize(