docstr: bias: Whether conv layers have bias or not.
  adaptive: Whether to use adaptive threshold training or not.
  smooth: If true, use bilinear instead of deconv.
  serial: If true, thresh prediction will combine segmentation result as input.
docstr_tok: ["bias",":","Whether","conv","layers","have","bias","or","not",".","adaptive",":","Whether","to","use","adaptive","threshold","training","or","not",".","smooth",":","If","true",",","use","bilinear","instead","of","deconv",".","serial",":","If","true",",","thresh","prediction","will","combine","segmentation","result","as","input","."]
code: def __init__(
      self,
      in_channels=[64, 128, 256, 512],
      inner_channels=256,
      k=10,
      bias=False,
      adaptive=False,
      smooth=False,
      serial=False,
      fpn=True,
      attention_type="scale_spatial",
      *args,
      **kwargs,
  ):
      """
      bias: Whether conv layers have bias or not.
      adaptive: Whether to use adaptive threshold training or not.
      smooth: If true, use bilinear instead of deconv.
      serial: If true, thresh prediction will combine segmentation result as input.
      """
      super(SegSpatialScaleDetector, self).__init__()
      self.k = k
      self.serial = serial
      self.fpn = fpn
      self.up5 = nn.Upsample(scale_factor=2, mode="nearest")
      self.up4 = nn.Upsample(scale_factor=2, mode="nearest")
      self.up3 = nn.Upsample(scale_factor=2, mode="nearest")
  
      self.in5 = nn.Conv2d(
          in_channels[-1], inner_channels, 1, bias=bias
      )
      self.in4 = nn.Conv2d(
          in_channels[-2], inner_channels, 1, bias=bias
      )
      self.in3 = nn.Conv2d(
          in_channels[-3], inner_channels, 1, bias=bias
      )
      self.in2 = nn.Conv2d(
          in_channels[-4], inner_channels, 1, bias=bias
      )
  
      if self.fpn:
          self.out5 = nn.Sequential(
              nn.Conv2d(
                  inner_channels,
                  inner_channels // 4,
                  3,
                  padding=1,
                  bias=bias,
              ),
              nn.Upsample(scale_factor=8, mode="nearest"),
          )
          self.out4 = nn.Sequential(
              nn.Conv2d(
                  inner_channels,
                  inner_channels // 4,
                  3,
                  padding=1,
                  bias=bias,
              ),
              nn.Upsample(scale_factor=4, mode="nearest"),
          )
          self.out3 = nn.Sequential(
              nn.Conv2d(
                  inner_channels,
                  inner_channels // 4,
                  3,
                  padding=1,
                  bias=bias,
              ),
              nn.Upsample(scale_factor=2, mode="nearest"),
          )
          self.out2 = nn.Conv2d(
              inner_channels,
              inner_channels // 4,
              3,
              padding=1,
              bias=bias,
          )
          self.out5.apply(self.weights_init)
          self.out4.apply(self.weights_init)
          self.out3.apply(self.weights_init)
          self.out2.apply(self.weights_init)
  
          self.concat_attention = ScaleFeatureSelection(
              inner_channels,
              inner_channels // 4,
              attention_type=attention_type,
          )
          self.binarize = nn.Sequential(
              nn.Conv2d(
                  inner_channels,
                  inner_channels // 4,
                  3,
                  bias=bias,
                  padding=1,
              ),
              BatchNorm2d(inner_channels // 4),
              nn.ReLU(inplace=True),
              nn.ConvTranspose2d(
                  inner_channels // 4, inner_channels // 4, 2, 2
              ),
              BatchNorm2d(inner_channels // 4),
              nn.ReLU(inplace=True),
              nn.ConvTranspose2d(inner_channels // 4, 1, 2, 2),
              nn.Sigmoid(),
          )
      else:
          self.concat_attention = ScaleFeatureSelection(
              inner_channels,
              inner_channels // 4,
          )
          self.binarize = nn.Sequential(
              nn.Conv2d(
                  inner_channels,
                  inner_channels // 4,
                  3,
                  bias=bias,
                  padding=1,
              ),
              BatchNorm2d(inner_channels // 4),
              nn.ReLU(inplace=True),
              nn.ConvTranspose2d(
                  inner_channels // 4, inner_channels // 4, 2, 2
              ),
              BatchNorm2d(inner_channels // 4),
              nn.ReLU(inplace=True),
              nn.ConvTranspose2d(inner_channels // 4, 1, 2, 2),
              nn.Sigmoid(),
          )
  
      self.binarize.apply(self.weights_init)
      self.adaptive = adaptive
      if adaptive:
          self.thresh = self._init_thresh(
              inner_channels, serial=serial, smooth=smooth, bias=bias
          )
          self.thresh.apply(self.weights_init)
  
      self.in5.apply(self.weights_init)
      self.in4.apply(self.weights_init)
      self.in3.apply(self.weights_init)
      self.in2.apply(self.weights_init)
  
file_path: EasyOCR/easyocr/DBNet/decoders/seg_detector_asf.py
imports: from collections import OrderedDict
  import pdb
  import torch
  import torch.nn
  from .feature_attention import ScaleFeatureSelection
label_desc: Use image node_id 1 to create a new SegSpatialScaleDetector object from inherited base classes: nn with example: obj = SegSpatialScaleDetector(in_channels, inner_channels, k, bias, adaptive, smooth, serial, fpn, attention_type)