Gorkem Polat
Gorkem Polat

Reputation: 114

What is the proper way of applying augmentations consecutively in Tensorflow Object Detection API?

I want to augment dataset by rotating 90, 180, and 270 degrees and apply same rotations to the horizontal or vertical flipped version of the image. So, in total, there will be 8 images for a single image (4 from original image rotations, 4 from flipped image rotations).

There is only 90 degree rotation in the API (random_rotation90). So, I suppose this function should be applied consecutively in order to obtain 180 and 270 degrees rotations. What is the proper way of doing this in config file?

data_augmentation_options {
  random_horizontal_flip{
  }
}
data_augmentation_options {
  random_rotation90{
  }
}

As far as I understand from the preprocessor.py file, above configuration applies augmentations directly to original image, in this case augmentations will not be applied consecutively. So is the following correct configuration for my purpose?

data_augmentation_options {
  random_horizontal_flip{
  }
  random_rotation90{
  }
}
data_augmentation_options {
  random_horizontal_flip{
  }
  random_rotation90{
  }
  random_rotation90{
  }
}
data_augmentation_options {
  random_horizontal_flip{
  }
  random_rotation90{
  }
  random_rotation90{
  }
  random_rotation90{
  }
}
data_augmentation_options {
  random_rotation90{
  }
}
data_augmentation_options {
  random_rotation90{
  }
  random_rotation90{
  }
}
data_augmentation_options {
  random_rotation90{
  }
  random_rotation90{
  }
  random_rotation90{
  }
}

Upvotes: 1

Views: 702

Answers (1)

amin71
amin71

Reputation: 109

No, for each option, data augmentation occurs once, and each option creates an image separately. Therefore, you can not get the rotation you want with multiple rotation options. To do this, you must do this: random_rotation90 { keypoint_rot_permutation: 3 keypoint_rot_permutation: 0 keypoint_rot_permutation: 1 keypoint_rot_permutation: 2 probability: 0.5 }

Upvotes: 1

Related Questions