Skip to content

Prevent zero-sized letterbox resizes - #26

Merged
parkjinman98 merged 1 commit into
mainfrom
codex/fix-zero-sized-resize-in-floor-letterboxing
Oct 2, 2026
Merged

parkjinman98 merged 1 commit into
mainfrom
codex/fix-zero-sized-resize-in-floor-letterboxing

Conversation

@parkjinman98

Copy link
Copy Markdown
Contributor

Motivation

  • Floor-mode letterboxing could truncate a highly asymmetric source axis to zero, causing cv2.resize to raise an exception and enabling a low-severity denial-of-service when unhandled.
  • The change aims to preserve upstream "floor" semantics while ensuring downstream preprocessing never requests an empty resize dimension.

Description

  • Clamp computed resized dimensions in LetterBoxGeometry.from_shapes so resized_height and resized_width are at least 1 while keeping existing rounding/truncation behavior otherwise. This prevents zero-sized resize targets from reaching OpenCV.
  • Add regression tests in tests/test_yolox_damoyolo.py that exercise extremely wide and extremely tall inputs through the packaged YOLOX and DAMO-YOLO preprocessing configurations to ensure the short axis remains nonzero for size_rounding="floor".

Testing

  • Ran the package YOLOX/DAMO-YOLO tests with OpenCV GL stub: LD_LIBRARY_PATH=/tmp/fake-gl python -m pytest -q tests/test_yolox_damoyolo.py, resulting in 94 passed (all tests in that file).
  • Ran the specific floor-rounding subset: LD_LIBRARY_PATH=/tmp/fake-gl python -m pytest -q tests/test_yolox_damoyolo.py -k 'floor_rounding', resulting in 5 passed for the focused cases.
  • Note: the environment lacks libGL.so.1 so tests used a temporary no-op GL loader under /tmp/fake-gl; pre-commit was not available in the execution environment.

Codex Task

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@parkjinman98
parkjinman98 merged commit 7b5cd1a into main Oct 2, 2026
3 checks passed
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