【问题标题】:Displaying Images from DataLoader with TensorFlow Lite Model Maker使用 TensorFlow Lite Model Maker 显示来自 DataLoader 的图像
【发布时间】:2021-01-03 04:28:19
【问题描述】:

我正在学习使用 TensorFlow Lite Model Maker 创建图像分类器的教程:https://www.tensorflow.org/lite/tutorials/model_maker_image_classification#simple_end-to-end_example。即使我完全按照教程进行操作,我也无法显示加载数据集中的图像。以下是相关代码和错误消息: error code: AttributeError: 'ImageClassifierDataLoader' object has no attribute 'dataset'

为什么会发生这种情况,我该如何解决?

  plt.figure(figsize=(10,10))
for i, (image, label) in enumerate(data.dataset.take(25)):
  plt.subplot(5,5,i+1)
  plt.xticks([])
  plt.yticks([])
  plt.grid(False)
  plt.imshow(image.numpy(), cmap=plt.cm.gray)
  plt.xlabel(data.index_to_label[label.numpy()])
plt.show()

AttributeError                            Traceback (most recent call last)
<ipython-input-9-160e876048da> in <module>()
      1 plt.figure(figsize=(10,10))
----> 2 for i, (image, label) in enumerate(data.dataset.take(25)):
      3   plt.subplot(5,5,i+1)
      4   plt.xticks([])
      5   plt.yticks([])

AttributeError: 'ImageClassifierDataLoader' object has no attribute 'dataset'

【问题讨论】:

    标签: tensorflow tensorflow-lite dataloader image-classification


    【解决方案1】:

    根据commit 他们对你隐藏了dataset,现在你应该使用gen_dataset() 方法得到一个:

    ds = data.gen_dataset()
    for i, (image, label) in enumerate(ds.take(25)):
      plt.subplot(5,5,i+1)
      plt.xticks([])
      plt.yticks([])
      plt.grid(False)
      plt.imshow(image.numpy(), cmap=plt.cm.gray)
      plt.xlabel(data.index_to_label[label.numpy()])
    plt.show()
    

    如果你填票让他们编辑 colab 笔记本就好了。

    【讨论】:

      猜你喜欢
      • 2021-04-16
      • 2021-10-02
      • 1970-01-01
      • 2021-03-10
      • 2016-11-13
      • 1970-01-01
      • 2012-02-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多