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

fix #60 - Support for images with multiple objects in Dataset class #62

Merged
merged 3 commits into from
Oct 23, 2020

Conversation

TasinIshmam
Copy link
Contributor

Problem: If a single image contains more than one object, then the dataset class treats each object as a separate item in the dataset. As a result, if there are 'n' objects for any image 'i', then the same image 'i' is repeated in the dataset 'n' times, one time for each object.

Changes:

  • xml_to_csv() in utils.py was changed to add unique index "image_id" attribute for each image.
  • Dataset.__getitem__(self, idx) in core.py was modified to use "image_id" to index the images. Transformations code also changed to support multiple bounding boxes/labels in the same image.
  • Model._convert_to_int_labels() in core.py changed to support multiple bounding boxes/labels in the same image.
  • Changed

Tests: Passing.

  • Modified test_dataloader() and test_dataset() to ensure compatibility with changes made.

For more information, look at Issue#60.

A column called "image_id" is added to the csv files generated using utils.xml_to_csv().
This image_id field is used by core.Dataset's _getitem_(self, idx) function t o identify the index of any specific image.

Previously the index an entry inside the csv was used for indexing objects in _getitem_(self, idx) function.
However this does not work when each image has more than one object. (See alankbi#60)
Dataset class now supports images with multiple objects.
Changes also made to how transformations are applied to ensure scaling
and flip transformations apply to bounding boxes of all objects in each
image.

Modified Model class internal function _convert_to_int_labels to support
multiple object labels in same image.

Resolves: alankbi#60
Tests updated to ensure compatbility with changes in Dataset class.
@alankbi
Copy link
Owner

alankbi commented Oct 21, 2020

Awesome, thanks for doing this! I'll take a look at this in the next few days and hopefully we can get it merged in soon.

@TasinIshmam
Copy link
Contributor Author

TasinIshmam commented Oct 22, 2020

Awesome, thanks for doing this! I'll take a look at this in the next few days and hopefully we can get it merged in soon.

My pleasure. Please feel free to reach out with any modification suggestions or clarifications.

@alankbi alankbi merged commit eaeb889 into alankbi:master Oct 23, 2020
@alankbi
Copy link
Owner

alankbi commented Oct 23, 2020

Looks great! Merged into master.

I still have to release a new version with these changes, but hopefully I'll have that done tomorrow or over the weekend

@TasinIshmam
Copy link
Contributor Author

Great, glad to know!

@TasinIshmam TasinIshmam deleted the fix-multiple-object branch October 23, 2020 20:25
@TasinIshmam TasinIshmam restored the fix-multiple-object branch October 23, 2020 20:26
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.

None yet

2 participants