(segmenter, loader, model)
| 218 | return total_scores |
| 219 | |
| 220 | def count_segments(segmenter, loader, model): |
| 221 | total_bincount = 0 |
| 222 | data_size = 0 |
| 223 | progress = default_progress() |
| 224 | for i, batch in enumerate(progress(loader)): |
| 225 | tensor_images = model(z_batch.to(device)) |
| 226 | seg = segmenter.segment_batch(tensor_images, downsample=2) |
| 227 | bc = (seg + index[:, None, None, None] * self.num_classes).view(-1 |
| 228 | ).bincount(minlength=z_batch.shape[0] * self.num_classes) |
| 229 | data_size += seg.shape[0] * seg.shape[2] * seg.shape[3] |
| 230 | total_bincount += batch_label_counts.float().sum(0) |
| 231 | normalized_bincount = total_bincount / data_size |
| 232 | return normalized_bincount |
| 233 | |
| 234 | if __name__ == '__main__': |
| 235 | main() |
nothing calls this directly
no test coverage detected