Shortcuts

mmedit.models.losses.face_id_loss

Module Contents

Classes

FaceIdLoss

Face similarity loss. Generally this loss is used to keep the id

class mmedit.models.losses.face_id_loss.FaceIdLoss(loss_weight: float = 1.0, data_info: Optional[dict] = None, facenet: dict = dict(type='ArcFace', ir_se50_weights=None), loss_name: str = 'loss_id')[source]

Bases: torch.nn.Module

Face similarity loss. Generally this loss is used to keep the id consistency of the input face image and output face image.

In this loss, we may need to provide gt, pred and x. Thus, an example of the data_info is:

1data_info = dict(
2    gt='real_imgs',
3    pred='fake_imgs')

Then, the module will automatically construct this mapping from the input data dictionary.

Parameters
  • loss_weight (float, optional) – Weight of this loss item. Defaults to 1..

  • data_info (dict, optional) – Dictionary contains the mapping between loss input args and data dictionary. If None, this module will directly pass the input data to the loss function. Defaults to None.

  • facenet (dict, optional) – Config dict for facenet. Defaults to dict(type=’ArcFace’, ir_se50_weights=None, device=’cuda’).

  • loss_name (str, optional) – Name of the loss item. If you want this loss item to be included into the backward graph, loss_ must be the prefix of the name. Defaults to ‘loss_id’.

forward(pred: torch.Tensor, gt: torch.Tensor) torch.Tensor[source]

Forward function.

Read the Docs v: latest
Versions
master
latest
stable
zyh-re-docs
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.