def simple_mil(extractor, channels, freeze=True): cnn_to_bw(extractor, IMGNET_MEAN, IMGNET_STD) if freeze: for param in extractor.parameters(): param.requires_grad = False mil_scores = nn.Sequential(nn.Conv2d(channels, 1, 1, 1, 0)) return PretrainedMIL(extractor, mil_scores)
def simple_pretrained(extractor, channels, features_shape, freeze=True): cnn_to_bw(extractor, IMGNET_MEAN, IMGNET_STD) if freeze: for param in extractor.parameters(): param.requires_grad = False predict = nn.Sequential(nn.Conv2d(channels, 1, features_shape, 1, 0), nn.Sigmoid()) return Pretrained(extractor, predict)
def simple_slicerMIL(extractor, feature_dims, freeze = True): cnn_to_bw(extractor, IMGNET_MEAN, IMGNET_STD) if freeze: for param in extractor.parameters(): param.requires_grad = False mil_scores = nn.Sequential( nn.Conv3d(feature_dims, 1, 1, 1, 0)) return PretrainedSlicerMIL(extractor, mil_scores)
def __init__(self, extractor): cnn_to_bw(extractor, IMGNET_MEAN, IMGNET_STD) for param in extractor.parameters(): param.requires_grad = False self.extractor = extractor if torch.cuda.is_available(): self.extractor = self.extractor.cuda() self.tree = None
def simple_slicer(extractor, feature_dims, feature_size, freeze = True): cnn_to_bw(extractor, IMGNET_MEAN, IMGNET_STD) if freeze: for param in extractor.parameters(): param.requires_grad = False predict = nn.Sequential( nn.Conv3d(feature_dims, 1, feature_size, 1, 0), nn.Sigmoid()) return PretrainedSlicer(extractor, predict)