Shortcuts

mmagic.engine.hooks.pickle_data_hook

Module Contents

Classes

PickleDataHook

Pickle Useful Data Hook.

Attributes

DATA_BATCH

mmagic.engine.hooks.pickle_data_hook.DATA_BATCH[source]
class mmagic.engine.hooks.pickle_data_hook.PickleDataHook(output_dir, data_name_list, interval=- 1, before_run=False, after_run=False, filename_tmpl='iter_{}.pkl')[source]

Bases: mmengine.hooks.Hook

Pickle Useful Data Hook.

This hook will be used in SinGAN training for saving some important data that will be used in testing or inference.

Parameters
  • output_dir (str) – The output path for saving pickled data.

  • data_name_list (list[str]) – The list contains the name of results in outputs dict.

  • interval (int) – The interval of calling this hook. If set to -1, the PickleDataHook will not be called during training. Default: -1.

  • before_run (bool, optional) – Whether to save before running. Defaults to False.

  • after_run (bool, optional) – Whether to save after running. Defaults to False.

  • filename_tmpl (str, optional) – Format string used to save images. The output file name will be formatted as this args. Defaults to ‘iter_{}.pkl’.

after_run(runner)[source]

The behavior after each train iteration.

Parameters

runner (object) – The runner.

before_run(runner)[source]

The behavior after each train iteration.

Parameters

runner (object) – The runner.

after_train_iter(runner, batch_idx: int, data_batch: DATA_BATCH = None, outputs: Optional[dict] = None)[source]

The behavior after each train iteration.

Parameters
  • runner (Runner) – The runner of the training process.

  • batch_idx (int) – The index of the current batch in the train loop.

  • data_batch (Sequence[dict], optional) – Data from dataloader. Defaults to None.

  • outputs (dict, optional) – Outputs from model. Defaults to None.

_pickle_data(runner: mmengine.runner.Runner)[source]

Save target data to pickle file.

Parameters

runner (Runner) – The runner of the training process.

_get_numpy_data(data: Tuple[List[torch.Tensor], torch.Tensor, int]) Tuple[List[numpy.ndarray], numpy.ndarray, int][source]

Convert tensor or list of tensor to numpy or list of numpy.

Parameters

data (Tuple[List[Tensor], Tensor, int]) – Data to be converted.

Returns

Converted data.

Return type

Tuple[List[np.ndarray], np.ndarray, int]

Read the Docs v: latest
Versions
latest
stable
0.x
Downloads
pdf
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.