Skip to content

Fix inconsistent performance when infer SVTR ONNX #14895

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Copy link

paddle-bot bot commented Mar 18, 2025

Thanks for your contribution!

@GreatV GreatV requested a review from Topdu March 20, 2025 02:36
@jzhang533 jzhang533 requested a review from Copilot April 2, 2025 05:53
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses inconsistent performance when inferring SVTR ONNX by modifying the image resize normalization function.

  • Updates the resize_norm_img_svtr function to adjust the image width dynamically based on the input aspect ratio.
  • Introduces padding for the resized image to ensure consistent dimensions.
Comments suppressed due to low confidence (1)

tools/infer/predict_rec.py:387

  • [nitpick] While not necessarily a naming error, the conditional logic determining resized_w could benefit from inline comments or a more descriptive variable name to clarify its purpose.
if math.ceil(imgH * ratio) > imgW:

max_wh_ratio = imgW * 1.0 / imgH
h, w = img.shape[0], img.shape[1]
ratio = w * 1.0 / h
max_wh_ratio = min(max(max_wh_ratio, ratio), max_wh_ratio)
Copy link
Preview

Copilot AI Apr 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The computation for max_wh_ratio is redundant since min(max(max_wh_ratio, ratio), max_wh_ratio) will always evaluate to the original max_wh_ratio. Consider removing this line or revising it to correctly adjust the ratio if that was the intent.

Suggested change
max_wh_ratio = min(max(max_wh_ratio, ratio), max_wh_ratio)
max_wh_ratio = max(max_wh_ratio, ratio)

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant