mmedit.engine.runner
¶
Package Contents¶
Classes¶
Validation loop for generative models. This class support evaluate |
|
Validation loop for generative models. This class support evaluate |
|
GenLogProcessor inherits from |
|
Loop for validation multi-datasets. |
|
Loop for validation multi-datasets. |
- class mmedit.engine.runner.GenTestLoop(runner: mmengine.runner.Runner, dataloader: Union[torch.utils.data.DataLoader, Dict], evaluator: Union[mmengine.evaluator.Evaluator, Dict, List])[source]¶
Bases:
mmengine.runner.TestLoop
Validation loop for generative models. This class support evaluate metrics with different sample mode.
- Parameters
runner (Runner) – A reference of runner.
dataloader (Dataloader or dict) – A dataloader object or a dict to build a dataloader.
evaluator (Evaluator or dict or list) – Used for computing metrics.
- run()[source]¶
Launch validation. The evaluation process consists of four steps.
Prepare pre-calculated items for all metrics by calling
self.evaluator.prepare_metrics()
.Get a list of metrics-sampler pair. Each pair contains a list of metrics with the same sampler mode and a shared sampler.
Generate images for the each metrics group. Loop for elements in each sampler and feed to the model as input by calling
self.run_iter()
.Evaluate all metrics by calling
self.evaluator.evaluate()
.
- run_iter(idx, data_batch: dict, metrics: Sequence[mmengine.evaluator.BaseMetric])[source]¶
Iterate one mini-batch and feed the output to corresponding metrics.
- Parameters
idx (int) – Current idx for the input data.
data_batch (dict) – Batch of data from dataloader.
metrics (Sequence[BaseMetric]) – Specific metrics to evaluate.
- class mmedit.engine.runner.GenValLoop(runner: mmengine.runner.Runner, dataloader: Union[torch.utils.data.DataLoader, Dict], evaluator: Union[mmengine.evaluator.Evaluator, Dict, List])[source]¶
Bases:
mmengine.runner.ValLoop
Validation loop for generative models. This class support evaluate metrics with different sample mode.
- Parameters
runner (Runner) – A reference of runner.
dataloader (Dataloader or dict) – A dataloader object or a dict to build a dataloader.
evaluator (Evaluator or dict or list) – Used for computing metrics.
- run()[source]¶
Launch validation. The evaluation process consists of four steps.
Prepare pre-calculated items for all metrics by calling
self.evaluator.prepare_metrics()
.Get a list of metrics-sampler pair. Each pair contains a list of metrics with the same sampler mode and a shared sampler.
Generate images for the each metrics group. Loop for elements in each sampler and feed to the model as input by calling
self.run_iter()
.Evaluate all metrics by calling
self.evaluator.evaluate()
.
- run_iter(idx, data_batch: dict, metrics: Sequence[mmengine.evaluator.BaseMetric])[source]¶
Iterate one mini-batch and feed the output to corresponding metrics.
- Parameters
idx (int) – Current idx for the input data.
data_batch (dict) – Batch of data from dataloader.
metrics (Sequence[BaseMetric]) – Specific metrics to evaluate.
- class mmedit.engine.runner.GenLogProcessor(window_size=10, by_epoch=True, custom_cfg: Optional[List[dict]] = None, num_digits: int = 4)[source]¶
Bases:
mmengine.runner.LogProcessor
GenLogProcessor inherits from
mmengine.runner.LogProcessor
and overwritesself.get_log_after_iter()
.This log processor should be used along with
mmedit.engine.runner.GenValLoop
andmmedit.engine.runner.GenTestLoop
.- get_log_after_iter(runner, batch_idx: int, mode: str) Tuple[dict, str] [source]¶
Format log string after training, validation or testing epoch.
If mode is in ‘val’ or ‘test’, we use runner.val_loop.total_length and runner.test_loop.total_length as the total number of iterations shown in log. If you want to know how total_length is calculated, please refers to
mmedit.engine.runner.GenValLoop.run()
andmmedit.engine.runner.GenTestLoop.run()
.- Parameters
runner (Runner) – The runner of training phase.
batch_idx (int) – The index of the current batch in the current loop.
mode (str) – Current mode of runner, train, test or val.
- Returns
- Formatted log dict/string which will be
recorded by
runner.message_hub
andrunner.visualizer
.
- Return type
Tuple(dict, str)
- get_log_after_epoch(runner, batch_idx: int, mode: str) Tuple[dict, str] [source]¶
Format log string after validation or testing epoch.
We use runner.val_loop.total_length and runner.test_loop.total_length as the total number of iterations shown in log. If you want to know how total_length is calculated, please refers to
mmedit.engine.runner.GenValLoop.run()
andmmedit.engine.runner.GenTestLoop.run()
.- Parameters
runner (Runner) – The runner of validation/testing phase.
batch_idx (int) – The index of the current batch in the current loop.
mode (str) – Current mode of runner.
- Returns
Formatted log dict/string which will be recorded by
runner.message_hub
andrunner.visualizer
.- Return type
Tuple(dict, str)
- class mmedit.engine.runner.MultiTestLoop(runner, dataloader: Union[torch.utils.data.DataLoader, Dict], evaluator: Union[mmengine.evaluator.Evaluator, Dict, List], fp16: bool = False)[source]¶
Bases:
mmengine.runner.base_loop.BaseLoop
Loop for validation multi-datasets.
- Parameters
runner (Runner) – A reference of runner.
dataloader (Dataloader or dict) – A dataloader object or a dict to build a dataloader.
evaluator (Evaluator or dict or list) – Used for computing metrics.
fp16 (bool) – Whether to enable fp16 validation. Defaults to False.
- class mmedit.engine.runner.MultiValLoop(runner, dataloader: Union[torch.utils.data.DataLoader, Dict], evaluator: Union[mmengine.evaluator.Evaluator, Dict, List], fp16: bool = False)[source]¶
Bases:
mmengine.runner.base_loop.BaseLoop
Loop for validation multi-datasets.
- Parameters
runner (Runner) – A reference of runner.
dataloader (list[Dataloader or dic]) – A dataloader object or a dict to build a dataloader.
evaluator (list[]) – Used for computing metrics.
fp16 (bool) – Whether to enable fp16 validation. Defaults to False.