Using python v 3.7.3
, pytorch v 0.4.1
, imgaug 0.3.0
, windows 10
, Jupyter Notebook
I am trying to iterate through several folders containing images, augment each image 6 times, then save a hard copy of each augmented image inside that folder. I am using the imgaug
library to augment the images.
I am able to iterate through the folders, and augment and display the images inside the folders with this code:
for folder in os.listdir(path):
for i in os.listdir(path + '\\' + folder):
img = imageio.imread(path + '\\' + folder + '\\' + i)
print('Original:')
ia.imshow(img)
img_aug = seq.augment_image(img)
print('Augmented:')
ia.imshow(img_aug)
But, I would like to ultimately augment each image 6 times and create 6 new hard files per image. I am trying to use this tutorial to make these changes. Right now, I am just trying the step to save a hard copy of the augmented images. Using this code:
for folder in os.listdir(path):
for i in os.listdir(path + '\\' + folder):
img = imageio.imread(path + '\\' + folder + '\\' + i)
print('Original:')
ia.imshow(img)
img_aug = seq.augment_image(img)
print('Augmented:')
ia.imshow(img_aug)
for im, im_aug in enumerate(img_aug):
imageio.imwrite(os.path.join(path, path + '\\' + folder + '\\' + folder + "%06d.png" % (im)), im_aug)
While the augmented images show up normally when I print them in Jupyter labs, they are being saved as a hard copy as completely flat. It's also saving hundreds of these images:
Why would my image show up correctly augmented in Jupyter Labs, but be saved in that format when I try to save a hard copy?