Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert_pascal_voc_to_tfrecords error #29

Open
fmthoker opened this issue Aug 23, 2017 · 2 comments
Open

convert_pascal_voc_to_tfrecords error #29

fmthoker opened this issue Aug 23, 2017 · 2 comments

Comments

@fmthoker
Copy link

While running the notebook i get the following error.

IOError Traceback (most recent call last)
in ()
24
25 write_image_annotation_pairs_to_tfrecord(filename_pairs=overall_train_image_annotation_filename_pairs,
---> 26 tfrecords_filename='pascal_augmented_train.tfrecords')

/home/fmthoker/bonn/lab_vision_systems/slim/models/tf-image-segmentation/tf_image_segmentation/utils/tf_records.py in write_image_annotation_pairs_to_tfrecord(filename_pairs, tfrecords_filename)
36
37 img = np.array(Image.open(img_path))
---> 38 annotation = np.array(Image.open(annotation_path))
39 # Unomment this one when working with surgical data
40 # annotation = annotation[:, :, 0]

/home/fmthoker/bonn/lab_vision_systems/tensorflow/local/lib/python2.7/site-packages/PIL/Image.pyc in open(fp, mode)
2408
2409 if filename:
-> 2410 fp = builtins.open(filename, "rb")
2411 exclusive_fp = True
2412

IOError: [Errno 2] No such file or directory: './benchmark_RELEASE/dataset/cls_png/2008_007573.png

Note: i have downloaded both pascal dataset and benchmark.

@hanskrupakar
Copy link

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()

`

@JosephKJ
Copy link

JosephKJ commented Nov 28, 2017

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants