gpt4 book ai didi

python - 尽管导入操作系统,_get_batches_of_transformed_samples 中的 NameError : global name 'os' is not defined in keras_preprocessing/image/iterator. py

转载 作者:行者123 更新时间:2023-12-01 08:23:01 24 4
gpt4 key购买 nike

这是我的代码顶部的导入

import os
from keras.preprocessing.image import ImageDataGenerator, array_to_img, img_to_array, load_img

这是回溯:

Using TensorFlow backend.
Found 33 images belonging to 2 classes.
Traceback (most recent call last):
File "imggen.py", line 29, in <module>
save_format = 'jpeg'):
File "/home/psdanielxu/.local/lib/python2.7/site-packages/keras_preprocessing/image/iterator.py", line 111, in next
return self._get_batches_of_transformed_samples(index_array)
File "/home/psdanielxu/.local/lib/python2.7/site-packages/keras_preprocessing/image/iterator.py", line 245, in _get_batches_of_transformed_samples
img.save(os.path.join(self.save_to_dir, fname))
NameError: global name 'os' is not defined

我不确定这个错误是如何持续存在的,因为我已经导入了操作系统

最佳答案

我查看了 keras-preprocessing 的 github,似乎他们错过了那里的导入。尝试在该文件位于 /home/psdanielxu/.local/lib/python2.7/site-packages 的 iterator.py 文件上添加 import os/keras_preprocessing/image/iterator.py 在您的系统上

如果这对您有用,您还应该转到项目的 github 并针对此错误提出问题。 (https://github.com/keras-team/keras-preprocessing/issues)

关于python - 尽管导入操作系统,_get_batches_of_transformed_samples 中的 NameError : global name 'os' is not defined in keras_preprocessing/image/iterator. py,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54500301/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com