def __init__(self, num_classes, num_channels=3):
    super().__init__()
    assert (num_channels == 3), 'num channels not used now. to use changle first conv layer to support num channels other then 3'
    filters = [64, 128, 256, 512]
    resnet = models.resnet34(pretrained=True)
    self.firstconv = resnet.conv1
    self.firstbn = resnet.bn1
    self.firstrelu = resnet.relu
    self.firstmaxpool = resnet.maxpool
    self.encoder1 = resnet.layer1
    self.encoder2 = resnet.layer2
    self.encoder3 = resnet.layer3
    self.encoder4 = resnet.layer4
    self.center = nn.Sequential(nn.MaxPool2d(2, 2), nn.Conv2d(filters[3], filters[1], 3, padding=1), nn.BatchNorm2d(filters[1]), nn.ReLU(inplace=True))
    self.decoder5 = UnetBNDecoderBlock(filters[1], (filters[2] // 4), filters[2])
    self.conv5 = nn.Conv2d((256 + 512), 256, 1)
    self.decoder4 = UnetBNDecoderBlock(filters[2], (filters[2] // 4), filters[1])
    self.conv4 = nn.Conv2d((128 + 256), 256, 1)
    self.decoder3 = UnetBNDecoderBlock(filters[2], (filters[2] // 4), filters[0])
    self.conv3 = nn.Conv2d((64 + 128), 128, 1)
    self.decoder2 = UnetBNDecoderBlock(filters[1], (filters[1] // 4), filters[0])
    self.conv2 = nn.Conv2d(128, 64, 1)
    self.finaldeconv1 = UnetBNDecoderBlock(filters[0], (filters[0] // 4), filters[0])
    self.logit = nn.Sequential(nn.Conv2d(64, 64, 3, padding=1), nn.BatchNorm2d(64), nonlinearity(inplace=True), nn.Conv2d(64, 1, 1))
def __init__(self, num_classes, num_channels=3):
    super().__init__()
    assert (num_channels == 3), 'num channels not used now. to use changle first conv layer to support num channels other then 3'
    filters = [64, 128, 256, 512]
    resnet = models.resnet34(pretrained=True)
    self.firstconv = resnet.conv1
    self.firstbn = resnet.bn1
    self.firstrelu = resnet.relu
    self.firstmaxpool = resnet.maxpool
    self.encoder1 = resnet.layer1
    self.encoder2 = resnet.layer2
    self.encoder3 = resnet.layer3
    self.encoder4 = resnet.layer4
    self.center = nn.Sequential(nn.MaxPool2d(2, 2), nn.Conv2d(filters[3], filters[1], 3, padding=1), nn.BatchNorm2d(filters[1]), nn.ReLU(inplace=True))
    self.decoder5 = UnetBNDecoderBlock(filters[1], (filters[2] // 4), filters[2])
    self.conv5 = nn.Conv2d((256 + 512), 256, 1)
    self.decoder4 = UnetBNDecoderBlock(filters[2], (filters[2] // 4), filters[1])
    self.conv4 = nn.Conv2d((128 + 256), 256, 1)
    self.decoder3 = UnetBNDecoderBlock(filters[2], (filters[2] // 4), filters[0])
    self.conv3 = nn.Conv2d((64 + 128), 128, 1)
    self.decoder2 = UnetBNDecoderBlock(filters[1], (filters[1] // 4), filters[0])
    self.conv2 = nn.Conv2d(128, 64, 1)
    self.finaldeconv1 = UnetBNDecoderBlock(filters[0], (filters[0] // 4), filters[0])
    self.logit = nn.Sequential(nn.Conv2d(64, 64, 3, padding=1), nn.BatchNorm2d(64), nonlinearity(inplace=True), nn.Conv2d(64, 1, 1))