def get_correctness():
    model.eval()
    correct_count = 0
    total_count = 0

    print('Testing:')
    for val_batch in tqdm(val_loader):
        data = val_batch

        inputs = data.get('inputs')
        current_batch_size = inputs.shape[0]

        out = model(data, device)
        if input_type == 'depth_pointcloud':
            out = out[0]
        class_gt = data.get('category').to(device)
        class_predict = out.max(dim=1)[1]

        #print('gt:',class_gt)
        #print('pred:',class_predict)
        correct_count += (class_predict == class_gt).sum().item()
        total_count += current_batch_size

    print('correct_count:', correct_count)
    print('total_count:', total_count)
    return correct_count / total_count
Esempio n. 2
0
    def forward(self, data, device):
        gt_depth_maps = data.get('inputs.depth').to(device)
        gt_mask = data.get('inputs.mask').to(device).byte()
        background_setting(gt_depth_maps, gt_mask)
        encoder_inputs = gt_depth_maps

        if self.with_img:
            img = data.get('inputs').to(device)
            encoder_inputs = {'img': img, 'depth': encoder_inputs}

        out = self.features(encoder_inputs)
        out = self.pred_fc(out)
        return out
Esempio n. 3
0
    def get_loss(self, data, device):
        class_gt = data.get('category').to(device)

        out = self.forward(data, device)
        loss = self.loss_func(out, class_gt)
        return loss
Esempio n. 4
0
 def forward(self, data, device):
     inputs = data.get('inputs').to(device)
     out = self.features(inputs)
     out = self.fc(out)
     return out