-
Notifications
You must be signed in to change notification settings - Fork 304
FPN - Add min/max size params for pre-processing. #830
Conversation
Thanks. Can you set the default values for |
@@ -26,6 +26,9 @@ class FasterRCNN(chainer.Chain): | |||
head (Link): A link that has the same interface as | |||
:class:`~chainercv.links.model.fpn.Head`. | |||
Please refer to the documentation found there. | |||
min_size (int): A preprocessing paramter for :meth:`prepare`. Please | |||
refer to a docstring found for :meth:`prepare`. |
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.
How about this?
Please refer to :meth:`prepare`.
docstring
will be confusing when it rendered by sphinx.
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 was done in the same style as the faster-rcnn docs with regards to the param.
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 see.
n_fg_class (int): The number of classes excluding the background. | ||
pretrained_model (string): The weight file to be loaded. | ||
n_fg_class (int): The number of classes excluding the background. | ||
pretrained_model (string): The weight file to be loaded. |
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 did you change the indentation?
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.
The rest of the code is indented with 4 space.
These lines were with 3. I am happy to revert if comments don't follow this requirement.
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 was my mistake. Thank you for fixing!
n_fg_class (int): The number of classes excluding the background. | ||
pretrained_model (string): The weight file to be loaded. | ||
This can take :obj:`'coco'`, `filepath` or :obj:`None`. | ||
The default value is :obj:`None`. |
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.
ditto.
@@ -19,7 +19,8 @@ class FasterRCNNFPNResNet(FasterRCNN): | |||
A subclass of this class should have :obj:`_base` and :obj:`_models`. | |||
""" | |||
|
|||
def __init__(self, n_fg_class=None, pretrained_model=None): | |||
def __init__(self, n_fg_class=None, pretrained_model=None, | |||
min_size=800, max_size=1333): |
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.
min_size
and max_size
are not used.
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.
That was a versioning mistake. It will be added on L39.
Perhaps, we can modify the tests to pass those parameters explicitly. In that case, we can remove the default value from |
@23pointsNorth Can you add tests that change |
I am not sure how you expect the testing to look like. If we inspect the other place I can alter the tests to include a value for min/max, such that we can remove the default in the class (but I think it may be unnecessary, Edit based on:
|
The test in
I'm sorry for my confusing comment. It is OK to keep the default values. I just mentioned the side-effect. |
@Hakuyume I attempted to add extra tests. I changed them to follow the ones in test_faster_rcnn in regards to The |
{'n_fg_class': 20}, | ||
{'n_fg_class': 1, 'min_size': 200, 'max_size': 400, | ||
'in_shape': (3, 200, 50), 'expected_shape': (3, 400, 100)}, | ||
{'n_fg_class': 1, 'min_size': 800, 'max_size': 133, |
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.
133
is typo of 1333
?
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.
Yes, a typo.
self.assertEqual(out.shape, self.expected_shape) | ||
|
||
def test_prepare_cpu(self): | ||
self.check_prepare() |
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.
We do not need to make _cpu/_gpu
because prepare
is not related cupy
.
You can use @testing.parameterize(*testing.product_dict(
[
{'n_fg_class': 1},
{'n_fg_class': 5},
{'n_fg_class': 20},
],
[
{
'in_shape': (3, 480, 640),
'min_size': 800, 'max_size': 1333,
'expected_shape': (3, 800, 1088),
},
{
'in_shape': (3, 200, 50),
'min_size': 200, 'max_size': 400,
'expected_shape': (3, 400, 100),
},
],
))
class TestFasterRCNN(unittest.TestCase): |
{'n_fg_class': 1, 'min_size': 200, 'max_size': 400, | ||
'in_shape': (3, 200, 50), 'expected_shape': (3, 400, 100)}, | ||
{'n_fg_class': 1, 'min_size': 800, 'max_size': 133, | ||
'in_shape': (3, 480, 640), 'expected_shape': (3, 800, 1088)}, |
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.
prepare
can accept a batch of images of different shapes.
How about 'in_sizes': [(480, 640), (320, 320)], 'expected_size': (800, 1088)
? (I omit 3
because it is not parameterized)
I think I've incorporated all of the requests. A general unexpected behaviour I found based on the tests i.e. This I think is ok in general, but should be documented somewhere. |
Actually, this is an expected behavior (same as the Detecton's implementation).
How about adding a note here?
For example,
|
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. Thank you!
Allow for the
min_size
,max_size
parameter to be set when creating an FPN network.It is following the Faster-RCNN template.