如何解决使用 TensorFlow Lite Model Maker 显示来自 DataLoader 的图像
我正在学习使用此处找到的 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,label) in enumerate(data.dataset.take(25)):
3 plt.subplot(5,i+1)
4 plt.xticks([])
5 plt.yticks([])
AttributeError: 'ImageClassifierDataLoader' object has no attribute 'dataset'
解决方法
根据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 notebook 就好了。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。