Skip to content

visual support for object detection dataset #1639

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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

VaranRohila
Copy link

@VaranRohila VaranRohila commented Mar 12, 2020

Added visualization support for object detection dataset.
Issue Link: Link

Procedure:

  1. Find out all the keys with the Sequence feature connector (Bbox are wrapped inside them).
  2. Find the keys with BboxFeature in Sequence keys.
  3. Find the labels if there are any in the Sequence keys.
  4. Plot image, bboxes, and labels on them.

We only take the first Sequence feature, first bbox feature and first label feature for now.

Notebook demonstration: Link

@googlebot googlebot added the cla: yes Author has signed CLA label Mar 12, 2020
@tfds-bot tfds-bot added the community:please_review Community - We need your help to review this PR. label Mar 12, 2020
Copy link
Member

@Conchylicultor Conchylicultor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR.

@tfds-bot tfds-bot added author:please_respond Author - please respond to the recent comments. and removed community:please_review Community - We need your help to review this PR. labels Mar 12, 2020
@VaranRohila
Copy link
Author

@Conchylicultor I have made some major changes in the structure of the module as you had suggested. There is one main file visualization.py and two visualizer modules image_visualizer.py and object_visualizer.py

@tfds-bot tfds-bot added tfds:is_reviewing TFDS team: PTAL and removed author:please_respond Author - please respond to the recent comments. labels Mar 13, 2020
Copy link
Member

@Conchylicultor Conchylicultor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the update. There seems to be a lot of duplicated code, making it harder to maintain. Could you re-factor in smaller functions reused across modules to avoid duplication ?

@tfds-bot tfds-bot added author:please_respond Author - please respond to the recent comments. and removed tfds:is_reviewing TFDS team: PTAL labels Mar 13, 2020
@VaranRohila
Copy link
Author

@Conchylicultor I have made changes according to your suggestions. Created an ImageVisualizer base class and two child classes, SupervisedVisualizer and ObjectVisualizer.

Could you suggest some methods to reuse the code inside the build function? I was thinking of using python decorators but that would certainly increase the code complexity quite a bit.

@VaranRohila
Copy link
Author

Update: I checked my code on wider_faces dataset as well. It is working fine, added that to the colab notebook for demonstration. I have also added a bbox_label flag to the parameters so that the label is not plotted for the bbox (for the datasets that have too many bbox and labels associated with them).

@tfds-bot tfds-bot added tfds:is_reviewing TFDS team: PTAL and removed author:please_respond Author - please respond to the recent comments. labels Mar 13, 2020
@tfds-bot tfds-bot added author:please_respond Author - please respond to the recent comments. and removed tfds:is_reviewing TFDS team: PTAL labels Mar 16, 2020
@VaranRohila
Copy link
Author

@Conchylicultor Some structural changes in the code. The ImageVisulaizer now has a build function which acts as a binder for two functions, _infer_object_keys() and _plot_objects() which should be defined in the child classes.

In the _infer_object_keys() we retrieve keys of the objects we need to plot on a single image like for SupervisedVisualizer we retrieve label keys and ObjectVisualizer we retrieve the bboxes and the labels keys and we pass them to the _plot_objects() function in the child classes.

In the _plot_objects() method of the child classes, we plot the objects on a single example. We plot labels for SupervisedVisualizer; labels and objects for ObjectVisualizer.

@tfds-bot tfds-bot added tfds:is_reviewing TFDS team: PTAL and removed author:please_respond Author - please respond to the recent comments. labels Mar 16, 2020
Copy link
Member

@Conchylicultor Conchylicultor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the update! This looks better

@tfds-bot tfds-bot added author:please_respond Author - please respond to the recent comments. and removed tfds:is_reviewing TFDS team: PTAL labels Mar 19, 2020
@VaranRohila
Copy link
Author

@Conchylicultor I have also overridden build function in the child classes so that more arguments can be added with respect to different child classes like bbox_label flag in ObjectVisualizer.

@VaranRohila
Copy link
Author

Also added DummyObjectDetection class in the test_utils.py for usage in the visualization_test.py file. Ran the test and it is working for both.

@tfds-bot tfds-bot added tfds:is_reviewing TFDS team: PTAL and removed author:please_respond Author - please respond to the recent comments. labels Mar 20, 2020
@Conchylicultor
Copy link
Member

I ended up refactoring myself the visualization to make it more extensible: https://github.com/tensorflow/datasets/pull/1728/files
Could you refactor the code to use the new class ?

@tfds-bot tfds-bot added author:please_respond Author - please respond to the recent comments. and removed tfds:is_reviewing TFDS team: PTAL labels Mar 26, 2020
@VaranRohila
Copy link
Author

Since I encountered some git errors, I had to force push. Everything is ok now/

@tfds-bot tfds-bot added tfds:is_reviewing TFDS team: PTAL and removed author:please_respond Author - please respond to the recent comments. labels Mar 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Author has signed CLA tfds:is_reviewing TFDS team: PTAL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants