Ejemplo n.º 1
0
    def forward(self, x, label):
        x = self.truck(x)
        # your code here
        batchsize = x.size(0)

        #-- Head architecture
        self.head_s2 = nn.Sequential(
            nn.Linear(4096, 84),
            nn.ReLU(inplace=True),
            #nn.Dropout(),
            nn.Linear(84, self.nr_cate * 3),  # 252=3*3
        )
        self.head_s1 = nn.Sequential(
            nn.Linear(4096, 84),
            nn.ReLU(inplace=True),
            #nn.Dropout(),
            nn.Linear(84, self.nr_cate * 2),
        )
        # self.maskout = Maskout(nr_cate=nr_cate)

        # Note: s1(x,y) is on a circle and (x^2+y^2=1)
        x_s2 = self.maskout(
            self.head_s2(x).view(batchsize, self.nr_cate, 3), label)
        x_s1 = self.maskout(
            self.head_s1(x).view(batchsize, self.nr_cate, 2), label)
        #-- Normalize coordinate to a unit
        x_s2 = norm2unit(x_s2)  #, nr_cate=self.nr_cate)
        x_s1 = norm2unit(x_s1)  #, nr_cate=self.nr_cate)

        Pred = edict(s2=x_s2, s1=x_s1)
        return Pred
Ejemplo n.º 2
0
    def forward(self, x, label):
        # forward truck
        x = self.truck(x)
        # your code here
        batchsize = x.size(0)
        x = x.view(batchsize, -1)  # viewed as (batchsize, 2048)

        # Note: s1(x,y) is on a circle and (x^2+y^2=1)
        x_s2 = self.maskout(
            self.head_s2(x).view(batchsize, self.nr_cate, 3), label)
        x_s1 = self.maskout(
            self.head_s1(x).view(batchsize, self.nr_cate, 2), label)
        #-- Normalize coordinate to a unit
        x_s2 = norm2unit(x_s2)  #, nr_cate=self.nr_cate)
        x_s1 = norm2unit(x_s1)  #, nr_cate=self.nr_cate)

        Pred = edict(s2=x_s2, s1=x_s1)
        return Pred
Ejemplo n.º 3
0
 def compute_pred(Prob):
     x_quat = Prob['quat']
     #-- Normalize coordinate to a unit
     x_quat = norm2unit(
         x_quat
     )  # Note: here we do l2 normalization. Just to make predicted quaternion a unit norm.
     #
     batchsize = x_quat.size(0)
     # Get cpu data.
     batch_data = x_quat.data.cpu().numpy().copy()
     assert batch_data.shape == (batchsize, 4), batch_data.shape
     Pred = edict(quat=batch_data)
     return Pred
Ejemplo n.º 4
0
    def forward(self, x):
        """label shape (batchsize, )  """
        x = self.trunk(x)  # Forward Conv and Fc6,Fc7
        #
        batchsize = x.size(0)  # x of shape (40, 3, 240, 320)

        #-- Normalize coordinate to a unit
        x_norm = norm2unit(x, dim=1)

        Prob = edict(norm=x_norm.permute(
            0, 2, 3,
            1).double())  # transpose prediction from BxCxHxW to BxHxWxC order.
        return Prob
Ejemplo n.º 5
0
    def forward(self, x, label):
        """label shape (batchsize, )  """
        x = self.trunk(x)
        #
        batchsize = x.size(0)

        # Note: quat(a,b,c,d) is on a 4d sphere and (x^2+y^2=1)
        x_quat = self.maskout(
            self.head_quat(x).view(batchsize, self.nr_cate, self.reg_n_D),
            label)
        #-- Normalize coordinate to a unit
        x_quat = norm2unit(x_quat)  #, nr_cate=self.nr_cate)

        Prob = edict(quat=x_quat)
        return Prob