Exemplo n.º 1
0
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)
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
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)
Exemplo n.º 4
0
 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
Exemplo n.º 5
0
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)