This repository has been archived by the owner on Jul 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 304
FPN - Add min/max size params for pre-processing. #830
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b1cca53
Add size params for preprocessing.
23pointsNorth 451c216
Update FasterRCNN with default sizes.
23pointsNorth ea816f8
Add size param and fix comments.
23pointsNorth b27316c
Add tests for min/max size in prepare.
23pointsNorth 99a0a35
Update size tests
23pointsNorth f1ad965
Fix size param to be a whole integer of _stride.
23pointsNorth 2f2d262
Fix flake8 errors.
23pointsNorth 98e5058
Add note about size.
23pointsNorth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,24 +31,35 @@ def __call__(self, x): | |
|
||
class DummyFasterRCNN(FasterRCNN): | ||
|
||
def __init__(self, n_fg_class): | ||
def __init__(self, n_fg_class, min_size, max_size): | ||
extractor = DummyExtractor() | ||
super(DummyFasterRCNN, self).__init__( | ||
extractor=extractor, | ||
rpn=RPN(extractor.scales), | ||
head=Head(n_fg_class + 1, extractor.scales), | ||
min_size=min_size, max_size=max_size, | ||
) | ||
|
||
|
||
@testing.parameterize( | ||
{'n_fg_class': 1}, | ||
{'n_fg_class': 5}, | ||
{'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, | ||
'in_shape': (3, 480, 640), 'expected_shape': (3, 800, 1088)}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
{'n_fg_class': 5, 'min_size': 200, 'max_size': 400, | ||
'in_shape': (3, 200, 50), 'expected_shape': (3, 400, 100)}, | ||
{'n_fg_class': 5, 'min_size': 800, 'max_size': 133, | ||
'in_shape': (3, 480, 640), 'expected_shape': (3, 800, 1088)}, | ||
{'n_fg_class': 20, 'min_size': 200, 'max_size': 400, | ||
'in_shape': (3, 200, 50), 'expected_shape': (3, 400, 100)}, | ||
{'n_fg_class': 20, 'min_size': 800, 'max_size': 133, | ||
'in_shape': (3, 480, 640), 'expected_shape': (3, 800, 1088)}, | ||
) | ||
class TestFasterRCNN(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.link = DummyFasterRCNN(n_fg_class=self.n_fg_class) | ||
self.link = DummyFasterRCNN(n_fg_class=self.n_fg_class, | ||
min_size=self.min_size, max_size=self.max_size) | ||
|
||
def test_use_preset(self): | ||
self.link.nms_thresh = 0 | ||
|
@@ -117,13 +128,19 @@ def test_predict_gpu(self): | |
self.link.to_gpu() | ||
assert_is_detection_link(self.link, self.n_fg_class) | ||
|
||
def test_prepare(self): | ||
imgs = [ | ||
np.random.randint(0, 255, size=(3, 480, 640)).astype(np.float32), | ||
np.random.randint(0, 255, size=(3, 320, 320)).astype(np.float32), | ||
] | ||
x, scales = self.link.prepare(imgs) | ||
self.assertEqual(x.shape, (2, 3, 800, 1088)) | ||
def check_prepare(self): | ||
x = _random_array(np, self.in_shape) | ||
out, scales = self.link.prepare(x) | ||
self.assertIsInstance(out, np.ndarray) | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. We do not need to make |
||
|
||
@attr.gpu | ||
def test_prepare_gpu(self): | ||
self.link.to_gpu() | ||
self.check_prepare() | ||
|
||
|
||
testing.run_module(__name__, __file__) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 of1333
?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.