Skip to content
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

Fix weird resized width and height if the difference of image ratio is large #18

Merged
merged 4 commits into from
Apr 10, 2024

Conversation

Pandede
Copy link
Owner

@Pandede Pandede commented Apr 10, 2024

Intuition

Before forward the image to model, resize the image to ensure the width and height are the multiply of stride (default: 16) is mandatory. However, there is a weird behaviour when the ratio between width and height is large.

Observation

Assume that an image in shape (40, 248, 3) is ready to be resized, the method Predictor._resize_to_fixed_ratio is invoked and returns a resized image in shape (608, 3776), which is extremely large and improper. That may decrease the inference time without any rising performance.
This behaviour is also spotted in the original code.

Solution

The solution is modify the way to compute factor: it should be bound_dim / max(h,w).
After the fix, the image is resized in shape (112, 608), which is more proper.

@Pandede Pandede self-assigned this Apr 10, 2024
@Pandede Pandede merged commit 7427875 into master Apr 10, 2024
2 checks passed
@Pandede Pandede deleted the fix-weird-resized-wh branch April 10, 2024 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant