Uneven dataset, how I should train the model if I can't load all pictures at once
From your tags, I see that you use keras. Keras offers you the class ImageDataGenerator which has the method flow_from_directory() (see here). This method loads the images in your training directory batch by batch from the hard drive and stores only the current batch in the RAM. This eliminates the bottleneck you currently face when loading the images.

To tackle the class imbalance, the recommended method is to use the class_weight argument of the keras classifiers. This argument assigns a weight to every class in your data, allowing you to give higher importance to images from the minority classes. This answer shows how you can calculate the class weights.

In the code below, I put that all together:

# Define constants - change them according to your requirements
BATCH_SIZE = 128
EPOCHS = 50
IMAGE_SIZE = 224

# Set up Image Data Generator
train_datagen = ImageDataGenerator(dtype=np.float16) # here you can also do some data augmentation

# Set up flow from directory
train_generator = train_datagen.flow_from_directory(directory="path/to/your/directory",
                                                    class_mode="categorical",
                                                    target_size=(IMAGE_SIZE, IMAGE_SIZE),  # resize the images if required
                                                    batch_size=BATCH_SIZE)

# Calculate class weights
counter = Counter(train_generator.classes)
max_val = float(max(counter.values()))
class_weights = {class_id: max_val/num_images for class_id, num_images in counter.items()}

# 
# Here you set up your model ...
# 

# After compiling the model, you fit it to your data using fit_generator
model.fit_generator(train_generator,
                    steps_per_epoch=train_generator.n // BATCH_SIZE,
                    epochs=EPOCHS,
                    class_weight=class_weights,  # use the class_weights as method parameter
                    verbose=1)