class_docstr: Userguidedcolorization, see https://github.com/haoyuying/colorization-pytorch
  
  Args:
      use_tanh (bool): Whether to use tanh as final activation function.
      load_checkpoint (str): Pretrained checkpoint path.
class_docstr_tok: ["Userguidedcolorization",",","see","https",":","\/\/github.com\/haoyuying\/colorization-pytorch","Args",":","use_tanh","(","bool",")",":","Whether","to","use","tanh","as","final","activation","function",".","load_checkpoint","(","str",")",":","Pretrained","checkpoint","path","."]
code: def __init__(
      self, use_tanh: bool = True, load_checkpoint: str = None
  ):
      super(UserGuidedColorization, self).__init__()
      self.input_nc = 4
      self.output_nc = 2
      # Conv1
      model1 = (
          Conv2D(self.input_nc, 64, 3, 1, 1),
          nn.ReLU(),
          Conv2D(64, 64, 3, 1, 1),
          nn.ReLU(),
          nn.BatchNorm(64),
      )
  
      # Conv2
      model2 = (
          Conv2D(64, 128, 3, 1, 1),
          nn.ReLU(),
          Conv2D(128, 128, 3, 1, 1),
          nn.ReLU(),
          nn.BatchNorm(128),
      )
  
      # Conv3
      model3 = (
          Conv2D(128, 256, 3, 1, 1),
          nn.ReLU(),
          Conv2D(256, 256, 3, 1, 1),
          nn.ReLU(),
          Conv2D(256, 256, 3, 1, 1),
          nn.ReLU(),
          nn.BatchNorm(256),
      )
  
      # Conv4
      model4 = (
          Conv2D(256, 512, 3, 1, 1),
          nn.ReLU(),
          Conv2D(512, 512, 3, 1, 1),
          nn.ReLU(),
          Conv2D(512, 512, 3, 1, 1),
          nn.ReLU(),
          nn.BatchNorm(512),
      )
  
      # Conv5
      model5 = (
          Conv2D(512, 512, 3, 1, 2, 2),
          nn.ReLU(),
          Conv2D(512, 512, 3, 1, 2, 2),
          nn.ReLU(),
          Conv2D(512, 512, 3, 1, 2, 2),
          nn.ReLU(),
          nn.BatchNorm(512),
      )
  
      # Conv6
      model6 = (
          Conv2D(512, 512, 3, 1, 2, 2),
          nn.ReLU(),
          Conv2D(512, 512, 3, 1, 2, 2),
          nn.ReLU(),
          Conv2D(512, 512, 3, 1, 2, 2),
          nn.ReLU(),
          nn.BatchNorm(512),
      )
  
      # Conv7
      model7 = (
          Conv2D(512, 512, 3, 1, 1),
          nn.ReLU(),
          Conv2D(512, 512, 3, 1, 1),
          nn.ReLU(),
          Conv2D(512, 512, 3, 1, 1),
          nn.ReLU(),
          nn.BatchNorm(512),
      )
  
      # Conv8
      model8up = (
          Conv2DTranspose(512, 256, kernel_size=4, stride=2, padding=1),
      )
      model3short8 = (Conv2D(256, 256, 3, 1, 1),)
      model8 = (
          nn.ReLU(),
          Conv2D(256, 256, 3, 1, 1),
          nn.ReLU(),
          Conv2D(256, 256, 3, 1, 1),
          nn.ReLU(),
          nn.BatchNorm(256),
      )
  
      # Conv9
      model9up = (
          Conv2DTranspose(256, 128, kernel_size=4, stride=2, padding=1),
      )
      model2short9 = (
          Conv2D(
              128,
              128,
              3,
              1,
              1,
          ),
      )
      model9 = (
          nn.ReLU(),
          Conv2D(128, 128, 3, 1, 1),
          nn.ReLU(),
          nn.BatchNorm(128),
      )
  
      # Conv10
      model10up = (
          Conv2DTranspose(128, 128, kernel_size=4, stride=2, padding=1),
      )
      model1short10 = (Conv2D(64, 128, 3, 1, 1),)
      model10 = (
          nn.ReLU(),
          Conv2D(128, 128, 3, 1, 1),
          nn.LeakyReLU(negative_slope=0.2),
      )
      model_class = (Conv2D(256, 529, 1),)
  
      if use_tanh:
          model_out = (Conv2D(128, 2, 1, 1, 0, 1), nn.Tanh())
      else:
          model_out = (Conv2D(128, 2, 1, 1, 0, 1),)
  
      self.model1 = nn.Sequential(*model1)
      self.model2 = nn.Sequential(*model2)
      self.model3 = nn.Sequential(*model3)
      self.model4 = nn.Sequential(*model4)
      self.model5 = nn.Sequential(*model5)
      self.model6 = nn.Sequential(*model6)
      self.model7 = nn.Sequential(*model7)
      self.model8up = nn.Sequential(*model8up)
      self.model8 = nn.Sequential(*model8)
      self.model9up = nn.Sequential(*model9up)
      self.model9 = nn.Sequential(*model9)
      self.model10up = nn.Sequential(*model10up)
      self.model10 = nn.Sequential(*model10)
      self.model3short8 = nn.Sequential(*model3short8)
      self.model2short9 = nn.Sequential(*model2short9)
      self.model1short10 = nn.Sequential(*model1short10)
      self.model_class = nn.Sequential(*model_class)
      self.model_out = nn.Sequential(*model_out)
  
      self.set_config()
  
      if load_checkpoint is not None:
          self.model_dict = paddle.load(load_checkpoint)
          self.set_dict(self.model_dict)
          print("load custom checkpoint success")
      else:
          checkpoint = os.path.join(
              self.directory, "user_guided.pdparams"
          )
          self.model_dict = paddle.load(checkpoint)
          self.set_dict(self.model_dict)
          print("load pretrained checkpoint success")
  
file_path: PaddleHub/modules/image/Image_editing/colorization/user_guided_colorization/module.py
imports: import os
  import paddle
  import paddle.nn
  from paddle.nn import Conv2D, Conv2DTranspose
  from paddlehub.module.module import moduleinfo
  import paddlehub.vision.transforms
  from paddlehub.module.cv_module import ImageColorizeModule
  from .data_feed import ColorizePreprocess
label_desc: Use image node_id 1 to create a new UserGuidedColorization object from inherited base classes: nn with example: obj = UserGuidedColorization(use_tanh, load_checkpoint)