Cysu / dgd_person_reid

Domain Guided Dropout for Person Re-identification
http://arxiv.org/abs/1604.07528
231 stars 94 forks source link

Input single image as test probe for testing & id similarity #25

Closed ChungPin closed 7 years ago

ChungPin commented 7 years ago

Hi, I'm doing some research on person re-identification, and I'm now trying to input only one image as test probe using dgd_person_reid. Take PRID_2011 dataset as example, the code /data/format_prid.py will randomly choose 100 people as test probe, so if I change it to randomly choose 1 person, it will input all the images of that person's tracklet. So I'm guessing if I only want to input single image as test probe, I will probably need to do lots of changing on your code, but I don't really know where to start... Could you give me some suggestions?

And I'm think that if I want to know the top-5 or top-10 ids that are the most similar to the test probe, sorting the distance produce by D = pairwise_distances(GX, PX, metric='mahalanobis', VI=M, n_jobs=-2) is the only way to get the similarity, the shortest distance will be the most similar to the test probe, so I'll need to sort 5 or 10 smallest distances with its id to get my answer, am I correct?

Sorry for disturbing you, I'm looking forward to your reply! Thank you very much!

Cysu commented 7 years ago

I'm not sure why you need to use only one image as probe for evaluation. But if you wish to visualize the results, the most convenient way would be writing a new ipython notebook. You may specify the image you want, loading the trained model, and compute pairwise distances.

If you wish to get top-5 predictions, you may just

indices = np.argsort(D, axis=0)

then indices[i, j] would be the index of the top-i gallery sample for probe-j.

ChungPin commented 7 years ago

oh! I was misunderstanding! because I thought that dgd_person_reid is a image-based person re-identification, so I take one image as test probe intuitively. Actually I need 1 tracklet as test probe. I tried on VIPeR, I did some changing in /data/format_viper.py line 43-45

split = {'trainval': trainval_pids, 'test_probe': test_pids, 'test_gallery': test_pids}

to

split = {'trainval': trainval_pids, 'test_probe': test_pids[1], 'test_gallery': test_pids}

the JSON I got is correct, with only one id as test probe, but I got error when doing make_dbs.sh from /tools/make_lists_id_training.py line 53-55

for views in identities[split['test_probe']]: test_probe.append(views[:len(views) // 2]) test_gallery.append(views[len(views) // 2:])

I'm wondering the error I got is because test_probe.append(views[:len(views) // 2]), I'm not really sure. so actually, I need suggestion on how to input only one tracklet as test probe, not only one image, could you give me some suggestions again? Thank you very much! Sorry for the wrong question I asked yesterday, and sorry that I have to disturb you again!

Cysu commented 7 years ago

Well, do you mean to use a tracklet (sequence of images) for each test probe? I would say it's a different problem setting, which is normally called multi-shot person re-identification. I'm afraid that our evaluation code can not be used directly for this problem setting. You need to define and implement how to aggregate the features of each frame, how to split the data, and how to evaluate the results.

For your information, our work targets on single-shot person re-id. We structure the data by identity-view-image hierarchy, that is, each identity has several camera views, and each view contains several images. We choose the first half of views for probe and the second half for gallery.

ChungPin commented 7 years ago

Sorry for letting you misunderstand! Input one identity is what I really want to try, I was stuck and confused. So that's why I try to put only one identity in test probe, but I got error

for views in identities[split['test_probe']]: test_probe.append(views[:len(views) // 2]) test_gallery.append(views[len(views) // 2:])

from /tools/make_lists_id_training.py, could you give me some advice after changing one id for test probe? I am now trying VIPeR and PRID_2011

Thanks!

Cysu commented 7 years ago

You can modify these lines to

split = {'trainval': trainval_pids,
         'test_probe': test_pids[:1],
         'test_gallery': test_pids}

in order to use only the first test identity for probe and others for gallery.