【问题标题】:How to Single Image Predict如何进行单图像预测
【发布时间】:2021-08-01 03:20:04
【问题描述】:

我有一个使用随机图像进行预测的代码。 Code 在评论区

**

那是随机图像预测,如何预测单个图像?提前致谢

【问题讨论】:

  • 直接将代码放入问题中即可
  • @axtck 这不是“好的”,必须这样做

标签: python tensorflow conv-neural-network google-colaboratory


【解决方案1】:

您需要将图像转换为 TF 数据集或 Numpy,您可以将其输入到 model.predict,如下所示。

im = Image.open(data_path)
im = im.resize((128,128))
im_array = np.array(im)
im_array = np.expand_dims(im_array, axis = 0)
pred = model.predict(im_array)
print("the probable class according to the model is {} with confidence :.2f}".format(class_names[np.argmax(pred)], np.max(pred)*100))

【讨论】:

猜你喜欢
  • 2020-06-29
  • 1970-01-01
  • 2021-02-13
  • 2021-11-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多