.npy
文件,但是无论我将多少imgs或标签放入程序中,npy文件的结果都只有1kb。
def create_train_data(data_path, img_type, rows, cols, label_path, npy_path):
# Generate npy files for training sets and labels
i = 0
print('-' * 30)
print('Creating training images...')
print('-' * 30)
imgs = glob.glob(data_path + "//*." + img_type)
imgdatas = np.ndarray((len(imgs), rows, cols, 3), dtype=np.uint8)
imglabels = np.ndarray((len(imgs), rows, cols, 1), dtype=np.uint8)
for imgname in imgs:
midname = imgname[imgname.rindex("\\") + 1:]
img = load_img(data_path + "\\" + midname)
img = img_to_array(img)
label = load_img(label_path + "\\" + midname, grayscale=True)
label = img_to_array(label)
imgdatas[i] = img
imglabels[i] = label
if i % 112 == 0:
print('Done: {0}/{1} images'.format(i, len(imgs)))
i += 1
np.save(npy_path + '\\X_train.npy', imgdatas)
np.save(npy_path + '\\y_train.npy', imglabels)
print('Saving to .npy files done.')
我认为输出.npy文件的大小与输入有关。
我不太清楚,至少不能总是1kb。