如何像 MNIST 数据集一样创建图像数据集?

新手上路,请多包涵

我有 10000 张一些手写数字的 BMP 图片。如果我想将数据提供给神经网络,我需要做什么?对于 MNIST 数据集,我只需要写

(X_train, y_train), (X_test, y_test) = mnist.load_data()

我在 python 中使用 Keras 库。我怎样才能创建这样的数据集?

原文由 Md Shopon 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 446
2 个回答

您应该编写自己的函数来加载所有图像或这样做:

 imagePaths = sorted(list(paths.list_images(args["testset"])))

# loop over the input images
for imagePath in imagePaths:
    # load the image, pre-process it, and store it in the data list
    image = cv2.imread(imagePath)
    image = cv2.resize(image, (IMAGE_DIMS[1], IMAGE_DIMS[0]))
    image = img_to_array(image)
    data.append(image)
    # extract the class label from the image path and update the
    # labels list

data = np.array(data, dtype="float") / 255.0

原文由 azharimran 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题