mmagic.models.editors.pix2pix.pix2pix
¶
Module Contents¶
Classes¶
Pix2Pix model for paired image-to-image translation. |
- class mmagic.models.editors.pix2pix.pix2pix.Pix2Pix(*args, **kwargs)[源代码]¶
Bases:
mmagic.models.base_models.BaseTranslationModel
Pix2Pix model for paired image-to-image translation.
- Ref:
Image-to-Image Translation with Conditional 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)[源代码]¶
Get the loss of discriminator.
- 参数
outputs (dict) – A dict of output.
- 返回
Loss and a dict of log of loss terms.
- 返回类型
Tuple
- _get_gen_loss(outputs)[源代码]¶
Get the loss of generator.
- 参数
outputs (dict) – A dict of output.
- 返回
Loss and a dict of log of loss terms.
- 返回类型
Tuple
- train_step(data, optim_wrapper=None)[源代码]¶
Training step function.
- 参数
data_batch (dict) – Dict of the input data batch.
optimizer (dict[torch.optim.Optimizer]) – Dict of optimizers for the generator and discriminator.
ddp_reducer (
Reducer
| None, optional) – Reducer from ddp. It is used to prepare forbackward()
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.
- 返回
Generated image or image dict.
- 返回类型
List[DataSample]
- 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.
- 返回
Generated image or image dict.
- 返回类型
List[DataSample]