Sampling from disparate ROIs? #2201
-
Hi, is there a recommended way to setup samplers/datamodules so that disparate ROIs can be sampled from a large image? For example, in this image: is it possible to sample only from cells A-H for training, and from cells G&I for validation? Assuming that the bounds for each cell are known in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Multiple ways actually! If you don't care about exactly which cells get assigned where, the easiest solution is torchgeo.datasets.random_grid_cell_assignment. Note that this acts on a single tile at a time, not on the entire area of the dataset. We should probably think about adding something that does the latter (@pmandiola any interest?) If you do care, and G&I must be in validation, but you do know the bounds for each cell in advance, then you can use torchgeo.datasets.roi_split instead. You can pass in ROIs for A-F, G, H, and I. Then you can compute the union of A-F and H, and the union of G and I, and you'll end up with exactly what you're looking for. Hope this helps! And feel free to contribute new splitters if these don't get you what you want. Or better visualizations for the docs. We really need better visualizations for these docs... |
Beta Was this translation helpful? Give feedback.
-
Oh, perfect! It looks like I was completely missing the |
Beta Was this translation helpful? Give feedback.
Multiple ways actually!
If you don't care about exactly which cells get assigned where, the easiest solution is torchgeo.datasets.random_grid_cell_assignment. Note that this acts on a single tile at a time, not on the entire area of the dataset. We should probably think about adding something that does the latter (@pmandiola any interest?)
If you do care, and G&I must be in validation, but you do know the bounds for each cell in advance, then you can use torchgeo.datasets.roi_split instead. You can pass in ROIs for A-F, G, H, and I. Then you can compute the union of A-F and H, and the union of G and I, and you'll end up with exactly what you're looking for.
Hope this helps! And feel free …