VIS-VAR / LGSC-for-FAS

Learning Generalized Spoof Cues for FaceAnti-spoofing
MIT License
225 stars 56 forks source link

TripletLoss #21

Open neverUseThisName opened 4 years ago

neverUseThisName commented 4 years ago

Hi, I have a hard time understanding code snippet in TripletLoss.py. What is the purpose of 'target = 1 - target[:, 0]'? Thanks.

ZGSLZL commented 4 years ago

Hi,thanks for your question. It should be noted that 'TripletLoss' here is asymmetric. The anchors only contains positive samples. After adding 'target = 1-target[:, 0]', 0 and 1 represent positive(real) and negative(fake) samples, respectively.

silvercherry commented 4 years ago

Hi,thanks for your question. It should be noted that 'TripletLoss' here is asymmetric. The anchors only contains positive samples. After adding 'target = 1-target[:, 0]', 0 and 1 represent positive(real) and negative(fake) samples, respectively.

hello but I notice in faceforensics.py you have changed the label if int(item[1]) == 0: pos_infos.append(dict( img_path=item[0], label=1 - int(item[1]))) else: neg_infos.append(dict( img_path=item[0], label=1 - int(item[1]))) if you use 'target = 1 - target[:, 0]' ,it will not use?

ZGSLZL commented 4 years ago

Hi, @silvercherry , sorry to confuse you, only when calculating the triplet loss, 0 represent positive(real).

silvercherry commented 4 years ago

Hi, @silvercherry , sorry to confuse you, only when calculating the triplet loss, 0 represent positive(real).

that means the real face groud truth is 1,when calculating the triplet loss it will be 0?