Skip to content

Issue 594: Property-Based Testing for Image Resizing and Preprocessing#664

Open
knoxiboy wants to merge 4 commits into
neeru24:mainfrom
knoxiboy:feat/issue-594-property-testing
Open

Issue 594: Property-Based Testing for Image Resizing and Preprocessing#664
knoxiboy wants to merge 4 commits into
neeru24:mainfrom
knoxiboy:feat/issue-594-property-testing

Conversation

@knoxiboy

@knoxiboy knoxiboy commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

This PR implements property-based testing using Hypothesis for the preprocess_image_for_resnet function to verify that it correctly resizes and formats arbitrary image dimensions to the target shape.

Related Issue

Closes #594

Changes made

  • Created property-based unit tests using the hypothesis package in tests/test_image_preprocessing.py.
  • Added test_preprocess_image_for_resnet_property to test resizing behavior with various height/width dimensions for RGB images.
  • Added test_preprocess_image_for_resnet_grayscale to test resizing behavior for grayscale (2D) images.
  • Updated preprocess_image_for_resnet in app.py to handle grayscale (2D and 1-channel 3D) arrays gracefully by expanding them to 3 channels to comply with ResNet requirements.
  • Addressed code review feedback:
    • Reduced generated image dimension strategy bounds to 500x500 to keep the CI pipeline quick and reliable.
    • Replaced constant-color comment descriptors to match actual generation strategies.
    • Allowed Hypothesis exceptions to propagate naturally instead of wrapping them in general try-except blocks.
    • Asserted a consistent 3-channel shape (1, 3, 224, 224) for grayscale test preprocessing results.

Checklist

  • I have tested my changes
  • My code follows project guidelines
  • No new errors introduced

Copilot AI review requested due to automatic review settings June 6, 2026 05:42
@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Thanks for creating a PR for your Issue! ☺️

We'll review it as soon as possible.
In the meantime, please double-check the file changes and ensure that all commits are accurate.

If there are any unresolved review comments, feel free to resolve them. 🙌🏼

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds property-based tests for preprocess_image_for_resnet and introduces Hypothesis as a test dependency.

Changes:

  • Added Hypothesis-driven tests to validate output tensor shapes for RGB and grayscale inputs.
  • Added hypothesis to requirements.txt (and normalized the pytest-cov line formatting).

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated 7 comments.

File Description
tests/test_image_preprocessing.py Adds property tests for image preprocessing output shapes across varying input sizes.
requirements.txt Adds Hypothesis as a testing dependency.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_image_preprocessing.py Outdated
Comment thread tests/test_image_preprocessing.py
Comment thread tests/test_image_preprocessing.py Outdated
Comment thread tests/test_image_preprocessing.py Outdated
Comment thread tests/test_image_preprocessing.py Outdated
Comment thread tests/test_image_preprocessing.py Outdated
Comment thread tests/test_image_preprocessing.py
@neeru24

neeru24 commented Jun 8, 2026

Copy link
Copy Markdown
Owner

@knoxiboy resolve conflicts

@knoxiboy

Copy link
Copy Markdown
Contributor Author

@knoxiboy resolve conflicts

Done

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.

[Feature] Property-Based Testing for Image Resizing and Preprocessing

3 participants