I use a TFOD object detection framework, and visualize all data augmentation functions. There are several functions, that throw the exception:
InvalidArgumentError: image_size must contain 3 elements[1] [Op:SampleDistortedBoundingBoxV2]
These functions are related to SSD augmentations:
- SSD random crop
- SSD random crop pad
- SSD random crop fixed aspect ratio
Previously, the guys (https://github.com/tensorflow/models/issues/3349) advised to check if the image is RGB. I copied the code and made sure - image is RGB. Shape of the image - tf.Tensor([320, 320, 3]). So, the image_size has exactly 3 elements.
Before, i normalize the image, because it is requested that pixels are from 0 to 1 range.
Here is the short snippet of a big system.
def modify(self, image_):
# before ssd, pixels must be [0, 1]
normalized_img = preprocessor.normalize_image(
image_,
original_minval=0,
original_maxval=255,
target_minval = 0,
target_maxval = 1
)
assert np.max(normalized_img.numpy()) <= 1.0
assert np.min(normalized_img.numpy()) >= 0.0
modified_img = self.augmentation_function(
normalized_img, **self._augmentation_parameters
)
return modified_img
Why do these functions continue requesting 3 elements in the image size? Thank you so much!