Fix: Corrected interpolation parameter in LetterResize to resolve Ope… #270
+1
−1
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.
…nCV error
我在使用 PaddleYOLO 的评估功能时,发现了 LetterResize 操作的一个问题。
问题现象 (The issue):
当 input_size 尺寸超过 640(例如 672, 768 等)时,yolov10模型在评估阶段会抛出以下错误:
OpenCV(4.5.5) 👎 error: (-5:Bad argument) in function 'resize' > Argument 'interpolation' is required to be an integer
经过代码排查,我定位到问题源于 ppdet/data/transform/operators.py 文件中的 LetterResize 类。
错误原因 (The cause):
在 _resize_img 方法内部,cv2.resize 函数的 interpolation 参数被硬编码为字符串 'bilinear',而不是 Python 可以识别的常量 cv2.INTER_LINEAR。这导致了类型错误,使得程序无法正常执行。
解决方案 (The fix):
该问题无法通过修改配置文件来解决,需要直接修改源代码。我将 interpolation='bilinear' 这一行代码改成了 interpolation=cv2.INTER_LINEAR。这个改动确保了 cv2.resize 函数接收到正确的整数类型参数,从而解决了报错问题。