KaiyangZhou / deep-person-reid

Torchreid: Deep learning person re-identification in PyTorch.
https://kaiyangzhou.github.io/deep-person-reid/
MIT License
4.3k stars 1.15k forks source link

Auxiliary loss #471

Open Thangbluee opened 3 years ago

Thangbluee commented 3 years ago

Many thanks to all the contributors for this project.

In your paper https://arxiv.org/pdf/1905.00953.pdf you use the cross-entropy loss as the main objective and the triplet loss as an auxiliary loss with a balancing weight (which needs to be tuned) to get the result showed in table 12e. How can I apply this auxiliary loss to train the model. Thanks!

buaa-luzhi commented 2 years ago

@Thangbluee I have the same question as you, triplet Loss is not used in the code. What parameters need to be adjusted if triplet Loss is used. Thanks!

LamnouarMohamed commented 2 years ago

@Thangbluee you can modify loss parameter in torchreid.models.build_model like this one "example" model = torchreid.models.build_model( name = 'osnet_x0_5', num_classes = datamanager.num_train_pids, loss = 'triplet', pretrained = True ) and also add engine relate this loss

engine = torchreid.engine.ImageTripletEngine( datamanager, model, optimizer, margin=0.3, weight_t=0.7, weight_x=1, scheduler=scheduler