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 :class:~mmengine.logging.LogProcessor

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])[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()

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.

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

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.

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 :class:~mmengine.logging.LogProcessor and overwrites :meth:self.get_log_after_iter.

This log processor should be used along with :class:mmedit.engine.runners.loops.GenValLoop and :class:mmedit.engine.runners.loops.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 :meth:mmedit.engine.runners.loops.GenValLoop.run and :meth:mmedit.engien.runners.loops.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 and runner.visualizer.

Return type

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 :meth:mmgen.core.runners.loops.GenValLoop.run and :meth:mmgen.core.runners.loops.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 and runner.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.

run()

Launch test.

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

Iterate one mini-batch.

Parameters
  • 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)[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.

run()

Launch validation.

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

Iterate one mini-batch.

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

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

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

Free document hosting provided by Read the Docs.