basicsr.models.hifacegan_model

class basicsr.models.hifacegan_model.HiFaceGANModel(opt)[source]

Bases: SRModel

HiFaceGAN model for generic-purpose face restoration. No prior modeling required, works for any degradations. Currently doesn’t support EMA for inference.

discriminate(input_lq, output, ground_truth)[source]

This is a conditional (on the input) discriminator In Batch Normalization, the fake and real images are recommended to be in the same batch to avoid disparate statistics in fake and real images. So both fake and real images are fed to D all at once.

init_training_settings()[source]
nondist_validation(dataloader, current_iter, tb_logger, save_img)[source]

TODO: Validation using updated metric system The metrics are now evaluated after all images have been tested This allows batch processing, and also allows evaluation of distributional metrics, such as:

@ Frechet Inception Distance: FID @ Maximum Mean Discrepancy: MMD

Warning

Need careful batch management for different inference settings.

optimize_parameters(current_iter)[source]
save(epoch, current_iter)[source]

Save networks and training state.

setup_optimizers()[source]
validation(dataloader, current_iter, tb_logger, save_img=False)[source]

Warning: HiFaceGAN requires train() mode even for validation For more info, see https://github.com/Lotayou/Face-Renovation/issues/31

Parameters:
  • dataloader (torch.utils.data.DataLoader) – Validation dataloader.

  • current_iter (int) – Current iteration.

  • tb_logger (tensorboard logger) – Tensorboard logger.

  • save_img (bool) – Whether to save images. Default: False.