qinglew / PCN-PyTorch

Implementation of PCN(Point Completion Network) in PyTorch.
141 stars 33 forks source link

Ground Truth PC messes up after epoch 1 #19

Closed MarioCavero closed 2 years ago

MarioCavero commented 2 years ago

I modified _load_data(self) in order to load my data. At the moment I have a small dataset to test the learning, 280 per object in train, 120 in test, partial and completes). Names of the files just go from 0 to 279 in train (0.pcd, 1.pcd, etc), and 280 to 399 (280.pcd, 281.pcd, etc). I'm not using right now model_id from line.split.

def _load_data(self):
        print('loading data')
        with open(os.path.join(self.dataroot, '{}.list').format(self.split), 'r') as f:
            lines = f.read().splitlines()
        if self.category != 'all':
            lines = list(filter(lambda x: x.startswith(self.cat2id2[self.category]), lines))

        partial_paths, complete_paths = list(), list()
        train_counter = 0
        test_counter = 280 # change to do clean up. Right now it's done so as to fit the names of the test partials
        for line in lines:
            print(line)
            category, model_id = line.split('/')
            if self.split == 'train':
                for i in range(280):
                    partial_paths.append(os.path.join(self.dataroot, self.split, 'partial', category,str(train_counter%280)+'.pcd'))
                    complete_paths.append(os.path.join(self.dataroot, self.split, 'complete', category, str(train_counter%280)+'.pcd'))
                    train_counter+=1

            else:
                for i in range(120):
                    partial_paths.append(os.path.join(self.dataroot, self.split, 'partial', category, str(test_counter)+'.pcd'))
                    complete_paths.append(os.path.join(self.dataroot, self.split, 'complete', category, str(test_counter)+'.pcd'))
                    test_counter+=1
                    if(test_counter == 400): # lazy module, clean up after it's working
                        test_counter = 280

On the first epoch, everything runs smoothly. But after the first epoch, the loss goes up, and looking in the log, the ground truth point cloud is for some reason, just a point, regardless of the one I am loading. (Yes, I checked them, they are good pointclouds). [First picture, epoch 1, second, epoch 2, of a run I made]. epoch_001 epoch_002

My guess is that it has something to do with either _load_data or with __getitem__, but trying to get my head around it, the loading of the data seems correct. Maybe a modification in __getitem__needs to be done for my specific type of data. I did a test on just loading the same complete PC per object, and it happens the same, first epoch is okay, after the first one, the Ground Truth get's interpreted by a point.

MarioCavero commented 2 years ago

After changing the complete PC (.pcd) to a (.ply), it works fine. For some reason, partial PCs are okay to be (.pcd) but the network messes up with (.pcd) complete PCs.

(Images of first, second and third epoch with shuffled dataset).

epoch_001 epoch_002 epoch_003 .