许可证:[errno 13]拒绝许可:'。'
但是,我尝试在下面运行此代码
import keras
import tensorflow as tf
from keras.preprocessing import image
fnames = sorted([os.path.join(train_cats_dir, fname) for
fname in os.listdir(train_cats_dir)])
img_path = fname[3]
img = tf.keras.preprocessing.image.load_img(img_path, target_size=(150, 150))
,但是我得到了这样的错误。
In [15]: img = tf.keras.preprocessing.image.load_img(img_path, target_size=(150, 150))
Traceback (most recent call last):
Input In [15] in <cell line: 1>
img = tf.keras.preprocessing.image.load_img(img_path, target_size=(150, 150))
File C:\Anaconda3\lib\site-packages\keras\preprocessing\image.py:313 in load_img
return image.load_img(path, grayscale=grayscale, color_mode=color_mode,
File C:\Anaconda3\lib\site-packages\keras_preprocessing\image\utils.py:113 in load_img
with open(path, 'rb') as f:
PermissionError: [Errno 13] Permission denied: '.'
当我运行最后一行IMG时,发生
了
错误
I tried to run this code below
import keras
import tensorflow as tf
from keras.preprocessing import image
fnames = sorted([os.path.join(train_cats_dir, fname) for
fname in os.listdir(train_cats_dir)])
img_path = fname[3]
img = tf.keras.preprocessing.image.load_img(img_path, target_size=(150, 150))
However, I got the error like this.
In [15]: img = tf.keras.preprocessing.image.load_img(img_path, target_size=(150, 150))
Traceback (most recent call last):
Input In [15] in <cell line: 1>
img = tf.keras.preprocessing.image.load_img(img_path, target_size=(150, 150))
File C:\Anaconda3\lib\site-packages\keras\preprocessing\image.py:313 in load_img
return image.load_img(path, grayscale=grayscale, color_mode=color_mode,
File C:\Anaconda3\lib\site-packages\keras_preprocessing\image\utils.py:113 in load_img
with open(path, 'rb') as f:
PermissionError: [Errno 13] Permission denied: '.'
The error occurred when I run the last line img
I'm using tensorflow 2.8.0 and spyder from anaconda3
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我无法弄清楚它的确切问题是什么(也许我相信版本问题),但是我更改了下面的代码,并且效果很好。
导入
keras.utils
仅解决了它。I couldn't figure out what is the exact problem of it (Maybe version issue I believe), but I changed the code like below and it worked well.
Importing
keras.utils
only solved it.