-
Notifications
You must be signed in to change notification settings - Fork 60
Add a unified resize operation for detection and a resize op for recognition inference #295
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
Conversation
padded_img = np.zeros((tar_h, tar_w, 3), dtype=np.uint8) | ||
padded_img[:resize_h, :resize_w, :] = resized_img | ||
data['image'] = padded_img |
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.
padded_img = np.zeros((tar_h, tar_w, 3), dtype=np.uint8) | |
padded_img[:resize_h, :resize_w, :] = resized_img | |
data['image'] = padded_img | |
data['image'] = np.pad(data['image'], ((0, tar_h - resize_h), (0, tar_w - resize_w), (0, 0))) |
data['polys'][:, :, 0] = data['polys'][:, :, 0] * scale_w | ||
data['polys'][:, :, 1] = data['polys'][:, :, 1] * scale_h |
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.
data['polys'][:, :, 0] = data['polys'][:, :, 0] * scale_w | |
data['polys'][:, :, 1] = data['polys'][:, :, 1] * scale_h | |
data['polys'] = data['polys'] * [scale_w, scale_h] |
resize_h = self.tar_h | ||
|
||
if self.keep_ratio==False: | ||
assert self.tar_w is not None, 'Must specify target_width if keep_ratio is False' |
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.
Move assert
inside __init__
?
padded_img = np.zeros((self.tar_h, self.tar_w, 3), dtype=np.uint8) | ||
padded_img[:, :resize_w, :] = resized_img | ||
data['image'] = padded_img |
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.
padded_img = np.zeros((self.tar_h, self.tar_w, 3), dtype=np.uint8) | |
padded_img[:, :resize_w, :] = resized_img | |
data['image'] = padded_img | |
data['image'] = np.pad(data['image'], ((0, 0), (0, self.tar_w - resize_w), (0, 0))) |
- DetResize: | ||
target_size: [ 1152, 2048] | ||
keep_ratio: True | ||
limit_type: auto |
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 feel this is a bit confusing. When I want an image to have a specific resolution (set by target_size
) and keep its ratio, I must need to set limit_type
to auto
. Otherwise, I will get completely unexpected output.
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.
Don't have to set limit_type auto in this case. You can just use the default "min". Here auto is just to make the same as ScalePadImage.
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.
If I don't set limit_type
to auto
, the output will be of size 736 by the shortest side.
under further improvment. |
32ebb72
to
d1cd911
Compare
Thank you for your contribution to the MindOCR repo.
Before submitting this PR, please make sure:
Motivation
(Write your motivation for proposed changes here.)
Test Plan
(How should this PR be tested? Do you require special setup to run the test or repro the fixed bug?)
Related Issues and PRs
(Is this PR part of a group of changes? Link the other relevant PRs and Issues here. Use https://help.github.com/en/articles/closing-issues-using-keywords for help on GitHub syntax)