so I have this function to generate image augmentation for semantic segmentation, and I was hoping to get random image with corresponding image mask.
i = 1 # variable to iterate till images_to_generate
while i <= images_to_generate:
number = random.randint(0, len(images)) # PIck a number to select an image & mask
image = images[number]
mask = masks[number]
# print(image, mask)
# image=random.choice(images) #Randomly select an image name
original_image = io.imread(image)
original_mask = io.imread(mask)
transformed_image = None
transformed_mask = None
# print(i)
n = 0 # variable to iterate till number of transformation to apply
transformation_count = random.randint(0, len(transformations)) # choose random number of transformation to apply on the image
print(number)
print(transformation_count)
while n <= transformation_count:
key = random.choice(list(transformations)) # randomly choosing method to call
seed = random.randint(1,100) # Generate seed to supply transformation functions.
transformed_image = transformations[key](original_image, seed)
transformed_mask = transformations[key](original_mask, seed)
n = n + 1
new_image_path = "%s/augmented_image_%s.jpg" % (img_augmented_path, i)
new_mask_path = "%s/augmented_mask_%s.png" % (msk_augmented_path, i) # Do not save as JPG
io.imsave(new_image_path, transformed_image)
io.imsave(new_mask_path, transformed_mask)
i = i + 1
but I'm getting the same image number with the same transformation all the time
why does this happen?
Aucun commentaire:
Enregistrer un commentaire