Categories
Misc

Question regarding an error in my NumPy array.

def load_data(dir_list, image_size):

X = []

Y = []

image_width, image_height = image_size

for directory in dir_list:

for filename in listdir(directory):

image = cv2.imread(directory + ‘//’ + filename)

imgres = resize(image, (240,240,3))

img_resized = cv2.resize(imgres, dsize = (image_width,
image_height),interpolation=cv2.INTER_CUBIC)

X.append(image)

if directory[-3:] == ‘yes’:

Y.append([1])

else:

Y.append([0])

X = np.array(X)

Y = np.array(Y)

X, Y = shuffle(X, Y)

print(f’Number of examples is: {len(X)}’)

print(f’X shape is: {X.shape}’)

print(f’y shape is: {Y.shape}’)

return X, Y

———————————————–

yes = ‘yes’

no = ‘no’

IMG_WIDTH, IMG_HEIGHT = (240, 240)

X, Y = load_data([yes, no], (IMG_WIDTH, IMG_HEIGHT))

——————————————————–

OUTPUT:

Number of examples is: 253

X shape is: (253,)

Y shape is: (253, 1)

——————————————————-

The X-Shape should be (253,240,240,3), however, I do not know
why it is missing the other numbers. Thank you for helping.

submitted by /u/-KingKrazy-

[visit reddit]

[comments]

Leave a Reply

Your email address will not be published. Required fields are marked *