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

Add tests for VOCDetectionDataset #177

Merged
merged 10 commits into from
Jun 14, 2017
Merged

Conversation

yuyu2172
Copy link
Member

This test does not check the data downloader.

self.assertIsInstance(bbox, np.ndarray)
self.assertEqual(bbox.dtype, np.float32)
self.assertEqual(bbox.ndim, 2)
self.assertEqual(bbox.shape[1], 4)
Copy link
Member

Choose a reason for hiding this comment

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

How about checking if x_min < x_max?

@@ -61,6 +61,8 @@ class VOCDetectionDataset(chainer.dataset.DatasetMixin):
return_difficult (bool): If true, this dataset returns a boolean array
that indicates whether bounding boxes are labeled as difficult
or not. The default value is :obj:`False`.
If :obj:`use_difficult` is :obj:`False`, this has to be
:obj:`False`.
Copy link
Member

Choose a reason for hiding this comment

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

How about returning a false array as difficult when use_difficult=False and return_difficult=True?


@attr.slow
def test_get_example(self):
for i in np.random.randint(0, len(self.dataset), size=(10,)):
Copy link
Member

Choose a reason for hiding this comment

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

We can use chainer.testing.condition.repeat.

@yuyu2172
Copy link
Member Author

yuyu2172 commented Jun 6, 2017

The maximum coordinates in bounding boxes should be smaller than height and width of an image.
These changes will be reflected after #246.

@yuyu2172 yuyu2172 changed the title Add tests for VOCDetectionDataset [WIP] Add tests for VOCDetectionDataset Jun 6, 2017
@@ -124,7 +125,12 @@ def get_example(self, i):
label.append(voc_utils.voc_detection_label_names.index(name))
bbox = np.stack(bbox).astype(np.float32)
label = np.stack(label).astype(np.int32)
difficult = np.array(difficult, dtype=np.bool)
if self.use_difficult:
Copy link
Member

Choose a reason for hiding this comment

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

This if statement is unnecessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

Are you saying that np.array(difficult, dtype=bool) should be called after if return_difficult?

Copy link
Member

@Hakuyume Hakuyume Jun 9, 2017

Choose a reason for hiding this comment

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

No, I mean that difficult = np.array(difficult, dtype=np.bool) is enough. If use_difficult is False, difficult becomes [False, False, ... ] because it skips difficult GTs (https://github.com/yuyu2172/chainercv/blob/52714429cc7b87c12a5f40a49f8a58c77149c66e/chainercv/datasets/voc/voc_detection_dataset.py#L116-L117). So, we can use difficult = np.array(difficult, dtype=np.bool) to make a False array.

@yuyu2172 yuyu2172 added the test label Jun 9, 2017
@yuyu2172 yuyu2172 added this to the v0.6 milestone Jun 9, 2017
@yuyu2172
Copy link
Member Author

Perhaps, we can add a utility function check_valid_bbox(bbox, H, W), which runs the check done in this test.
However, I am not sure how to call unittest.TestCase.assertEqual outside of the class unittest.TestCase.
One workaround is to use np.testing.assert_equal.

@Hakuyume
What do you think about making the utility function inside this PR?

@yuyu2172 yuyu2172 changed the title [WIP] Add tests for VOCDetectionDataset Add tests for VOCDetectionDataset Jun 11, 2017
@Hakuyume Hakuyume mentioned this pull request Jun 14, 2017
@Hakuyume
Copy link
Member

@Hakuyume
What do you think about making the utility function inside this PR?

I'm working on assertion utilities in #278.

@yuyu2172
Copy link
Member Author

@Hakuyume

Nice. Should I close this PR?

@Hakuyume
Copy link
Member

Nice. Should I close this PR?

No. I want to merge this PR before mine. Now I'm checking this PR. So could you leave this PR open?

@yuyu2172
Copy link
Member Author

OK

Copy link
Member

@Hakuyume Hakuyume left a comment

Choose a reason for hiding this comment

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

LGTM

@Hakuyume Hakuyume merged commit d1b7c85 into chainer:master Jun 14, 2017
@yuyu2172 yuyu2172 deleted the voc-detection-test branch June 14, 2017 11:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants