-
Notifications
You must be signed in to change notification settings - Fork 86
MscocoObjectDetection can set optional classes and instantiate. #525
MscocoObjectDetection can set optional classes and instantiate. #525
Conversation
3408bad
to
44d2f81
Compare
I fixed buildkite test. please check again if you have time. |
There was a problem hiding this 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. 😄
@tsawada I changed to blank images from mscoco images. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM Thanks!
lmnet/tests/fixtures/datasets/MSCOCO/annotations/instances_train2014.json
Show resolved
Hide resolved
|
||
|
||
# TODO | ||
def test_mscoco_segmentation(): |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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()
There was a problem hiding this 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.
lmnet/tests/fixtures/datasets/MSCOCO/annotations/instances_train2014.json
Show resolved
Hide resolved
|
||
def test_mscoco_object_detection_optional_classes_instantiate(): | ||
MscocoObjectDetection.classes = ['person'] | ||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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()
@tsawada I fixed some reviews🦀 please check again! |
lmnet/tests/fixtures/datasets/MSCOCO/annotations/instances_val2014.json
Outdated
Show resolved
Hide resolved
@tsawada I fixed it! please check again. |
lmnet/lmnet/datasets/mscoco.py
Outdated
@@ -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__") |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
…e. change annotation values
bd765e9
to
96cc905
Compare
lmnet/lmnet/datasets/mscoco.py
Outdated
@@ -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)) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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!
Motivation and Context
See #523
Description
in
_gt_boxes_from_image_id
, only to useself.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.
How has this been tested?
# on blueoil/lmnet $ PYTHONPATH=. pytest tests/lmnet_tests/datasets_tests/test_mscoco.py
Screenshots (if appropriate):
Types of changes
Checklist: