How to balance images in folder by doing augmentation such that number of images in this folder are equal to number of images in other folder?

淺唱寂寞╮ 提交于 2021-02-08 09:23:54

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!