This repository is based on previous works from Part_ReID.
Please refer to In Defense of the Triplet Loss for Person Re-Identification and Deeply-Learned Part-Aligned Representations for Person Re-Identification for more details.
cd online_triplet_loss
sh ./mask.sh
from online_triplet_loss.online_triplet_loss import OnlineTripletLoss as LossFunction
triplet_loss_fun = LossFunction(all_triplets=False,
positive_type=LossFunction.SampleMethod_ALL,
negative_type=LossFunction.SampleMethod_ALL,
margin_type=LossFunction.MarginType_SOFTMARGIN,
margin=0.3, mu=1.)
loss = triplet_loss_fun(features, labels)
accuracy = triplet_loss_fun.accuracy
- SampleMethod_ALL
- SampleMethod_HARD
- SampleMethod_MODERATE
- hard margin
- soft margin
- This parameter is adopted for keep a balance between the intra-class loss for postive pairs and the triplet distance.
- mu=1. is highly recommend, which means that we ignore the intra-class loss.