Exemplo n.º 1
0
    def init_directories(self):
        """
    Creates the 'im_seg' directory in the data_path. Also creates the train/val/test/out
    directories with the images/ and annotations/ directory for each.
    If the directories already exist, then initialises the data_sizes based on existing 
    directories.
    """
        Dataset._create_dirs(
            self.im_seg_path,
            self.train_path,
            self.val_path,
            self.test_path,
        )
        # Create train, val, test dirs, each with an images and annotations sub-directories
        dirs = {
            "train": self.train_path,
            "val": self.val_path,
            "test": self.test_path
        }
        for set_type, directory in dirs.items():
            Dataset._create_dirs(os.path.join(directory, 'images'),
                                 os.path.join(directory, 'annotations'))

            # Size of each training, val and test directories
            num_samples = len([name for name in os.listdir(os.path.join(directory, 'images'))\
                               if name.endswith('.jpg')])
            self.data_sizes[set_type] = num_samples
Exemplo n.º 2
0
    def create_model_out_dir(self, model_name):
        """
    Creates directories for metrics, ouput images and annotations for a
    given model during training.
    """
        try:
            getattr(self, "model_path")
            raise AttributeError("Attribute model_path already created")
        except AttributeError as e:
            pass

        self.model_path = os.path.join(self.out_path, model_name)
        self.checkpoint_path = os.path.join(self.model_path, 'checkpoints')
        self.metrics_path = os.path.join(self.model_path, 'metrics')
        self.preds_path = os.path.join(self.model_path, 'preds')

        Dataset._create_dirs(self.out_path, self.model_path,
                             self.checkpoint_path, self.metrics_path,
                             self.preds_path)
Exemplo n.º 3
0
 def __init__(self, data_path, classes_path='classes.json'):
     super().__init__(data_path, classes_path=classes_path)
     self.meta_path = os.path.join(self.data_path, 'metadata')
     Dataset._create_dirs(self.meta_path)