Fix data dimension swapping and axis errors#1335
Fix data dimension swapping and axis errors#1335abhayrajjais01 wants to merge 2 commits intoweecology:mainfrom
Conversation
|
Hi @abhayrajjais01,
|
Hi @vickysharma-prog,
|
e11fa34 to
bde5364
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1335 +/- ##
=======================================
Coverage 87.34% 87.34%
=======================================
Files 24 24
Lines 2978 2978
=======================================
Hits 2601 2601
Misses 377 377
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| assert ds[1].shape == (3, 300, 300) | ||
|
|
||
|
|
||
| def test_TiledRaster_non_square(tmp_path): |
There was a problem hiding this comment.
I’m having difficulty seeing how this test is necessary given the changes made.
| # Check that it's 3 bands | ||
| bands = numpy_image.shape[2] | ||
| # Check that it's 3 bands (image is now channels-first: C x H x W) | ||
| bands = numpy_image.shape[0] |
There was a problem hiding this comment.
Please take some time to understand this part of the code, you may be able to make more meaningful improvements to the logic.
Description
This PR addresses two dimensionality and shape bugs when preparing and loading data for predictions.
Changes:
src/deepforest/datasets/prediction.py: Fixed a bug whereheightandwidthbounds were swapped when passed toslidingwindow.generateForSize.rasterio'ssrc.shapereturns(height, width), but the variables were passed to the generator in reversed order.src/deepforest/preprocess.py: Fixed a bug wherenumpy_image.shape[2]was being accessed for the number of bands after the image tensor was already transposed from(H, W, C)to channels-first(C, H, W). It now correctly checksnumpy_image.shape[0].Type of change
AI-Assisted Development
AI tools used (if applicable):
Gemini