Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

MscocoObjectDetection can set optional classes and instantiate. #525

Merged

Conversation

takecore
Copy link
Contributor

@takecore takecore commented Oct 15, 2019

Motivation and Context

See #523

Description

in _gt_boxes_from_image_id, only to use self.classes related annotation data.

I add lmnet/test/fixtures/datasets/MSCOCO. please check this out.
I add blank 4 images to MSCOCO/train2014, MSCOCO/val2014.
like this image 10x10 black image.

COCO_train2014_000000000001

How has this been tested?

# on blueoil/lmnet
$ PYTHONPATH=. pytest tests/lmnet_tests/datasets_tests/test_mscoco.py

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature / Optimization (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@blueoil-butler blueoil-butler bot added the CI: auto-run Run CI automatically label Oct 15, 2019
@iizukak iizukak added the CI: test-all Run all tests once label Oct 16, 2019
@blueoil-butler blueoil-butler bot removed the CI: test-all Run all tests once label Oct 16, 2019
@takecore takecore force-pushed the fix/mscoco-dataset-can-use-optional-classes branch from 3408bad to 44d2f81 Compare October 16, 2019 09:29
@takecore
Copy link
Contributor Author

I fixed buildkite test. please check again if you have time.

Copy link
Contributor

@Joeper214 Joeper214 left a comment

Choose a reason for hiding this comment

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

@takecore Thanks for your contribution! I added some comments. Also, please specify if either this is a bugfix or enhancement. 😄

@iizukak iizukak requested a review from tsawada October 17, 2019 04:05
@takecore
Copy link
Contributor Author

@tsawada I changed to blank images from mscoco images.
please check this out🐥

Copy link
Contributor

@Joeper214 Joeper214 left a comment

Choose a reason for hiding this comment

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

LGTM Thanks!



# TODO
def test_mscoco_segmentation():
Copy link
Contributor

Choose a reason for hiding this comment

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

This gives a false sense that we test segmentation (when somebody looks at list of tests)
So just have a todo comment without a function.
# TODO(takecore): test segmentation


def test_mscoco_object_detection_optional_classes_instantiate():
MscocoObjectDetection.classes = ['person']
try:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why a try block? I think the test fails when the function throws exception anyway (I might be wrong)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tsawada

This try block mean instantiate test.

I think the test fails when the function throws exception anyway

I think so. but test fails problem is how class designed is. (I think it is out of scope.)
This PR just fix override classes and can instantiate.

# ok pattern
MscocoObjectDetection()

# error occured pattern, but this PR will can run
MscocoObjectDetection.classes = ['person']
MscocoObjectDetection()

Copy link
Contributor Author

@takecore takecore left a comment

Choose a reason for hiding this comment

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

@tsawada thank I commented.


def test_mscoco_object_detection_optional_classes_instantiate():
MscocoObjectDetection.classes = ['person']
try:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tsawada

This try block mean instantiate test.

I think the test fails when the function throws exception anyway

I think so. but test fails problem is how class designed is. (I think it is out of scope.)
This PR just fix override classes and can instantiate.

# ok pattern
MscocoObjectDetection()

# error occured pattern, but this PR will can run
MscocoObjectDetection.classes = ['person']
MscocoObjectDetection()

@takecore
Copy link
Contributor Author

@tsawada I fixed some reviews🦀 please check again!

@takecore
Copy link
Contributor Author

@tsawada I fixed it! please check again.

@@ -225,10 +225,16 @@ def coco_category_id_to_lmnet_class_id(self, cat_id):
@functools.lru_cache(maxsize=None)
def _gt_boxes_from_image_id(self, image_id):
"""Return gt boxes list ([[x, y, w, h, class_id]]) of a image."""
classes = set(class_name for class_name in self.classes if class_name is not "__background__")
Copy link
Contributor

Choose a reason for hiding this comment

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

class_ids should be a set BUTclasses should be a list.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, you right. I fixed this.

@takecore takecore force-pushed the fix/mscoco-dataset-can-use-optional-classes branch from bd765e9 to 96cc905 Compare October 25, 2019 08:08
@@ -198,7 +198,7 @@ def coco(self):
def _image_ids(self):
"""Return all files and gt_boxes list."""
classes = [class_name for class_name in self.classes if class_name is not "__background__"]
target_class_ids = self.coco.getCatIds(catNms=classes)
target_class_ids = set(self.coco.getCatIds(catNms=classes))
Copy link
Contributor

Choose a reason for hiding this comment

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

why do you use set() here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tsawada I have 2 reasons.

When another person looks at the code in the future, it can be recognized that the same description is written.
If they can be recognized as the same, it is easy to fixed or abstracted.
That's why I used set.

It's hard to tell if you're using self.classes in this class or if you're using looped classes.
I want to distinguish each one.
But, since the scope of the fixes is getting wider and wider, I have only described set.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we don't need set() here. Please leave it as a list.

Copy link
Contributor Author

@takecore takecore Oct 25, 2019

Choose a reason for hiding this comment

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

thanks I fixed it as a list.

Copy link
Contributor

@tsawada tsawada left a comment

Choose a reason for hiding this comment

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

LGTM, Approval

Thanks for all the fixes!

@iizukak iizukak merged commit a189ba4 into blue-oil:master Oct 29, 2019
@takecore takecore deleted the fix/mscoco-dataset-can-use-optional-classes branch October 30, 2019 09:58
@iizukak iizukak added this to the v0.14.0 milestone Nov 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CI: auto-run Run CI automatically
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants