artus.train packageο
Submodulesο
artus.train.build_trainer moduleο
Build a to train deep learning model.
- class artus.train.build_trainer.MyTrainer(cfg)ο
Bases:
DefaultTrainerA custom trainer that performs validation loop.
- classmethod build_evaluator(cfg, dataset_name, output_folder=None)ο
_summary_
- Parameters:
cfg (CfgNode) β config file in detectron2 format
dataset_name (str) β name of the dataset
output_folder (str, optional) β Path to the directory where results of training and evaluation will be saved. Defaults to None.
- Returns:
an evaluator for coco dataset.
- Return type:
detectron2.evaluation.COCOEvaluator
- build_hooks()ο
Build a hook to make validation on the validation dataset.
- Returns:
validation metrics
- Return type:
hooks
- classmethod build_test_loader(cfg: CfgNode, dataset_name)ο
Build a test dataloader.
- Parameters:
cfg (CfgNode) β config file in detectron2 format
dataset_name (str) β the name of the dataset
- Returns:
A test dataloader.
- Return type:
torch.utils.data.DataLoader
- classmethod build_train_loader(cfg)ο
Build a train dataloader.
- Parameters:
cfg (CfgNode) β config file in detectron2 format
- Returns:
A train dataloader.
- Return type:
torch.utils.data.DataLoader
artus.train.config moduleο
A module to handle a config file in yaml format and build a CfgNode.
An example of the config file expected can be found in artusβs tutorials at https://github.com/6tronl/artus-examples/blob/main/configs/x101_allsites_species_overlapping25_tiles5000_ITER3000.yml
- artus.train.config.add_config(cfg, config_path, device, train_dataset, test_dataset, output_dir=None, mode=['train', 'inference'])ο
Add config for DL model coming from a yaml config file.
- Parameters:
cfg (CfgNode) β a config file in detectron2 format
config_path (str) β the path to a config file following the format provided in the tutorials.
device (str) β βcpuβ or βcudaβ. Results of βcudaβ if torch.cuda.is_available() else βcpuβ
train_dataset (str) β name of the registered dataset for training
test_dataset (str) β name of the registered dataset for validation
output_dir (str, optional) β the path to the output directory. Defaults to None.
mode (list, optional) β Whether this config will be added in a training or inference use case. Defaults to [βtrainβ, βinferenceβ].
- Returns:
a custom config file for training a deep learning model
- Return type:
CfgNode
- artus.train.config.read_config(config_path)ο
Read a yaml file used to config a model for training or inference.
- Parameters:
config_path (str) β the path to a config file in yaml format
- Returns:
A python object
artus.train.data_augmentation moduleο
A module to perform data augmentation during the training and/or inference process
- artus.train.data_augmentation.custom_mapper(dataset_dict)ο
A custom mapper to make data augmentation with the images
Custom mapper performs resizing, flipping, color editor to artificially augment data.
- Parameters:
dataset_dict (dict) β a dict mapping the images along with their labels.
- Returns:
a dict mapping the augmentated images along with their labels
- Return type:
dict
artus.train.train moduleο
A module to train a deep learning model with a config file in the yaml format.
- artus.train.train.add_logs_path_to_config(config_path, checkpoint_path_dict)ο
Add logs paths to the config file to keep track of trained models. :param config_path: the path to a config file (yaml) :type config_path: str :param checkpoint_path_dict: a dict including the βCHECKPOINTβ (the path to the checkpoint saved) :type checkpoint_path_dict: dict
- Returns:
The same config file with the path to the final checkpoint added.
- artus.train.train.train_model(config_path)ο
A function that trains a deep learning model with detectron2.
Support multiple deep learning tasks : object detection and instance segmentation.
- Parameters:
config_path β the path to a config file (yaml)
Returns: A folder within the logs directory with the checkpoint (.pth) of the model and events file for visualization of the training and validation metrics with tensorboard. A subdirectory is also created with the inference resultst of the validation step.
artus.train.validation_hook moduleο
A detectron2 hook system to make validation during the training process.