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

FPN - Add min/max size params for pre-processing. #830

Merged
merged 8 commits into from
Mar 12, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions chainercv/links/model/fpn/faster_rcnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
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 this?

Please refer to :meth:`prepare`.

docstring will be confusing when it rendered by sphinx.

Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

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

I see.

max_size (int): A preprocessing paramter for :meth:`prepare`.

Parameters:
nms_thresh (float): The threshold value
Expand All @@ -40,17 +43,19 @@ class FasterRCNN(chainer.Chain):

"""

_min_size = 800
_max_size = 1333
_stride = 32

def __init__(self, extractor, rpn, head):
def __init__(self, extractor, rpn, head,
min_size=800, max_size=1333):
super(FasterRCNN, self).__init__()
with self.init_scope():
self.extractor = extractor
self.rpn = rpn
self.head = head

self._min_size = min_size
self._max_size = max_size

self.use_preset('visualize')

def use_preset(self, preset):
Expand Down
21 changes: 14 additions & 7 deletions chainercv/links/model/fpn/faster_rcnn_fpn_resnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Copy link
Member

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.

Copy link
Contributor Author

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.

param, path = utils.prepare_pretrained_model(
{'n_fg_class': n_fg_class}, pretrained_model, self._models)

Expand Down Expand Up @@ -56,8 +57,8 @@ class FasterRCNNFPNResNet50(FasterRCNNFPNResNet):
Feature Pyramid Networks for Object Detection. CVPR 2017

Args:
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.
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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!

This can take :obj:`'coco'`, `filepath` or :obj:`None`.
The default value is :obj:`None`.

Expand All @@ -74,6 +75,9 @@ class FasterRCNNFPNResNet50(FasterRCNNFPNResNet):
* `filepath`: A path of npz file. In this case, :obj:`n_fg_class` \
must be specified properly.
* :obj:`None`: Do not load weights.
min_size (int): A preprocessing paramter for :meth:`prepare`. Please
refer to a docstring found for :meth:`prepare`.
max_size (int): A preprocessing paramter for :meth:`prepare`.

"""

Expand All @@ -99,10 +103,10 @@ class FasterRCNNFPNResNet101(FasterRCNNFPNResNet):
Feature Pyramid Networks for Object Detection. CVPR 2017

Args:
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`.
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`.
Copy link
Member

Choose a reason for hiding this comment

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

ditto.


* :obj:`'coco'`: Load weights trained on train split of \
MS COCO 2017. \
Expand All @@ -117,6 +121,9 @@ class FasterRCNNFPNResNet101(FasterRCNNFPNResNet):
* `filepath`: A path of npz file. In this case, :obj:`n_fg_class` \
must be specified properly.
* :obj:`None`: Do not load weights.
min_size (int): A preprocessing paramter for :meth:`prepare`. Please
refer to a docstring found for :meth:`prepare`.
max_size (int): A preprocessing paramter for :meth:`prepare`.

"""

Expand Down