Derived geodatasets
derived_geodatasets
¶
Attributes¶
Classes¶
CustomImageDataset
¶
Bases: Dataset
Source code in tree_detection_framework/preprocessing/derived_geodatasets.py
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | |
Methods:¶
__init__(images_dir, chip_size, chip_stride, labels_dir=None)
¶
Dataset for creating a dataloader from a folder of individual images, with an option to create tiles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images_dir
|
Union[Path, List[PATH_TYPE]]
|
Path to a folder containing potentially nested image files, or list of paths to image files. By 'nested' image files, that means that images could reside in arbitrarily nested subdirectories and this dataset should iterate over all of them. E.g. images_dir/ subdir1/ [images] subdir2/ [images] |
required |
chip_size
|
int
|
Dimension of each image chip (width, height) in pixels. |
required |
chip_stride
|
int
|
Stride to take while chipping the images (horizontal, vertical) in pixels. |
required |
labels_dir
|
Optional[List[PATH_TYPE]]
|
List of paths to annotation .geojson files corresponding to the images. Should have same file name as the image. |
None
|
Source code in tree_detection_framework/preprocessing/derived_geodatasets.py
CustomRasterDataset
¶
Bases: RasterDataset
Custom dataset class for orthomosaic raster images. This class extends the RasterDataset from torchgeo.
Attributes:
| Name | Type | Description |
|---|---|---|
filename_glob |
str
|
Glob pattern to match files in the directory. |
is_image |
bool
|
Indicates that the data being loaded is image data. |
separate_files |
bool
|
True if data is stored in a separate file for each band, else False. |
Source code in tree_detection_framework/preprocessing/derived_geodatasets.py
CustomVectorDataset
¶
Bases: VectorDataset
Custom dataset class for vector data which act as labels for the raster data. This class extends the VectorDataset from torchgeo.
Source code in tree_detection_framework/preprocessing/derived_geodatasets.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
Methods:¶
__getitem__(query)
¶
Retrieve image/mask and metadata indexed by query.
This function is largely based on the __getitem__ method from TorchGeo's VectorDataset.
Modifications have been made to include the following keys within the returned dictionary:
1. 'shapes' as polygons per tile represented in pixel coordinates.
2. 'bounding_boxes' as bounding box of every detected polygon per tile in pixel coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
BoundingBox
|
(minx, maxx, miny, maxy, mint, maxt) coordinates to index |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
sample of image/mask and metadata at that index |
Raises:
| Type | Description |
|---|---|
IndexError
|
if query is not found in the index |
Source code in tree_detection_framework/preprocessing/derived_geodatasets.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |