Fix bug in example (miss-leading under certain circumstance) #21
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
There is a potential bug in the given example, regarding the regular expression for file matching. This could lead to mismatching between image filenames and annotation filenames, which may cause serious confusion in the final COCO-format result.
Details
pycococreator/examples/shapes/shapes_to_coco.py
Line 63 in 207b4fa
The line above produces a regular expression for file matching image file with its annotation files. However, it might fail under certain circumstances.
For example, if there are two images (1.jpg and 1000.jpg). The regular expression produced when finding the annotation files for 1.jpg will be
1.*
. Unfortunately, this expression also includes annotation files corresponding to 1000.pngImplemented fix
Changed the regular expression from
basename.*
tobaseline_.*
successfully solved the problem, as long as the user sticks to the naming conventionbasename_classname_instanceID
for annotation files.Note
this bug does not affect the original example, but users modifying the example for their custom dataset may trigger it and suffer from that. At least, it took me considerable time to figure that out. :)