-
Notifications
You must be signed in to change notification settings - Fork 370
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
GridGeoSampler: change stride of last patch to sample entire ROI #630
GridGeoSampler: change stride of last patch to sample entire ROI #630
Conversation
…l and issue warning
…l and issue warning
…artial patch (to be padded) test_single.py: add tests for multiple limit cases (see issue microsoft#448)
@adamjstewart this is ready for review. I added more tests than necessary. I can remove some if you'd prefer. |
It seems like a test with the NAIP dataset is failing, but on Windows, the tests passes. Can you try on Ubuntu @adamjstewart ? I'll be back home thursday to test on Ubuntu locally if needed. |
@adamjstewart I added you as collaborator on my fork if you'd like to push some modifications. I'll be in and out until next week |
@remtav, can you add me as well? |
Okay so I just played with this for awhile, the NAIPChesapeakeDataModule has stride hardcoded as 128 which I think makes the 2nd box generated by the sampler jump out of the dataset bounds. The test data is 218x128 and strides of < 64 seem to work. |
Wait a minute. Do we want to sample beyond the ROI?? What if I have a geospatial train/val/test split and the sampler goes beyond the ROI of train into val/test? Wouldn't that be bad? |
An alternative behavior to make sure we sample all space within the ROI without sampling beyond is to force an additional overlapping box along the right and bottom sides of the ROI. |
@calebrob6 which of these possible solutions does that correspond to? #448 (comment) |
Adjust the stride of the last patch only -- e.g. of the logic is here https://github.com/microsoft/poultry-cafos/blob/main/cafo/data/TileDatasets.py#L65 |
That's also the solution I had implemented in my first solution (draft): |
Trying to release 0.3.1 in approximately 1 week. @remtav can you revert back to your original solution and we can iterate from there? If you're busy, I can take over from here. I think we've agreed on what the correct behavior should be, which was the hardest part. Note that #736 may also affect the same lines of code. |
…into samplers/gridgeosampler_bounds # Conflicts: # torchgeo/samplers/single.py
Sure, I can revert and build on top of initial solution (adjust stride of last patch) with unit tests and formatting clean up. I'll push at the latest on monday. |
…r row/col and issue warning" This reverts commit cb554c6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still need to check to make sure the rounding is right, will compare to #736 later.
Ready for review @adamjstewart Old: Hopefully that does it, but please double check. There might also be small conflicts with #736. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks correct for all situations I can think of. Just a few remaining questions/suggestions before this is ready to merge.
Thanks for the fix @remtav! Sorry this took so long to merge. |
…rosoft#630) * Adjust minx/miny with a smaller stride for the last sample per row/col and issue warning * style and mypy fixes * black test fix * Adjust minx/miny with a smaller stride for the last sample per row/col and issue warning * style and mypy fixes * black test fix * single.py: adapt gridgeosampler to sample beyond limit of ROI for a partial patch (to be padded) test_single.py: add tests for multiple limit cases (see issue microsoft#448) * format for black and flake8 * format for black and flake8 * once again, format for black and flake8 * Revert "Adjust minx/miny with a smaller stride for the last sample per row/col and issue warning" This reverts commit cb554c6 * adapt unit tests, remove warnings * flake8: remove warnings import * Address some comments * Simplify computation of # rows/cols * Document this new feature * Fix size of ceiling symbol * Simplify tests Co-authored-by: Adam J. Stewart <[email protected]>
* Adjust minx/miny with a smaller stride for the last sample per row/col and issue warning * style and mypy fixes * black test fix * Adjust minx/miny with a smaller stride for the last sample per row/col and issue warning * style and mypy fixes * black test fix * single.py: adapt gridgeosampler to sample beyond limit of ROI for a partial patch (to be padded) test_single.py: add tests for multiple limit cases (see issue #448) * format for black and flake8 * format for black and flake8 * once again, format for black and flake8 * Revert "Adjust minx/miny with a smaller stride for the last sample per row/col and issue warning" This reverts commit cb554c6 * adapt unit tests, remove warnings * flake8: remove warnings import * Address some comments * Simplify computation of # rows/cols * Document this new feature * Fix size of ceiling symbol * Simplify tests Co-authored-by: Adam J. Stewart <[email protected]>
…rosoft#630) * Adjust minx/miny with a smaller stride for the last sample per row/col and issue warning * style and mypy fixes * black test fix * Adjust minx/miny with a smaller stride for the last sample per row/col and issue warning * style and mypy fixes * black test fix * single.py: adapt gridgeosampler to sample beyond limit of ROI for a partial patch (to be padded) test_single.py: add tests for multiple limit cases (see issue microsoft#448) * format for black and flake8 * format for black and flake8 * once again, format for black and flake8 * Revert "Adjust minx/miny with a smaller stride for the last sample per row/col and issue warning" This reverts commit cb554c6 * adapt unit tests, remove warnings * flake8: remove warnings import * Address some comments * Simplify computation of # rows/cols * Document this new feature * Fix size of ceiling symbol * Simplify tests Co-authored-by: Adam J. Stewart <[email protected]>
This PR changes the way in which
GridGeoSampler
samples patches from each tile if the tile size is not a multiple of the stride. We want to cover the entire tile, requiring us to adjust the stride of the final row/column.This also changes the number of patches returned from each tile. Let$i$ be the size of the input tile. Let $k$ be the requested size of the output patch. Let $s$ be the requested stride. Let $o$ be the number of output rows/columns sampled from each tile.
Before
After
Reboot of #448
Fixes #431