【发布时间】:2019-11-15 00:54:40
【问题描述】:
我正在研究来自“APTOS 2019 失明检测”的 kaggle 数据集,该数据集位于一个 zip 文件中。我想预处理数据集以输入深度学习模型。
我的代码如下所示:
train_dir = '../input/train_images'
train_labels = pd.read_csv('../input/train.csv')
train_labels['diagnosis'] = train_labels['diagnosis'].astype(str)
test_dir = '../input/test_images'
然后预处理我写的:
from keras.preprocessing.image import ImageDataGenerator
train_datagen = ImageDataGenerator(
rotation_range=40,
width_shift_range=0.2,
height_shift_range=0.2,
shear_range=0.2,
zoom_range=0.2,
horizontal_flip=True,
vertical_flip=True,
rescale=1./255,)
test_datagen = ImageDataGenerator(rescale = 1./255)
train_generator = train_datagen.flow_from_dataframe(
train_labels[:3295],
directory=train_dir,
x_col='id_code', y_col='diagnosis',
target_size=(150, 150),
color_mode='rgb',
class_mode='categorical',
batch_size=32,
shuffle=True,)
validation_generator = test_datagen.flow_from_dataframe(
train_labels[3295:],
directory=train_dir,
x_col='id_code', y_col='diagnosis',
target_size=(150, 150),
color_mode='rgb',
class_mode='categorical',
batch_size=32,
shuffle=True,)
但是当我运行代码时。我得到的结果是:
找到属于 0 个类的 0 个经过验证的图像文件名。
找到属于 0 个类的 0 个经过验证的图像文件名。
我也尝试过解压缩文件,但它不会解压缩说
FileNotFoundError:[Errno 2] 没有这样的文件或目录:'train_images.zip'
# importing required modules
from zipfile import ZipFile
# specifying the zip file name
file_name = "../input/train_images.zip"
# opening the zip file in READ mode
with ZipFile(file_name, 'r') as zip:
# extracting all the files
print('Extracting all the files now...')
zip.extractall()
那么有人可以帮我解决这个问题吗?我会很感激的
【问题讨论】:
-
首先检查磁盘上是否有
../input/train_images.zip。它可以在您期望的不同文件夹中,或者您从不同文件夹运行脚本因此找不到../input/train_images.zip -
也许你应该手动解压,不用 Python。
-
好吧,我不能。因为它是一个内核唯一的竞争,所以我们只应该在 kaggle 服务器内部工作。否则我可以手动提取它。但显然我已经找到了解决办法。谢谢!