Shortcuts

mmedit.engine.runner

Package Contents

Classes

GenTestLoop

Validation loop for generative models. This class support evaluate

GenValLoop

Validation loop for generative models. This class support evaluate

GenLogProcessor

GenLogProcessor inherits from mmengine.runner.LogProcessor and

MultiTestLoop

Loop for validation multi-datasets.

MultiValLoop

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])[源代码]

Bases: mmengine.runner.TestLoop

Validation loop for generative models. This class support evaluate metrics with different sample mode.

参数
  • 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()

Launch validation. The evaluation process consists of four steps.

  1. Prepare pre-calculated items for all metrics by calling self.evaluator.prepare_metrics().

  2. Get a list of metrics-sampler pair. Each pair contains a list of metrics with the same sampler mode and a shared sampler.

  3. 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().

  4. Evaluate all metrics by calling self.evaluator.evaluate().

run_iter(idx, data_batch: dict, metrics: Sequence[mmengine.evaluator.BaseMetric])

Iterate one mini-batch and feed the output to corresponding metrics.

参数
  • 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])[源代码]

Bases: mmengine.runner.ValLoop

Validation loop for generative models. This class support evaluate metrics with different sample mode.

参数
  • 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()

Launch validation. The evaluation process consists of four steps.

  1. Prepare pre-calculated items for all metrics by calling self.evaluator.prepare_metrics().

  2. Get a list of metrics-sampler pair. Each pair contains a list of metrics with the same sampler mode and a shared sampler.

  3. 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().

  4. Evaluate all metrics by calling self.evaluator.evaluate().

run_iter(idx, data_batch: dict, metrics: Sequence[mmengine.evaluator.BaseMetric])

Iterate one mini-batch and feed the output to corresponding metrics.

参数
  • 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)[源代码]

Bases: mmengine.runner.LogProcessor

GenLogProcessor inherits from mmengine.runner.LogProcessor and overwrites self.get_log_after_iter().

This log processor should be used along with mmedit.engine.runner.GenValLoop and mmedit.engine.runner.GenTestLoop.

get_log_after_iter(runner, batch_idx: int, mode: str) Tuple[dict, str]

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() and mmedit.engine.runner.GenTestLoop.run().

参数
  • 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.

返回

Formatted log dict/string which will be

recorded by runner.message_hub and runner.visualizer.

返回类型

Tuple(dict, str)

get_log_after_epoch(runner, batch_idx: int, mode: str) Tuple[dict, str]

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() and mmedit.engine.runner.GenTestLoop.run().

参数
  • 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.

返回

Formatted log dict/string which will be recorded by runner.message_hub and runner.visualizer.

返回类型

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)[源代码]

Bases: mmengine.runner.base_loop.BaseLoop

Loop for validation multi-datasets.

参数
  • 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.

run()

Launch test.

run_iter(idx: int, data_batch: Sequence[dict])

Iterate one mini-batch.

参数
  • idx (int) – The index of the current batch in the loop.

  • data_batch (Sequence[dict]) – Batch of data from dataloader.

class mmedit.engine.runner.MultiValLoop(runner, dataloader: Union[torch.utils.data.DataLoader, Dict], evaluator: Union[mmengine.evaluator.Evaluator, Dict, List], fp16: bool = False)[源代码]

Bases: mmengine.runner.base_loop.BaseLoop

Loop for validation multi-datasets.

参数
  • 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.

run()

Launch validation.

run_iter(idx: int, data_batch: Sequence[dict])

Iterate one mini-batch.

参数
  • idx (int) – The index of the current batch in the loop.

  • data_batch (Sequence[dict]) – Batch of data from dataloader.

Read the Docs v: latest
Versions
master
latest
stable
zyh-doc-notfound-extend
Downloads
pdf
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.