Image processing OsError:-2在使用ImageDataGenerator使用keras对模型进行培训期间
我有16个类数据,并已将图像放置在train文件夹中,每个类有16个文件夹。这对所有测试和val都是如此。但当我尝试运行代码时,在第行抛出错误: 型号:fit_生成器() 输出:Image processing OsError:-2在使用ImageDataGenerator使用keras对模型进行培训期间,image-processing,keras,deep-learning,conv-neural-network,Image Processing,Keras,Deep Learning,Conv Neural Network,我有16个类数据,并已将图像放置在train文件夹中,每个类有16个文件夹。这对所有测试和val都是如此。但当我尝试运行代码时,在第行抛出错误: 型号:fit_生成器() 输出: _________________________________________________________________ 激活68(激活)(无、122、122、128)0 _________________________________________________________________ 最大池
_________________________________________________________________
激活68(激活)(无、122、122、128)0
_________________________________________________________________
最大池2D_42(最大池(无、61、61、128)0
_________________________________________________________________
展平14(展平)(无,476288)0
_________________________________________________________________
致密(致密)(无,100)47628900
_________________________________________________________________
激活69(激活)(无,100)0
_________________________________________________________________
致密(致密)(无,16)1616
_________________________________________________________________
激活70(激活)(无,16)0
=================================================================
总参数:47847282
可培训参数:47847282
不可训练参数:0
_________________________________________________________________
没有一个
提供列车和val数据。。。。。。。。。
找到了319835张属于16类的图片。
找到了16个类别的39995张图片。
培训开始。。。。。
纪元1/1
---------------------------------------------------------------------------
OSError回溯(最近一次调用上次)
在里面
---->1.LENET()
错误:
_________________________________________________________________
activation_68 (Activation) (None, 122, 122, 128) 0
_________________________________________________________________
max_pooling2d_42 (MaxPooling (None, 61, 61, 128) 0
_________________________________________________________________
flatten_14 (Flatten) (None, 476288) 0
_________________________________________________________________
dense_27 (Dense) (None, 100) 47628900
_________________________________________________________________
activation_69 (Activation) (None, 100) 0
_________________________________________________________________
dense_28 (Dense) (None, 16) 1616
_________________________________________________________________
activation_70 (Activation) (None, 16) 0
=================================================================
Total params: 47,847,282
Trainable params: 47,847,282
Non-trainable params: 0
_________________________________________________________________
None
Feeding the train and val data.........
Found 319835 images belonging to 16 classes.
Found 39995 images belonging to 16 classes.
Training Starting.....
Epoch 1/1
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-45-0229da3ad25e> in <module>
----> 1 baseline.LENET()
et_大小,插值)
117 elif颜色_模式=='rgb':
118如果img.mode!='RGB':
-->119 img=img.convert('RGB')
120其他:
121 raise VALUERROR('颜色模式必须为“灰度”、“rgb”或“rgba”)
转换中的~\Miniconda3\envs\tensorflow\lib\site packages\PIL\Image.py(自身、模式、矩阵、抖动、调色板、颜色)
928 """
929
-->930 self.load()
931
932如果非模式和self.mode==“P”:
加载中的~\Miniconda3\envs\tensorflow\lib\site packages\PIL\TiffImagePlugin.py(self)
1095 def加载(自):
1096如果自用加载libtiff:
->1097返回自。_加载_libtiff()
1098 return super(TiffImageFile,self).load()
1099
~\Miniconda3\envs\tensorflow\lib\site packages\PIL\TiffImagePlugin.py in\u load\u libtiff(self)
1207
1208如果误差<0:
->1209上升IOError(err)
1210
1211返回Image.Image.load(自)
错误:-2
请告诉我这里有什么问题。我搜索了整个互联网,但无法解决此问题:(
注:数据集是RVL-CDIP数据集。当我使用猫和狗数据集时,上面的代码运行良好。请帮助我。我也有同样的问题,我通过将图像从TIF格式转换为JPEG格式来解决它 我的系统上的文件夹结构是: 另外,你能告诉我你从哪里得到了完整的数据集吗?我只能从Kaggle访问其中的一部分
_________________________________________________________________
activation_68 (Activation) (None, 122, 122, 128) 0
_________________________________________________________________
max_pooling2d_42 (MaxPooling (None, 61, 61, 128) 0
_________________________________________________________________
flatten_14 (Flatten) (None, 476288) 0
_________________________________________________________________
dense_27 (Dense) (None, 100) 47628900
_________________________________________________________________
activation_69 (Activation) (None, 100) 0
_________________________________________________________________
dense_28 (Dense) (None, 16) 1616
_________________________________________________________________
activation_70 (Activation) (None, 16) 0
=================================================================
Total params: 47,847,282
Trainable params: 47,847,282
Non-trainable params: 0
_________________________________________________________________
None
Feeding the train and val data.........
Found 319835 images belonging to 16 classes.
Found 39995 images belonging to 16 classes.
Training Starting.....
Epoch 1/1
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-45-0229da3ad25e> in <module>
----> 1 baseline.LENET()
et_size, interpolation)
117 elif color_mode == 'rgb':
118 if img.mode != 'RGB':
--> 119 img = img.convert('RGB')
120 else:
121 raise ValueError('color_mode must be "grayscale", "rgb", or "rgba"')
~\Miniconda3\envs\tensorflow\lib\site-packages\PIL\Image.py in convert(self, mode, matrix, dither, palette, colors)
928 """
929
--> 930 self.load()
931
932 if not mode and self.mode == "P":
~\Miniconda3\envs\tensorflow\lib\site-packages\PIL\TiffImagePlugin.py in load(self)
1095 def load(self):
1096 if self.use_load_libtiff:
-> 1097 return self._load_libtiff()
1098 return super(TiffImageFile, self).load()
1099
~\Miniconda3\envs\tensorflow\lib\site-packages\PIL\TiffImagePlugin.py in _load_libtiff(self)
1207
1208 if err < 0:
-> 1209 raise IOError(err)
1210
1211 return Image.Image.load(self)
OSError: -2
import os
import cv2
Base_Dir = 'Path-to-Data-Folder'
for Folder in sorted(os.listdir(Base_Dir)):
for Sub_Folder in sorted(os.listdir(Base_Dir + '/' + Folder)):
try:
os.mkdir(Base_Dir + '/' + Folder + '/' + Sub_Folder + '_JPEG')
except OSError:
pass
for File in sorted(os.listdir(Base_Dir + '/' + Folder + '/' + Sub_Folder)):
if File[-3:] == "tif":
Out_File = File[:-3] + "jpeg"
Im = cv2.imread(Base_Dir + '/' + Folder + '/' + Sub_Folder + '/' + File)
cv2.imwrite(Base_Dir + '/' + Folder + '/' + Sub_Folder + '_JPEG/' + Out_File, Im)