2
Basically my algorithm imports all the photos I have inside a directory (dataset_train), saving these photos in vector X and the name of the folder where it was in vector Y.
import os
import cv2
import numpy as np
x = []
y = []
for root, dirs, files in os.walk("dataset_train"):
path = root.split(os.sep)
for file in files:
imagem_nome = root + '/' + file
imagem = cv2.imread(imagem_nome, 0)
x.append(imagem)
y.append(path[1])
print('Imagens para treinamento lidas:', len(x))
(x_train, y_train) = (np.asarray(x), y)
print(x_train.shape)
print(x_train[0].shape)
Exit:
Imagens para treinamento lidas: 11957
(11957,)
(250, 250)
I’m using as a basis the CNN MNIST algorithm, in which it has 60000 images, 28x28 pixels. In this algorithm when I use shape()
in the training vector it returns (60000, 28, 28)
. But when I do it in mine it returns only (11957,)
, I need him to return (11957,250, 250)
. My dataset are 250x250 pixel photos.
Can someone help me with this, please? I’m new to Python :(
Funny that I tried to do in a smaller dataset and this my code worked. But its I try to do in this larger dataset of that problem.
– Felipe Ricardo dos Santos