ParticleDetection.modelling.detectron

Collection of custom Detectron2 objects to provide a customized training process with more sophisticated outputs.

Author: Adrian Niemann (adrian.niemann@ovgu.de)

Date: 31.10.2022

class CompleteMapper(*args: Any, **kwargs: Any)[source]

Bases: DatasetMapper

Provides annotation data in training and testing context.

__call__(dataset_dict)[source]
Args:

dataset_dict (dict): Metadata of one image, in Detectron2 dataset format.

Returns:

dict: a format that builtin models in detectron2 accept

class CustomTensorboardWriter(*args: Any, **kwargs: Any)[source]

Bases: EventWriter

Write all scalars to a tensorboard file.

close()[source]
write()[source]
class CustomTrainer(*args: Any, **kwargs: Any)[source]

Bases: DefaultTrainer

augmentations: List[detectron2.data.transforms.Augmentation] = []
classmethod build_evaluator(cfg: detectron2.config.config.CfgNode, dataset_name: str)[source]

Build a custom evaluator depending on the detection task.

Parameters
  • cfg (CfgNode) –

    Detectron2 network configuration with allowed TASK field of:

    "None" -> will be changed to "segm"

    "segm" -> results in an evaluator for a segmentation task

    "keypoints" -> results in an evaluator for a keypoint detection task

  • dataset_name (str) – Name of a dataset that is registered in the Detectron2 framework, that is used as the test dataset of the constructed evaluator.

Returns

DatasetEvaluators

build_hooks()[source]

Build a list of hooks, including the DefaultTrainer default hooks and a custom loss hook used during evaluation.

classmethod build_train_loader(cfg)[source]

Custom loader for training data.

Parameters

cfg (CfgNode) – Detectron2 network configuration.

Returns

Iterable

build_writers()[source]

Builds additional/custom writers for use during training.

class EvalLossHook(*args: Any, **kwargs: Any)[source]

Bases: HookBase

Hook to compute different losses in the training process of a network.

This is the copy of the loss hook used by Detectron2 for the training dataset. This hook is intended for evaluating the loss on the test dataset during the training process.

after_step()[source]