azavea / raster-vision

An open source library and framework for deep learning on satellite and aerial imagery.
https://docs.rastervision.io
Other
2.03k stars 380 forks source link

Use smarter default padding value for sliding windows #2190

Closed AdeelH closed 2 weeks ago

AdeelH commented 2 weeks ago

Overview

This PR introduces a new calculate_required_padding() function that calculates the appropriate padding size--based on size, stride, pad_direction, and crop_sz--which is now used by Box.get_windows() and predict_scene_ss(). It also adds more discussion about padding to the Sampling training data tutorial notebook.

The main motivation is to make it easier to determine the right padding when making semantic segmentation predictions with a crop_sz such that no pixels are left out. The padding value calculated by calculate_required_padding() ensures this.

Additionally, when crop_sz is not specified, calculate_required_padding() returns the minimum padding required to generate enough windows to cover the entire extent. This is a change from the previous behavior of always using size / 2.

Checklist

Notes

N/A

Testing Instructions

See new/updated unit tests.

codecov[bot] commented 2 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 90.14%. Comparing base (adac1a2) to head (4389af7).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #2190 +/- ## ========================================== + Coverage 90.09% 90.14% +0.05% ========================================== Files 198 198 Lines 9879 9877 -2 ========================================== + Hits 8900 8904 +4 + Misses 979 973 -6 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.