# Balancing on the particular imbalanced classes of image dataset

I have a dataset that has 12 classes in the base directory. However, these 12 classes consist of several amounts of Images. The number of images of 12 classes is inconsistent therefore its impacts the total accuracy. Thus, should I apply the data augmentation to the particular classes that have a low amount of data?

Image data of each class:

#Dummy Classes

[AAAA: 713
ABCD: 274
ACBD: 335
BBBB: 538
BACD: 607
CCCC: 463
CABD: 309
CDAB: 762]


Therefore, if should I have to apply data augmentation to increase the amount of data in that particular classes that have a lower amount of image, as a result, I have been applied data augmentation but it does not increase the image data. Besides that, I want to generate the augmented data with the raw data that means the input and out directory will be the same. Therefore, it is possible to assist me to solve this problem?

Notebook: Google Colab OS: Windows 10

Code of Augmentation for particular (Individual Classes):

from keras.preprocessing.image import ImageDataGenerator

datagen = ImageDataGenerator(
rotation_range=45,
width_shift_range=0.2,
height_shift_range=0.2,
shear_range = 0.2,
zoom_range = 0.2,
horizontal_flip=True,
fill_mode = 'reflect', cval = 125)

i = 0

for batch in datagen.flow_from_directory(directory = ('/content/dataset/ABCD'),
batch_size = 317,
target_size = (256, 256),
color_mode = ('rgb'),
save_to_dir = ('/content/dataset/ABCD'),
save_prefix = ('aug'),
save_format = ('png')):
i += 1
if i > 100:
break


Output: Found 0 images belonging to 0 classes.