Data Enhancement in the Object Detection API: random_image_scale

I am trying to use the data extension functions of the object detection API, in particular random_image_scale.

Digging a bit, I found a function that implements it (inserted below). Am I missing something, or is the true truth of the boxes not being treated here? I looked around and found nothing. If the basic truth does not change in accordance with the scaling performed with the image, this will be corrupted with the training of the model, right?

Please let me know if I missed something, or should I avoid this feature in order to train my network.

File: /object_detection/core/preprocessor.py

def random_image_scale(image, masks=None, min_scale_ratio=0.5, max_scale_ratio=2.0, seed=None): """Scales the image size. Args: image: rank 3 float32 tensor contains 1 image -> [height, width, channels]. masks: (optional) rank 3 float32 tensor containing masks with size [height, width, num_masks]. The value is set to None if there are no masks. min_scale_ratio: minimum scaling ratio. max_scale_ratio: maximum scaling ratio. seed: random seed. Returns: image: image which is the same rank as input image. masks: If masks is not none, resized masks which are the same rank as input masks will be returned. """ with tf.name_scope('RandomImageScale', values=[image]): result = [] image_shape = tf.shape(image) image_height = image_shape[0] image_width = image_shape[1] size_coef = tf.random_uniform([], minval=min_scale_ratio, maxval=max_scale_ratio, dtype=tf.float32, seed=seed) image_newysize = tf.to_int32( tf.multiply(tf.to_float(image_height), size_coef)) image_newxsize = tf.to_int32( tf.multiply(tf.to_float(image_width), size_coef)) image = tf.image.resize_images( image, [image_newysize, image_newxsize], align_corners=True) result.append(image) if masks: masks = tf.image.resize_nearest_neighbor( masks, [image_newysize, image_newxsize], align_corners=True) result.append(masks) return tuple(result) 
+5
source share
1 answer

If you are using the tfrecord file, the field boundaries are not absolute pixels, but relative percentages. therefore, if you scale the image, the boxes remain unchanged.

So it should be good.

+1
source

Source: https://habr.com/ru/post/1273437/


All Articles