-
Notifications
You must be signed in to change notification settings - Fork 233
Correct Resize pipeline #211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 4 commits
b1f972b
159e5ce
b0ab0dd
e98d5b8
12568ad
41ea798
1246986
6a263be
880e94b
156d50b
6564429
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | |||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -205,7 +205,7 @@ def __call__(self, results): | ||||||||||||||||||||||||||||||||||||||||||||||||
| scale = (self.scale[-1], int(self.scale[-1] / w * h)) | |||||||||||||||||||||||||||||||||||||||||||||||||
| else: | |||||||||||||||||||||||||||||||||||||||||||||||||
| # direct use the given ones | |||||||||||||||||||||||||||||||||||||||||||||||||
| scale = self.scale | |||||||||||||||||||||||||||||||||||||||||||||||||
| scale = self.scale[::-1] | |||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||
| if self.keep_ratio: | |
| img, scale_factor = mmcv.imrescale( | |
| img, | |
| scale, | |
| return_scale=True, | |
| interpolation=self.interpolation, | |
| backend=self.backend) | |
| else: | |
| img, w_scale, h_scale = mmcv.imresize( | |
| img, | |
| scale, | |
| return_scale=True, | |
| interpolation=self.interpolation, | |
| backend=self.backend) | |
| scale_factor = np.array((w_scale, h_scale), dtype=np.float32) | |
| return img, scale_factor |
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.
You may use the following command to run the unit test locally.
coverage run --branch --source mmgen -m pytest -s tests/test_datasets/test_pipelines/test_augmentation.py
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... I think it's a little bit confusing though. Current Resize:
| Cases | Arguments | Comments |
|---|---|---|
| scale with a factor & keep ratio | scale=float, keep_ratio=True | lack of asserting keep_ratio=True; not support scale=int |
| scale with factors (fh, fw) & not keep ratio | not supported | |
| scale with size (h, w) & not keep ratio | scale=(h, w), keep_ratio=False | Misplaced h and w |
| scale with size (h, -1) & keep ratio | scale=(h, -1), keep_ratio=True; | lack of asserting keep_ratio=True; variable max_long_edge could be the actual short edge |
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 can help resolve the problems:
- lacking asserting
keep_ratio=True; - not support scale=int;
- Misplaced
handw(solved).
But as for the " variable max_long_edge could be the actual short edge", it requires futher discussion.
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.
Your analysis of cases 1 and 2 are correct. And for case 3 we automatically rescale short edge and this behavior is independent of the position of -1 in scale.
Uh oh!
There was an error while loading. Please reload this page.