问题
I have 5 folders named as class_i each folder has the i class images. the images are with .jpg format. How can I balance the images in each folder by doing augmentation such that number of images in this folder will be equal to the number of images in the folder with highest number of images? Also, could you please help in plotting a curve shows number of images in each folder before and after balancing?
回答1:
Just extended my other answer with algorithm that does exactly what you want in this question. Algorithm is located at the very end of my answer.
It accepts two folders - one for input, one for output. Each folder contains subfolders named with integer labels, each subfolder contains images of that label.
When code is run first it does augmentation, then plots images counts for input folder (unmodified) and after window is closed it plots second window with counts for augmented (output) images.
Inside output folders each image is named with source image name plus suffix signifying augmentation method used to produce output PNG image. There can be several augmentation filters per image, each filter produces one PNG output.
来源:https://stackoverflow.com/questions/65899253/how-to-balance-images-in-folder-by-doing-augmentation-such-that-number-of-images