【问题标题】:How to predict a single input(external) image for categorical data using CNN using Keras如何使用 Keras 使用 CNN 预测分类数据的单个输入(外部)图像
【发布时间】:2018-04-21 05:38:05
【问题描述】:

我正在使用 MNIST 数据库制作一个手写数字识别项目,我已经针对数据集中的 60,0000 张图像对其进行了训练,并针对 10,000 张测试图像对其进行了测试,得到的结果准确率约为 99%。 现在我想输入一个外部图像,看看我的手写数字是否被 CNN 识别。所以我扫描了自己的手写图像,将其转换为灰度和 numpy 数组并将其输入 CNN,但我总是将输出预测结果作为 8 作为 numpy 数组的一个热编码向量。

              import numpy as np

              from keras.preprocessing import image
              test_image = image.load_img('six.jpg', target_size = (28,28))

              test_image = image.img_to_array(test_image, data_format = None)
              from numpy import *
              test_image= delete(test_image,  np.s_[::2], 2)


              test_image = np.expand_dims(test_image, axis = 0)
              predicted_dig = digit_recogniser.predict(test_image,batch_size= 32)
              predicted_digits = np.argmax(np.round(predicted_digits),axis=0)

您能帮我弄清楚代码有什么问题吗?我如何才能成功预测由/外部输入单独扫描的数字?我的 CNN 使用 MNIST 数据集进行了全面训练。这是一种我想在随机选取我选择的手写图像时做出的准确预测。

【问题讨论】:

    标签: python deep-learning keras


    【解决方案1】:

    您在测试期间是否匹配训练数据预处理?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-05-14
      • 1970-01-01
      • 1970-01-01
      • 2019-06-13
      • 1970-01-01
      • 2018-03-26
      • 2018-02-15
      相关资源
      最近更新 更多