我想用python创建数据集,其中包含:训练图像,测试图像和训练标签,测试标签...我该怎么办?

时间:2019-07-23 06:00:54

标签: python-3.x dataset

我有一些图像和标签,如何构建数据集,其中包含:(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)

0 个答案:

没有答案