Shortcuts

mmagic.models.editors.cyclegan.cyclegan

Module Contents

Classes

CycleGAN

CycleGAN model for unpaired image-to-image translation.

class mmagic.models.editors.cyclegan.cyclegan.CycleGAN(*args, buffer_size=50, loss_config=dict(cycle_loss_weight=10.0, id_loss_weight=0.5), **kwargs)[源代码]

Bases: mmagic.models.base_models.BaseTranslationModel

CycleGAN model for unpaired image-to-image translation.

Ref: Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks

forward_test(img, target_domain, **kwargs)[源代码]

Forward function for testing.

参数
  • img (tensor) – Input image tensor.

  • target_domain (str) – Target domain of output image.

  • kwargs (dict) – Other arguments.

返回

Forward results.

返回类型

dict

_get_disc_loss(outputs)[源代码]

Backward function for the discriminators.

参数

outputs (dict) – Dict of forward results.

返回

Discriminators’ loss and loss dict.

返回类型

dict

_get_gen_loss(outputs)[源代码]

Backward function for the generators.

参数

outputs (dict) – Dict of forward results.

返回

Generators’ loss and loss dict.

返回类型

dict

_get_opposite_domain(domain)[源代码]

Get the opposite domain respect to the input domain.

参数

domain (str) – The input domain.

返回

The opposite domain.

返回类型

str

train_step(data: dict, optim_wrapper: mmengine.optim.OptimWrapperDict)[源代码]

Training step function.

参数
  • data_batch (dict) – Dict of the input data batch.

  • optimizer (dict[torch.optim.Optimizer]) – Dict of optimizers for the generators and discriminators.

  • ddp_reducer (Reducer | None, optional) – Reducer from ddp. It is used to prepare for backward() in ddp. Defaults to None.

  • running_status (dict | None, optional) – Contains necessary basic information for training, e.g., iteration number. Defaults to None.

返回

Dict of loss, information for logger, the number of samples and results for visualization.

返回类型

dict

test_step(data: dict) mmagic.utils.typing.SampleList[源代码]

Gets the generated image of given data. Same as val_step().

参数

data (dict) – Data sampled from metric specific sampler. More details in Metrics and Evaluator.

返回

A list of DataSample contain generated results.

返回类型

SampleList

val_step(data: dict) mmagic.utils.typing.SampleList[源代码]

Gets the generated image of given data. Same as val_step().

参数

data (dict) – Data sampled from metric specific sampler. More details in Metrics and Evaluator.

返回

A list of DataSample contain generated results.

返回类型

SampleList

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.