Imageomics / Imageomics/wing-segmentation

Coco annotation image filenames are wrong when resizing is used

Open
#7 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
6
Forks
2
PR merge metrics
No merged PRs in 30d

Description

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](https://github.com/Imageomics/wing-segmentation/blob/main/src/wing_segmenter/image_processor.py#L77)...

```python
# 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](https://github.com/Imageomics/wing-segmentation/blob/main/src/wing_segmenter/image_processor.py#L99))

```python
# 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
1. 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!

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in src/wing_segmenter/image_processor.py around the resized-image save at line 77 and COCO metadata call at line 99. Trace how relative_path and save_path are used when --size is set for non-PNG sources. Done means metadata/coco_annotations.json uses the filenames written in the resized output subdirectory while retaining the resized annotation coordinates.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-vision
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.