Skip to content

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

Merged
Pandede merged 4 commits into
masterfrom
fix-weird-resized-wh
Apr 10, 2024
Merged

Fix weird resized width and height if the difference of image ratio is large#18
Pandede merged 4 commits into
masterfrom
fix-weird-resized-wh

Conversation

@Pandede

@Pandede Pandede commented Apr 10, 2024

Copy link
Copy Markdown
Owner

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
@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