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

Slicing: add unique slice index number to output file name #943

Merged
merged 4 commits into from
Nov 5, 2023

Conversation

jokober
Copy link
Contributor

@jokober jokober commented Sep 4, 2023

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

  • File 1: file_name: ./mot-123/img1/000001.jpg
  • File 2: file_name: ./mot-456/img1/000001.jpg

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.

@jokober
Copy link
Contributor Author

jokober commented Sep 16, 2023

I just found this discussion which likely is related: #721

@fcakyon
Copy link
Collaborator

fcakyon commented Nov 5, 2023

Thanks a lot for your contribution @jokober !

@fcakyon fcakyon added this pull request to the merge queue Nov 5, 2023
Merged via the queue into obss:main with commit f04a7ee Nov 5, 2023
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

Successfully merging this pull request may close these issues.

2 participants