if AUGMENT and prob < it[0]: for extra in range(3): center = np.array([ int(image.shape[0] / 2), int(image.shape[1] / 2) ]) deg = np.random.randint(-10, 10) #deg = np.random.normal()*30 newimg = aug.salt_and_pepper( aug.gaussian_blur(image)) #.3 probability for each of shifting vs rotating vs shift(rotate(image)) p = np.random.randint(0, 3) if p == 0: newimg, nb = aug.shift_image(newimg, box[idx]) elif p == 1: newimg, nb = aug.rotate_image_and_boxes( newimg, deg, center, box[idx]) elif p == 2: newimg, nb = aug.rotate_image_and_boxes( newimg, deg, center, box[idx]) newimg, nb = aug.shift_image(newimg, nb) newimg = (newimg).astype(np.uint8) if idx % 1000 == 0 and SAVE_IMAGES: Image.fromarray(newimg).save( 'process/img_%s_%s_%s.png' % (name, extra, it[0]))
]) deg = np.random.randint(-10, 10) #deg = np.random.normal()*30 # changed # remove and gaussian blur newimg = aug.gaussian_blur(image) #newimg = image #.3 probability for each of shifting vs rotating vs shift(rotate(image)) p = np.random.randint(0, 3) # debug # modified to use the removed cloud version of bboxes # image, new_coords, new_classes if p == 0: newimg, nb = aug.shift_image( newimg, new_coords) #newimg,nb = aug.shift_image(newimg,box[idx]) elif p == 1: newimg, nb = aug.rotate_image_and_boxes( newimg, deg, center, new_coords) #newimg,nb = aug.rotate_image_and_boxes(newimg,deg,center,box[idx]) elif p == 2: newimg, nb = aug.rotate_image_and_boxes( newimg, deg, center, new_coords) #newimg,nb = aug.rotate_image_and_boxes(newimg,deg,center,box[idx]) newimg, nb = aug.shift_image(newimg, nb) newimg = (newimg).astype(np.uint8) if idx % 100 == 0 and SAVE_IMAGES: #debug