0

I am following the tutorial for creating an image classifier using the TensorFlow Lite Model Maker found here: https://www.tensorflow.org/lite/tutorials/model_maker_image_classification#simple_end-to-end_example. Even though I am following the tutorial exactly, I can't images from the loaded data sets to display. Here's the relevant code and error message: error code: AttributeError: 'ImageClassifierDataLoader' object has no attribute 'dataset'

Why is this happening and how do I fix this?

  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'
4

1 回答 1

0

根据他们对你隐藏的承诺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-01-03T11:51:08.383 回答