Open fmthoker opened 7 years ago
Hey, I got a similar error. I didn't know what the problem was so I simply circumvented it by ensuring all image and annotation filenames exist by adding this condition at Line 36 in utils/tf_records.py
for img_path, annotation_path in filename_pairs:
if os.path.exists(img_path) and os.path.exists(annotation_path):
img = np.array(Image.open(img_path))
annotation = np.array(Image.open(annotation_path))
# Unomment this one when working with surgical data
# annotation = annotation[:, :, 0]
# The reason to store image sizes was demonstrated
# in the previous example -- we have to know sizes
# of images to later read raw serialized string,
# convert to 1d array and convert to respective
# shape that image used to have.
height = img.shape[0]
width = img.shape[1]
img_raw = img.tostring()
annotation_raw = annotation.tostring()
example = tf.train.Example(features=tf.train.Features(feature={
'height': _int64_feature(height),
'width': _int64_feature(width),
'image_raw': _bytes_feature(img_raw),
'mask_raw': _bytes_feature(annotation_raw)}))
writer.write(example.SerializeToString())
writer.close()
`
You need to convert the .mat annotations into images, before converting to tf_records
You can do this by:
from tf_image_segmentation.utils.pascal_voc import convert_pascal_berkeley_augmented_mat_annotations_to_png
pascal_berkeley_root = '/home/joseph/Dataset/BerkleySegmentationData/benchmark_RELEASE'
convert_pascal_berkeley_augmented_mat_annotations_to_png(pascal_berkeley_root)
While running the notebook i get the following error.
IOError Traceback (most recent call last)