def compute_conditional_samples(batch, *args): image_batch = batch.cuda() _ = model(image_batch) acts = model.retained_layer(layername) seg = segmodel.segment_batch(renorm(image_batch), downsample=4) hacts = upfn(acts) return tally.conditional_samples(hacts, seg)
def compute_conditional_indicator(batch, *args): image_batch = batch.cuda() seg = segmodel.segment_batch(renorm(image_batch), downsample=4) _ = model(image_batch) acts = model.retained_layer(layername) hacts = upfn(acts) iacts = (hacts > level_at_99).float() # indicator where > 0.99 percentile. return tally.conditional_samples(iacts, seg)
def compute_conditional_indicator(batch, *args): data_batch = batch.cuda() out_batch = model(data_batch) image_batch = out_batch if is_generator else renorm(data_batch) seg = segmodel.segment_batch(image_batch, downsample=4) acts = model.retained_layer(layername) hacts = upfn(acts) iacts = (hacts > level_at_99).float() # indicator return tally.conditional_samples(iacts, seg)
def compute_selected_segments(batch, *args): img, seg = batch # show(iv.segmentation(seg)) image_batch = img.cuda() seg_batch = seg.cuda() _ = self.model(image_batch) acts = self.model.retained_layer(self.layername) hacts = self.upfn(acts) iacts = (hacts > level_at_99).float() # indicator where > 0.99 percentile. return tally.conditional_samples(iacts, seg_batch)