许可证:[errno 13]拒绝许可:'。'

发布于 2025-02-11 07:47:44 字数 979 浏览 0 评论 0原文

但是,我尝试在下面运行此代码

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千鲤 2025-02-18 07:47:44

我无法弄清楚它的确切问题是什么(也许我相信版本问题),但是我更改了下面的代码,并且效果很好。

import keras.utils

fnames = sorted([os.path.join(train_cats_dir, fname) for
             fname in os.listdir(train_cats_dir)])

img_path = fnames[3]

img = keras.utils.load_img(img_path, target_size=(150, 150))

导入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.

import keras.utils

fnames = sorted([os.path.join(train_cats_dir, fname) for
             fname in os.listdir(train_cats_dir)])

img_path = fnames[3]

img = keras.utils.load_img(img_path, target_size=(150, 150))

Importing keras.utils only solved it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文