在深度学习中显示带有matplotlib的图像
运行此代码:
#loading test images
val_ds = tf.keras.preprocessing.image_dataset_from_directory(
test_path,image_size=(img_height,img_width), label_mode='int',
batch_size=batch_size)
import matplotlib.pyplot as plt
plt.figure(figsize=(12,12))
for img ,label in val_ds.take(1):
for i in range(12):
ax = plt.subplot(4,3,i + 1)
plt.imshow(img[i].numpy().astype('uint8'))
plt.title(class_name[label[i]])
plt.axis('off')
我有一个错误:
notFoundError:newrandomaccessfile无法创建/开放:D:\ Machine 学习\ dpl \ tensorflow的计算机视觉深度学习 2 [tutsnode.com] - 用张量的深度学习计算机视觉 2 \ 3。卷积神经网络\ 15.1 covid19 \ covid19 \ test \ covid \ auntminnie-a-2020_01_28_28_23_23_51_6665_2020_01_28_vietnam_coronavirus.jpeg :该系统找不到指定的路径。 ;没有这样的过程
[[{{node readfile}}]] [op:iteratorGetNext]
任何帮助?
Running this piece of code:
#loading test images
val_ds = tf.keras.preprocessing.image_dataset_from_directory(
test_path,image_size=(img_height,img_width), label_mode='int',
batch_size=batch_size)
import matplotlib.pyplot as plt
plt.figure(figsize=(12,12))
for img ,label in val_ds.take(1):
for i in range(12):
ax = plt.subplot(4,3,i + 1)
plt.imshow(img[i].numpy().astype('uint8'))
plt.title(class_name[label[i]])
plt.axis('off')
I got this error :
NotFoundError: NewRandomAccessFile failed to Create/Open: D:\Machine
Learning\DPL\Deep Learning for Computer Vision with TensorFlow
2[TutsNode.com] - Deep Learning for Computer Vision with TensorFlow
2\3. Convolutional Neural Networks\15.1
covid19\covid19\test\Covid\auntminnie-a-2020_01_28_23_51_6665_2020_01_28_Vietnam_coronavirus.jpeg
: The system cannot find the path specified. ; No such process
[[{{node ReadFile}}]] [Op:IteratorGetNext]
Any help ??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据官方文档的
image_dataset_from_directory函数:
没有像test_path这样的参数,但您在代码中提到了这一点。
要加载图像,您必须使用此功能:
As per official documentation
image_dataset_from_directory function:
there is no argument like test_path but you mention this in your code.
And for loading image you have to use this function: