(self, inputs, outputs, patches, batch_size)
| 250 | return self._ensure_tuple_outputs(outputs) |
| 251 | |
| 252 | def _initialize_mergers(self, inputs, outputs, patches, batch_size): |
| 253 | in_patch = torch.chunk(patches, batch_size)[0] |
| 254 | mergers = [] |
| 255 | ratios = [] |
| 256 | for out_patch_batch in outputs: |
| 257 | out_patch = torch.chunk(out_patch_batch, batch_size)[0] |
| 258 | # calculate the ratio of input and output patch sizes |
| 259 | ratio = tuple(op / ip for ip, op in zip(in_patch.shape[2:], out_patch.shape[2:])) |
| 260 | |
| 261 | # calculate merged_shape and cropped_shape |
| 262 | merger_kwargs = self.merger_kwargs.copy() |
| 263 | cropped_shape, merged_shape = self._get_merged_shapes(inputs, out_patch, ratio) |
| 264 | if "merged_shape" not in merger_kwargs: |
| 265 | merger_kwargs["merged_shape"] = merged_shape |
| 266 | if merger_kwargs["merged_shape"] is None: |
| 267 | raise ValueError("`merged_shape` cannot be `None`.") |
| 268 | if "cropped_shape" not in merger_kwargs: |
| 269 | merger_kwargs["cropped_shape"] = cropped_shape |
| 270 | |
| 271 | # initialize the merger |
| 272 | merger = self.merger_cls(**merger_kwargs) |
| 273 | |
| 274 | # store mergers and input/output ratios |
| 275 | mergers.append(merger) |
| 276 | ratios.append(ratio) |
| 277 | |
| 278 | return mergers, ratios |
| 279 | |
| 280 | def _aggregate(self, outputs, locations, batch_size, mergers, ratios): |
| 281 | for output_patches, merger, ratio in zip(outputs, mergers, ratios): |
no test coverage detected