<s>[INST] import os
import cv2
import numpy as np

class ImageLoader:
    def __init__(self, image_path, labels, shape = (128, 128)):
        self.image_path = image_path
        self.labels = labels
        self.shape = shape
        self.files = os.listdir(image_path)

    def get_random_image(self):
        file_name = np.random.choice(self.files)
        file_path = os.path.join(self.image_path, file_name)
        image = cv2.imread(file_path, cv2.IMREAD_COLOR)
        image = cv2.resize(image, self.shape, cv2.INTER_CUBIC)
        return image

    def get_all_images(self):
        images = []
        for file_name in self.files:
            file_path = os.path.join(self.image_path, file_name)
            image = cv2.imread(file_path, cv2.IMREAD_COLOR)
            image = cv2.resize(image, self.shape)
            images.append(image)
        return images

# Testing the ImageLoader class
image_path = r'E:\Workspace\PycharmProjects\DeepLearningProject\Dataset\Training'
loader = ImageLoader(image_path, labels=['dog', 'cat'])
image1 = loader.get_random_image()
image2 = loader.get_random_image()

# Print the shape of the loaded images
print(image1.shape)
print(image2.shape)

# Print the shape of the images
# image3 = loader.get_all_images()
# print(len(image3))

Note: This is the complete code.

I need some feedback on the design and potential errors in the code.

Design Feedback:

1. Is the design good?[/INST]