Slicing: add unique slice index number to output file name #943
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.
I had a problem with sahi resulting in wrong bounding boxes after slicing. This is kind of a edge case but I still wanted to propose a solution to that.
This happened due my dataset structure. I have images with the same file name but in different folders. Like so
After slicing the sliced images get a new name starting with the file name and followed by the slicing coordinates. However sahi does not check if there is already a file available with that name. Hence an existing image file with the same name but an originally different path will be overwritten and the coco dataset will contain several entries linking to the same sliced image but containing different bounding boxes. This resulted in a faulty dataset.
The way I solved it is probably not the prettiest but the fastest I guess. I simply added an index to the slice names resulting in new unique names.