Augmentor icon indicating copy to clipboard operation
Augmentor copied to clipboard

augment only a single, or set of images

Open niekverw opened this issue 7 years ago • 3 comments

I was wondering if it is possible to use Augmentor to augment a single image or augment multiple images in exactly the same manner (e.g. multiple np.array as input, not filename)? if you have image + Masks, it may be necessary to augment masks the exact same way.

so something like:

i1 = cv2.imread (f1)
i2 = cv2.imread (f2)

x = []
x.append (i1)
x.append (i2)
print(np.array(x).shape)

rotate = ops.RotateRange(probability=0, max_left_rotation=50, max_right_rotation=10)

img_ro = np.array(rotate.perform_operation(Image.fromarray(x)))
for ii in img_ro:
  plt.imshow(ii) # each image in x is rotated in the same way
  plt.show()

niekverw avatar Jan 31 '18 09:01 niekverw

Hi @niekverw , yes, this is now finally possible using the ground_truth() function in the Pipeline class (as of Augmentor v0.2.0).

Basically, just use this function to point to a directory containing the mask images, and when you generate new image data, images will be generated for both the mask and the original images:

p = Augmentor.Pipeline("/home/user/images")
p.ground_truth("/home/user/mask_images")

Call p.sample() in the same way as per usual to generate both sets of images.

See the README for more details.

mdbloice avatar Mar 01 '18 13:03 mdbloice

@mdbloice, Thanks for this awesome library. Just wondering similar to transforming the mask, is it possible to transform the bounding box coordinates as well ?

kmsravindra avatar May 16 '18 11:05 kmsravindra

@mdbloice Hi there, Can you explain more about masks in the ground truth directory? I have image files and annotation files (a text file containing coordinates and dimensions of bounding boxes). My interest is to apply augmentation on image (shift, rotation, or flip), but also similarly to grounding boxes (masks?). Thanks.

jaelim avatar Sep 07 '18 16:09 jaelim