mmagic.models.losses.face_id_loss
¶
Module Contents¶
Classes¶
Face similarity loss. Generally this loss is used to keep the id |
- class mmagic.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
andx
. Thus, an example of thedata_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’.