(self, cfg, name)
| 467 | |
| 468 | class ValidationDataset(PreprocessedDataset): |
| 469 | def __init__(self, cfg, name): |
| 470 | super(ValidationDataset, self).__init__(cfg, name) |
| 471 | self.tiles = [] |
| 472 | |
| 473 | if self.num_images == 0: |
| 474 | return |
| 475 | |
| 476 | input_channel_indices = get_channel_indices(self.channels, self.all_channels) |
| 477 | |
| 478 | # Split the images into tiles |
| 479 | for sample_index in range(self.num_images): |
| 480 | # Get the input image |
| 481 | input_name, _ = self.samples[sample_index] |
| 482 | input_image, _ = self.images[input_name] |
| 483 | |
| 484 | # Get the size of the image |
| 485 | height = input_image.shape[0] |
| 486 | width = input_image.shape[1] |
| 487 | if height < self.tile_size or width < self.tile_size: |
| 488 | error('image is smaller than the tile size') |
| 489 | |
| 490 | # Compute the number of tiles |
| 491 | num_tiles_y = height // self.tile_size |
| 492 | num_tiles_x = width // self.tile_size |
| 493 | |
| 494 | # Compute the start offset for centering |
| 495 | start_y = (height % self.tile_size) // 2 |
| 496 | start_x = (width % self.tile_size) // 2 |
| 497 | |
| 498 | # Add the tiles |
| 499 | for y in range(num_tiles_y): |
| 500 | for x in range(num_tiles_x): |
| 501 | oy = start_y + y * self.tile_size |
| 502 | ox = start_x + x * self.tile_size |
| 503 | |
| 504 | if self.main_feature == 'sh1': |
| 505 | for k in range(0, 9, 3): |
| 506 | ch = input_channel_indices[k:k+3] + input_channel_indices[9:] |
| 507 | self.tiles.append((sample_index, oy, ox, ch)) |
| 508 | else: |
| 509 | self.tiles.append((sample_index, oy, ox, input_channel_indices)) |
| 510 | |
| 511 | def __len__(self): |
| 512 | return len(self.tiles) |
nothing calls this directly
no test coverage detected