我有一些图像和标签,如何构建数据集,其中包含:(train_images,test_images),(train_labels,test_labels)用于神经网络作为分类器
import numpy as np
import glob
import cv2
from skimage import color
image_path='address'
#I want to path images that has a png and jpeg format
images = glob.glob(image_path + '*.jpg')
images.sort()
#read the images with Open CV
I =[]
width =150
height =200
for img in images:
image = cv2.imread(img)
image = cv2.resize(image ,(width , height))
image=image/image.max()
image = color.rgb2gray(image)
I.append(image)
I = np.array(I)
#make label
data_labels =[]
for i in range(0,5):
for j in range(0,10):
label = j
data_label.append(label)
data_label = np.array(data_labels)
np.random.seed()
np.random.shuffle(data_labels)