InvalidArgumentError:jpeg::解压缩失败。 JPEG 数据或裁剪窗口无效。 [[{{节点decode_image/DecodeImage}}]] [Op:IteratorGetNext]
嗨,我收到错误
InvalidArgumentError:jpeg::解压缩失败。无效的 JPEG 数据或 裁剪窗口。 [[{{节点解码图像/解码图像}}]] [操作:IteratorGetNext]
运行下面的代码后。该错误来自行
for image_batch, label_batch in test_dataset
我可以知道为什么会出现此错误吗?谢谢
BATCH_SIZE = 32
IMG_SIZE = (224, 224)
train_dataset = image_dataset_from_directory(data_dir,
shuffle=True,
label_mode = 'categorical',
validation_split = 0.2,
batch_size=BATCH_SIZE,
seed = 42,
subset = "training",
image_size=IMG_SIZE
)
validation_dataset = image_dataset_from_directory(data_dir,
shuffle=True,
label_mode = 'categorical',
validation_split = 0.2,
batch_size=BATCH_SIZE,
seed = 42,
subset = "validation",
image_size=IMG_SIZE
)
train_size = int(0.8 * len(train_dataset))
test_dataset = train_dataset.skip(train_size)
y_pred_species = [] # store predicted labels
y_pred_diseases = []
y_true = [] # store true labels
# iterate over the dataset
for image_batch, label_batch in test_dataset: # use dataset.unbatch() with repeat
# append true labels
y_true.append(label_batch)
# compute predictions
preds = model.predict(image_batch)
# append predicted labels
y_pred_species.append(np.argmax(preds[0], axis = - 1))
y_pred_diseases.append(np.argmax(preds[1], axis = - 1))
# convert the true and predicted labels into tensors
correct_labels = tf.concat([item for item in y_true], axis = 0)
correct_labels = np.argmax(correct_labels, axis=1)
predicted_species_labels = tf.concat([item for item in y_pred_species], axis = 0)
predicted_diseases_labels = tf.concat([item for item in y_pred_diseases], axis = 0)
Hi I am getting the error
InvalidArgumentError: jpeg::Uncompress failed. Invalid JPEG data or
crop window. [[{{node decode_image/DecodeImage}}]]
[Op:IteratorGetNext]
after running the code below. The error is coming from the line,
for image_batch, label_batch in test_dataset
May I know why does this error appear? thanks
BATCH_SIZE = 32
IMG_SIZE = (224, 224)
train_dataset = image_dataset_from_directory(data_dir,
shuffle=True,
label_mode = 'categorical',
validation_split = 0.2,
batch_size=BATCH_SIZE,
seed = 42,
subset = "training",
image_size=IMG_SIZE
)
validation_dataset = image_dataset_from_directory(data_dir,
shuffle=True,
label_mode = 'categorical',
validation_split = 0.2,
batch_size=BATCH_SIZE,
seed = 42,
subset = "validation",
image_size=IMG_SIZE
)
train_size = int(0.8 * len(train_dataset))
test_dataset = train_dataset.skip(train_size)
y_pred_species = [] # store predicted labels
y_pred_diseases = []
y_true = [] # store true labels
# iterate over the dataset
for image_batch, label_batch in test_dataset: # use dataset.unbatch() with repeat
# append true labels
y_true.append(label_batch)
# compute predictions
preds = model.predict(image_batch)
# append predicted labels
y_pred_species.append(np.argmax(preds[0], axis = - 1))
y_pred_diseases.append(np.argmax(preds[1], axis = - 1))
# convert the true and predicted labels into tensors
correct_labels = tf.concat([item for item in y_true], axis = 0)
correct_labels = np.argmax(correct_labels, axis=1)
predicted_species_labels = tf.concat([item for item in y_pred_species], axis = 0)
predicted_diseases_labels = tf.concat([item for item in y_pred_diseases], axis = 0)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论