def create_test_data():
train_data_path = os.path.join(data_path, 'test')
images = os.listdir(train_data_path)
total = len(images)
imgs = np.ndarray((total, 1, image_rows, image_cols), dtype=np.uint8)
imgs_id = np.ndarray((total, ), dtype=np.int32)
i = 0
print('Creating test images...')
for image_name in images:
img_id = int(image_name.split('.')[0])
img = cv2.imread(os.path.join(train_data_path, image_name), cv2.IMREAD_GRAYSCALE)
imgs[i, 0] = img
imgs_id[i] = img_id
if i % 100 == 0:
print('Done: {0}/{1} images'.format(i, total))
i += 1
print('Loading done.')
np.save(img_test_path, imgs)
np.save(img_test_id_path, imgs_id)
print('Saving to .npy files done.')
data.py 文件源码
python
阅读 25
收藏 0
点赞 0
评论 0
评论列表
文章目录