docstr: Multi-path 4-Cascaded RefineNet for image segmentation
  
  Args:
      input_shape ((int, int)): (channel, size) assumes input has
          equal height and width
      refinenet_block (block): RefineNet Block
      num_classes (int, optional): number of classes
      features (int, optional): number of features in refinenet
      resnet_factory (func, optional): A Resnet model from torchvision.
          Default: models.resnet101
      pretrained (bool, optional): Use pretrained version of resnet
          Default: True
      freeze_resnet (bool, optional): Freeze resnet model
          Default: True
  
  Raises:
      ValueError: size of input_shape not divisible by 32
docstr_tok: ["Multi-path","4-Cascaded","RefineNet","for","image","segmentation","Args",":","input_shape","(","(","int",",","int",")",")",":","(","channel",",","size",")","assumes","input","has","equal","height","and","width","refinenet_block","(","block",")",":","RefineNet","Block","num_classes","(","int",",","optional",")",":","number","of","classes","features","(","int",",","optional",")",":","number","of","features","in","refinenet","resnet_factory","(","func",",","optional",")",":","A","Resnet","model","from","torchvision",".","Default",":","models.resnet101","pretrained","(","bool",",","optional",")",":","Use","pretrained","version","of","resnet","Default",":","True","freeze_resnet","(","bool",",","optional",")",":","Freeze","resnet","model","Default",":","True","Raises",":","ValueError",":","size","of","input_shape","not","divisible","by","32"]
code: def __init__(
      self,
      input_shape,
      refinenet_block,
      num_classes=1,
      features=256,
      resnet_factory=models.resnet101,
      pretrained=True,
      freeze_resnet=False,
      **kwargs,
  ):
      """Multi-path 4-Cascaded RefineNet for image segmentation
  
      Args:
          input_shape ((int, int)): (channel, size) assumes input has
              equal height and width
          refinenet_block (block): RefineNet Block
          num_classes (int, optional): number of classes
          features (int, optional): number of features in refinenet
          resnet_factory (func, optional): A Resnet model from torchvision.
              Default: models.resnet101
          pretrained (bool, optional): Use pretrained version of resnet
              Default: True
          freeze_resnet (bool, optional): Freeze resnet model
              Default: True
  
      Raises:
          ValueError: size of input_shape not divisible by 32
      """
      super().__init__()
  
      input_channel, input_size = input_shape
  
      if input_size % 32 != 0:
          raise ValueError("{} not divisble by 32".format(input_shape))
  
      resnet = resnet_factory(pretrained=pretrained)
  
      self.layer1 = nn.Sequential(
          resnet.conv1,
          resnet.bn1,
          resnet.relu,
          resnet.maxpool,
          resnet.layer1,
      )
  
      self.layer2 = resnet.layer2
      self.layer3 = resnet.layer3
      self.layer4 = resnet.layer4
  
      if freeze_resnet:
          layers = [self.layer1, self.layer2, self.layer3, self.layer4]
          for layer in layers:
              for param in layer.parameters():
                  param.requires_grad = False
  
      self.layer1_rn = nn.Conv2d(
          256, features, kernel_size=3, stride=1, padding=1, bias=False
      )
      self.layer2_rn = nn.Conv2d(
          512, features, kernel_size=3, stride=1, padding=1, bias=False
      )
      self.layer3_rn = nn.Conv2d(
          1024, features, kernel_size=3, stride=1, padding=1, bias=False
      )
      self.layer4_rn = nn.Conv2d(
          2048,
          2 * features,
          kernel_size=3,
          stride=1,
          padding=1,
          bias=False,
      )
  
      self.refinenet4 = RefineNetBlock(
          2 * features, (2 * features, input_size // 32)
      )
      self.refinenet3 = RefineNetBlock(
          features,
          (2 * features, input_size // 32),
          (features, input_size // 16),
      )
      self.refinenet2 = RefineNetBlock(
          features,
          (features, input_size // 16),
          (features, input_size // 8),
      )
      self.refinenet1 = RefineNetBlock(
          features,
          (features, input_size // 8),
          (features, input_size // 4),
      )
  
      self.output_conv = nn.Sequential(
          ResidualConvUnit(features),
          ResidualConvUnit(features),
          nn.Conv2d(
              features,
              num_classes,
              kernel_size=1,
              stride=1,
              padding=0,
              bias=True,
          ),
      )
  
file_path: pywick/pywick/models/segmentation/refinenet/refinenet.py
imports: import torch.nn
  import torchvision.models
  import torch.nn.functional
  from .blocks import RefineNetBlock, ResidualConvUnit, RefineNetBlockImprovedPooling
label_desc: Use image node_id 1 to create a new BaseRefineNet4Cascade object from inherited base classes: nn with example: obj = BaseRefineNet4Cascade(input_shape, refinenet_block, num_classes, features, resnet_factory, pretrained, freeze_resnet)