예제 #1
0
 def _init_param(self):
     nu.init_module(self.Q_noise)
     nu.init_module(self.R_noise)
     nu.init_module(self.pred2loc)
     nu.init_lstm_module(self.pred_lstm)
     nu.init_lstm_module(self.Q_lstm)
     nu.init_lstm_module(self.R_lstm)
예제 #2
0
 def _init_param(self):
     nu.init_module(self.loc2feat)
     nu.init_module(self.vel2feat)
     nu.init_module(self.pred2loc)
     nu.init_lstm_module(self.pred_lstm)
     nu.init_lstm_module(self.refine_lstm)
    def __init__(self, arch_name, roi_name, down_ratio, roi_kernel):
        super(Model, self).__init__()
        self.base = dla_up.__dict__[arch_name](
            pretrained_base='imagenet', down_ratio=down_ratio)

        num_channel = self.base.channels[int(np.log2(down_ratio))]

        # We use roialign with kernel size = 7 in our experiments
        assert ('align' in roi_name or 'pool' in roi_name)
        assert (roi_kernel == 7)

        if 'align' in roi_name:
            print('Using RoIAlign')
            self.roi_pool = ROIAlign(
                                    (roi_kernel, roi_kernel), 
                                    1.0 / down_ratio, 
                                    0)
        elif 'pool' in roi_name:
            print('Using RoIPool')
            self.roi_pool = ROIPool(
                                    (roi_kernel, roi_kernel), 
                                    1.0 / down_ratio)

        self.dim = nn.Sequential(
            nn.Conv2d(num_channel, num_channel,
                      kernel_size=3, stride=1, padding=0, bias=False),
            nn.BatchNorm2d(num_channel),
            nn.ReLU(inplace=True),
            nn.Conv2d(num_channel, num_channel,
                      kernel_size=3, stride=1, padding=0, bias=False),
            nn.BatchNorm2d(num_channel),
            nn.ReLU(inplace=True),
            nn.Conv2d(num_channel, num_channel,
                      kernel_size=3, stride=1, padding=0, bias=False),
            nn.BatchNorm2d(num_channel),
            nn.ReLU(inplace=True),
            nn.Conv2d(num_channel, 3, kernel_size=1,
                      stride=1, padding=0, bias=True))  # 3 dim

        self.rot = nn.Sequential(
            nn.Conv2d(num_channel, num_channel,
                      kernel_size=3, stride=1, padding=0, bias=False),
            nn.BatchNorm2d(num_channel),
            nn.ReLU(inplace=True),
            nn.Conv2d(num_channel, num_channel,
                      kernel_size=3, stride=1, padding=0, bias=False),
            nn.BatchNorm2d(num_channel),
            nn.ReLU(inplace=True),
            nn.Conv2d(num_channel, num_channel,
                      kernel_size=3, stride=1, padding=0, bias=False),
            nn.BatchNorm2d(num_channel),
            nn.ReLU(inplace=True),
            nn.Conv2d(num_channel, 8, kernel_size=1,
                      stride=1, padding=0, bias=True))  # 1 + 1 + 2

        self.dep = nn.Sequential(
            nn.Conv2d(num_channel, num_channel,
                      kernel_size=3, stride=1, padding=0, bias=False),
            nn.BatchNorm2d(num_channel),
            nn.ReLU(inplace=True),
            nn.Conv2d(num_channel, num_channel,
                      kernel_size=3, stride=1, padding=0, bias=False),
            nn.BatchNorm2d(num_channel),
            nn.ReLU(inplace=True),
            nn.Conv2d(num_channel, num_channel,
                      kernel_size=3, stride=1, padding=0, bias=False),
            nn.BatchNorm2d(num_channel),
            nn.ReLU(inplace=True),
            nn.Conv2d(num_channel, 1, kernel_size=1,
                      stride=1, padding=0, bias=True),
            nn.Sigmoid())

        self.cen = nn.Sequential(
            nn.Conv2d(num_channel, num_channel,
                      kernel_size=3, stride=1, padding=0, bias=False),
            nn.BatchNorm2d(num_channel),
            nn.ReLU(inplace=True),
            nn.Conv2d(num_channel, num_channel,
                      kernel_size=3, stride=1, padding=0, bias=False),
            nn.BatchNorm2d(num_channel),
            nn.ReLU(inplace=True),
            nn.Conv2d(num_channel, num_channel,
                      kernel_size=3, stride=1, padding=0, bias=False),
            nn.BatchNorm2d(num_channel),
            nn.ReLU(inplace=True),
            nn.Conv2d(num_channel, 2, kernel_size=1,
                      stride=1, padding=0, bias=True))

        nu.init_module(self.base)
        nu.init_module(self.dim)
        nu.init_module(self.rot)
        nu.init_module(self.dep)
        nu.init_module(self.cen)