Skip to content

Coco annotation image filenames are wrong when resizing is used #7

@vsivsi

Description

@vsivsi

Hi, thanks for all of the work put into this newest 0.1.0 release. It's a big improvement!

One little glitch I've run into is that the image filenames written in the metadata/coco_annotations.json output file are incorrect when the --size option is used, and the source images aren't already PNG format files.

The result is a coco format file that uses the resized image coordinates (for bounding boxes, masks, etc.) but continues to use the original source data image filenames, and not the renamed files as output in the resized output subdir.

The issue appears to arise because the resized image output filename constructed here...

            # Save resized image
            base = Path(relative_path).with_suffix("") 
            save_path = os.path.join(segmenter.resized_dir, str(base) + ".png")

...isn't then propagated to the code where the coco image metadata is recorded (here)

        # Initialize COCO annotations for this image
        image_id = add_coco_image_info(segmenter.coco_annotations_path, relative_path, working_image.shape)

Note that relative_path is used to construct save_path, but that new filename is then ignored in writing the coco image info.

What I expected would happen is either:

  1. The coco annotation filenames would match those written to the resized subdir, or
  2. The coco bbox and segmentation annotations would be rescaled back to the original source image resolutions.

Thanks again for maintaining this tool, it's proving very useful for our work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions