import tensorflow as tfimport pandas as pdimport numpy as npimport matplotlib as pltimport pathlibimport matplotlib.pyplot as pltimport cv2import osfrom keras.layers import Densefrom keras.models import Sequentialdataset_train=cv2.imread(r"……. \flowerdataset\train1")dataset_test=cv2.imread(r"…………\ flowerdataset\test1")folder=r"……….. flowerdataset\train1"path=r"……………..\flowerdataset\train_2"if not os.path.exists(path): os.mkdir(path) print("Folder %s created!" % path)else: print("Folder %s already exists" % path)for images in os.listdir(folder): img=os.path.join(folder,images) img1=cv2.imread(img) img_resized=cv2.resize(img1,(100,100), interpolation = cv2.INTER_LINEAR) gray_img=cv2.cvtColor(img_resized,cv2.COLOR_BGR2GRAY) cv2.imwrite(os.path.join(path, images), gray_img)list_flat=[]for img_flat in os.listdir(path): m = os.path.join(path,img_flat) m_read=cv2.imread(m) im_norm=m_read/255. m_flat=im_norm.flatten() list_flat.append(m_flat) print(list_flat)output:[array([0.6 , 0.6 , 0.6 , ..., 0.37647059, 0.37647059, 0.37647059])][array([0.6 , 0.6 , 0.6 , ..., 0.37647059, 0.37647059, 0.37647059]), array([0.00784314, 0.00784314, 0.00784314, ..., 0.21960784, 0.21960784, 0.21960784])][array([0.6 , 0.6 , 0.6 , ..., 0.37647059, 0.37647059, 0.37647059]), array([0.00784314, 0.00784314, 0.00784314, ..., 0.21960784, 0.21960784, 0.21960784]), array([0.20392157, 0.20392157, 0.20392157, ..., 0.27058824, 0.27058824, 0.27058824])][array([0.6 , 0.6 , 0.6 , ..., 0.37647059, 0.37647059, 0.37647059]), array([0.00784314, 0.00784314, 0.00784314, ..., 0.21960784, 0.21960784, 0.21960784]), array([0.20392157, 0.20392157, 0.20392157, ..., 0.27058824, 0.27058824, 0.27058824]), array([0.55686275, 0.55686275, 0.55686275, ..., 0.56470588, 0.56470588, 0.56470588])][array([0.6 , 0.6 , 0.6 , ..., 0.37647059, 0.37647059, 0.37647059]), array([0.00784314, 0.00784314, 0.00784314, ..., 0.21960784, 0.21960784, 0.21960784]), array([0.20392157, 0.20392157, 0.20392157, ..., 0.27058824, 0.27058824, 0.27058824]), array([0.55686275, 0.55686275, 0.55686275, ..., 0.56470588, 0.56470588, 0.56470588]), array([0.09019608, 0.09019608, 0.09019608, ..., 0.02745098, 0.02745098, 0.02745098])][array([0.6 , 0.6 , 0.6 , ..., 0.37647059, 0.37647059, 0.37647059]), array([0.00784314, 0.00784314, 0.00784314, ..., 0.21960784, 0.21960784, 0.21960784]), array([0.20392157, 0.20392157, 0.20392157, ..., 0.27058824, 0.27058824, 0.27058824]), array([0.55686275, 0.55686275, 0.55686275, ..., 0.56470588, 0.56470588, 0.56470588]), array([0.09019608, 0.09019608, 0.09019608, ..., 0.02745098, 0.02745098, 0.02745098]), array([0.60784314, 0.60784314, 0.60784314, ..., 0.25098039, 0.25098039, 0.25098039])][array([0.6 , 0.6 , 0.6 , ..., 0.37647059, 0.37647059, 0.37647059]), array([0.00784314, 0.00784314, 0.00784314, ..., 0.21960784, 0.21960784, 0.21960784]), array([0.20392157, 0.20392157, 0.20392157, ..., 0.27058824, 0.27058824, 0.27058824]), array([0.55686275, 0.55686275, 0.55686275, ..., 0.56470588, 0.56470588, 0.56470588]), array([0.09019608, 0.09019608, 0.09019608, ..., 0.02745098, 0.02745098, 0.02745098]), array([0.60784314, 0.60784314, 0.60784314, ..., 0.25098039, 0.25098039, 0.25098039]), array([0.09019608, 0.09019608, 0.09019608, ..., 0.08627451, 0.08627451, 0.08627451])]
I want to build a simple ANN model using flower dataset. Before that I have preprocessed the dataset which has only 23 images, while feeding it to ANN network I flattened the dataset. Now I am not able to place the flattened dataset in array.I tried by creating empty list and appending each fattened data points, I got the output with array word between. Also, why flatten data output displays all the numbers in the output 3 times.I want the output to be array of flatten images of shape(23,10000) to feed it to neural net. I tried doing reshape(23,10000) with flatten it did not work. I am not getting how to proceed from here, can anyone please help.