MCPcopy Create free account
hub / github.com/CSAILVision/gandissect / count_segments

Function count_segments

netdissect/fullablate.py:220–232  ·  view source on GitHub ↗
(segmenter, loader, model)

Source from the content-addressed store, hash-verified

218 return total_scores
219
220def 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
234if __name__ == '__main__':
235 main()

Callers

nothing calls this directly

Calls 2

default_progressFunction · 0.90
segment_batchMethod · 0.45

Tested by

no test coverage detected