fix SAR inference, when batch size>1, norm_img_batch and valid_ratios… #11238
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.
… shapes do not match
PR 类型 PR types
Bug fixes
PR 变化内容类型 PR changes
APIs
描述 Description
Fix SAR inference bug in tools/infer/predict_rec.py.
When SAR model inferencing with rec_batch_num size>1, an error occured,
ValueError: (InvalidArgument) The 0-th dimension of input[0] and input[1] is expected to be equal.But received input[0]'s shape = [1, 1, 512], input[1]'s shape = [16, 30, 512]. [Hint: Expected inputs_dims[0][j] == inputs_dims[i][j], but received inputs_dims[0][j]:1 != inputs_dims[i][j]:16.] (at /paddle/paddle/phi/kernels/funcs/concat_funcs.h:83)
It cased by
valid_ratios
's incorrect shape.This PR aims to fix this bug.提PR之前的检查 Check-list
This PR is pushed to the dygraph branch or cherry-picked from the dygraph branch. Otherwise, please push your changes to the dygraph branch.