Exemple #1
0
 def __init__(self, shape, bkg_paths, mean=pr.BGR_IMAGENET_MEAN):
     super(AugmentImage, self).__init__()
     # self.add(LoadImage(4))
     self.add(pr.ResizeImage(shape))
     self.add(pr.BlendRandomCroppedBackground(bkg_paths))
     self.add(pr.RandomContrast())
     self.add(pr.RandomBrightness())
     self.add(pr.RandomSaturation(0.7))
     self.add(pr.RandomHue())
     self.add(pr.ConvertColorSpace(pr.RGB2BGR))
Exemple #2
0
# let's download a test image and put it inside our PAZ directory
IMAGE_URL = ('https://github.com/oarriaga/altamira-data/releases/download'
             '/v0.9/image_augmentation.png')
filename = os.path.basename(IMAGE_URL)
image_fullpath = get_file(filename, IMAGE_URL, cache_subdir='paz/tutorials')

# we load the original image and display it
image = load_image(image_fullpath)
show_image(image)

# We construct a data augmentation pipeline using the built-in PAZ processors:
augment = SequentialProcessor()
augment.add(pr.RandomContrast())
augment.add(pr.RandomBrightness())
augment.add(pr.RandomSaturation())

# We can now apply our pipeline as a normal function:
for _ in range(5):
    image = load_image(image_fullpath)
    # use it as a normal function
    image = augment(image)
    show_image(image)

# We can add to our sequential pipeline other function anywhere i.e. arg 0:
augment.insert(0, pr.LoadImage())
for _ in range(5):
    # now we don't load the image every time.
    image = augment(image_fullpath)
    show_image(image)
 def __init__(self):
     super(AugmentImage, self).__init__()
     self.add(pr.RandomContrast())
     self.add(pr.RandomBrightness())
     self.add(pr.RandomSaturation())
     self.add(pr.RandomHue())