Cysu / open-reid

Open source person re-identification library in python
https://cysu.github.io/open-reid/
MIT License
1.34k stars 349 forks source link

Fail to reproduce triplet loss benchmark on Market1501 #15

Closed huanghoujing closed 7 years ago

huanghoujing commented 7 years ago

Hi, Tong Xiao, very grateful for your complete and self-contained ReID library. I have a small question to consult you about. I failed to reproduce the performance using triplet loss on Market1501.

I think my script is effectively the same as provided in your github.io page:

CUDA_VISIBLE_DEVICES=0,1,2,3 python examples/triplet_loss.py -d market1501 -a resnet50 --combine-trainval --logs-dir examples/logs/triplet-loss/market1501-resnet50-4gpu-batch-size-256 -b 256 --print-freq 20

The performance it achieved is quite worse than reported on your github.io page:

Mean AP: 60.3%
CMC Scores    allshots      cuhk03  market1501
  top-1          34.8%       63.1%       80.4%
  top-5          51.4%       87.4%       92.1%
  top-10         59.7%       92.7%       95.1%

Do you have anything not updated on the github.io page? Waiting for your kind response and thank you very much.

Anyone else who has run this code and notices this issue is also highly appreciated to share your results.

huanghoujing commented 7 years ago

After checking the paper In Defense of the Triplet Loss for Person Re-Identification, I found a typo in your script examples/triplet_loss.py and fixed it, and then things went very well.

In the adjust_lr function, I changed line

lr = args.lr if epoch <= 100 else args.lr * (0.001 ** ((epoch - 100) / 50))

into

lr = args.lr if epoch <= 100 else args.lr * (0.001 ** ((epoch - 100) / 50.))

(I changed 50 to 50.) which allows the learning rate to decay gradually after 100 epochs.

Finally, I got the following promising results as in your github doc:

Mean AP: 67.5%
CMC Scores    allshots      cuhk03  market1501
  top-1          42.8%       70.0%       84.5%
  top-5          59.2%       91.1%       94.1%
  top-10         67.2%       95.0%       96.5%

This issue is solved, thank you again for your wonderful library.

Cysu commented 7 years ago

@huanghoujing Thank you very much for the finding! It seems that python3 treats / as floating numbers division, while python2 does not. I will fix this soon.

huanghoujing commented 7 years ago

OK, now I got it :)