feat(detection): support windowed GeoTIFF reads in InferenceSlicer#2281
Open
madhavcodez wants to merge 1 commit into
Open
feat(detection): support windowed GeoTIFF reads in InferenceSlicer#2281madhavcodez wants to merge 1 commit into
madhavcodez wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2281 +/- ##
=======================================
Coverage 79% 79%
=======================================
Files 66 66
Lines 8567 8584 +17
=======================================
+ Hits 6726 6744 +18
+ Misses 1841 1840 -1 🚀 New features to boost your workflow:
|
InferenceSlicer can now accept an open rasterio-style dataset and read each tile via a windowed read instead of loading the whole image into memory, enabling tiled inference on multi-GB aerial/drone GeoTIFFs. Detection is duck-typed so rasterio stays an optional dependency (supervision[geotiff]) and the library imports no rasterio symbols. Adds CRS projected validation and tests. Closes roboflow#2027.
a3a44a2 to
7354a40
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes #2027.
InferenceSlicercan now run tiled inference directly on an open rasterio-style dataset, reading each tile via a windowed read instead of loading the whole image into memory. This makes it possible to slice multi-GB aerial/drone GeoTIFFs that don't fit in RAM — the exact patternInferenceSliceralready implements, just sourced from disk windows rather than an in-memory array.The original reporter outlined this with a
rasterio.windows-based reference implementation; this PR integrates the capability intoInferenceSliceritself (the issue has been open and unclaimed for ~5 months).Design
_is_windowed_raster: a callable.readplus.crs/.width/.height), and tiles are read with rasterio's tuple-window formread(window=((row_start, row_stop), (col_start, col_stop))). Installable viapip install "supervision[geotiff]"(new optional extra).crop_image,resolution_wh,compact_masks, out-of-bounds warning, andmove_detectionssemantics. All existingInferenceSlicertests pass unmodified.ValueError, since pixel-space tiling on lat/lon is meaningless;crs is None(a plain TIFF) is allowed.uint16) and all bands; selecting/converting is the callback's responsibility (documented in the__call__docstring).Tests
tests/detection/tools/test_inference_slicer_geotiff.py— runs without rasterio installed via a lightweight fake dataset, and includes a realrasterio.MemoryFileintegration test guarded byimportorskip:overlap_wh > 0);crop_imagetile;crs=Noneworks, geographic CRS raises, projected CRS does not;uint16) is preserved through to the callback.Notes for reviewers
rasterioimport leaks into core. Happy to add astr | Pathconvenience overload (opening/closing the dataset internally) in a follow-up if you'd prefer that ergonomics.WindowedRasterDatasetProtocolso static type checkers accept a rasterio dataset without supervision depending on rasterio's types.