Giter VIP home page Giter VIP logo

layumi / 2016_person_re-id Goto Github PK

View Code? Open in Web Editor NEW
265.0 27.0 117.0 13.68 MB

TOMM2017 A Discriminatively Learned CNN Embedding for Person Re-identification

Home Page: https://dl.acm.org/citation.cfm?id=3159171

License: MIT License

Makefile 2.58% MATLAB 27.97% C++ 6.62% Cuda 14.89% C 47.19% Shell 0.36% M 0.03% Roff 0.36%
matconvnet matlab person-reidentification tomm2017 reidentification re-id

2016_person_re-id's Introduction

A Discriminatively Learned CNN Embedding for Person Re-identification

In this package, we provide our training and testing code written in Matconvnet for the paper A Discriminatively Learned CNN Embedding for Person Re-identification.

We also include matconvnet-beta23 which has been modified for our paper. All codes have been test on Ubuntu14.04 and Ubuntu16.04 with Matlab R2015b.

This code is ONLY released for academic use.

Resources

~What's new: We add the data preparation and evaluation codes for CUHK03.

~What's new: We make the code of model structure more easy to follow.

~What's new: We provide a better code for extract feature.

~What's new: We provide a faster evaluation code for Market-1501.

Installation

  1. Clone this repo

    git clone https://github.com/layumi/2016_person_re-ID.git
    cd 2016_person_re-ID
    mkdir data
  2. Download the pretrained model.

    This model is ONLY released for academic use. You can find the pretrained model in GoogleDriver or [BaiduYun] (https://pan.baidu.com/s/1miG2OpM). Download and put them into the ./data.

    BaiduYun sometime changes the link. If you find the url fail, you can contact me to update it.

  3. Compile matconvnet (Note that I have included my Matconvnet in this repo, so you do not need to download it again. I has changed some codes comparing with the original version. For example, one of the difference is in /matlab/+dagnn/@DagNN/initParams.m. If one layer has params, I will not initialize it again, especially for pretrained model.)

    You just need to uncomment and modify some lines in gpu_compile.m and run it in Matlab. Try it~ (The code does not support cudnn 6.0. You may just turn off the Enablecudnn or try cudnn5.1)

    If you fail in compilation, you may refer to http://www.vlfeat.org/matconvnet/install/

Dataset

  • Download Market1501 Dataset. [Google] [Baidu] The photos are taken in Tsinghua University.

  • DukeMTMC-reID is a larger dataset in the same format of Market1501. The photos are taken in Duke University. You can download it from DukeMTMC-reID Dataset. We also upload the result to DukeMTMC-reID leaderboard.

  • If you want to rehearsal our result on CUHK03 Dataset, you can simply change the number of kernel from 751 to 1367 in resnet52_market.m and recreate net.mat. Because there are 751 IDs in Market-1501 while 1367 training identities are in CUHK03. More information can be found in cuhk03-prepare-eval dir. We add the data preparation and evaluation codes for CUHK03.

  • Training dataset for Oxford5k (http://cmp.felk.cvut.cz/cnnimageretrieval/)

Test

  1. Run test/test_gallery_query_crazy.m to extract the features of images in the gallery and query set. They will store in a .mat file. Then you can use it to do evaluation.
  2. Evaluate feature on the Market-1501. Run evaluation/zzd_evaluation_res_faster.m. You can get the following Single-query Result.
Methods               Rank@1 mAP
Ours* (SQ) 80.82% 62.30%
Ours* (MQ-avg) 86.67% 70.16%
Ours* (MQ-max) 86.76% 70.68%
Ours* (MQ-max+rerank) 86.67% 72.55%

*Note that the result is slightly higher than the result reported in our paper.

*For multi-query result, you can use evaluation/zzd_evaluation_res_fast.m . It is slower than evaluation/zzd_evaluation_res_faster.m since it need to extract extra features. (The evaluation code is modified from the Market-1501 Baseline Code)

FQA

  1. What is multi-query setting?

Actually, we can get a sequence of the query under one camera instead of one image. Then we can use every image in this sequence to extract a query mean feature (mean of feature extracted from several images). We call it multi-query. If we use this feature to do person retrieval, we usually get a better result. But it use additional images (in 'Market-1501/gt_bboxes'). You can find more detail in the original paper.

Train

  1. Add your dataset path into prepare_data.m and run it. Make sure the code outputs the right image path.

  2. Run train_id_net_res_2stream.m to have fun.

Citation

Please cite this paper in your publications if it helps your research:

@article{zheng2016discriminatively,
  title={A Discriminatively Learned CNN Embedding for Person Re-identification},
  author={Zheng, Zhedong and Zheng, Liang and Yang, Yi},
  doi={10.1145/3159171},
  note={\mbox{doi}:\url{10.1145/3159171}},
  journal={ACM Transactions on Multimedia Computing Communications and Applications},
  year={2017}
}

Acknowledge

Thanks for Xuanyi Dong to realize our paper in Caffe.

Thanks for Weihang Chen to realize our paper in Keras.

Thanks for Weihang Chen to report the bug in prepare_data.m.

Related Repos

  1. Person re-ID with GAN
  2. Pedestrian Alignment Network

2016_person_re-id's People

Contributors

joyluo avatar layumi avatar tannd-ds avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

2016_person_re-id's Issues

Use same data for training and validation?

Because of the same operation to image's set attribution that function rand_same_class and function rand_diff_class use in training and validation, the model validates with almost the same data from training, which will lead to unreliable accuracy.

Detail:

In cnn_train_day.m, line98~99

[net, state] = processEpoch(net, state, params, 'train',opts) ;
[net, state] = processEpoch(net, state, params, 'val',opts) ;

in each epoch,

  • function processEpoch will do training with opts containing data indexes whose set == 1;
  • and do validation with opts containing data indexes whose set == 2;
  • and do eval in line 219~226
if strcmp(mode, 'train')
    net.mode = 'normal' ;
    net.accumulateParamDers = (s ~= 1) ;
    net.eval(inputs, params.derOutputs, 'holdOn', s < params.numSubBatches) ;
else
    net.mode = 'test' ;
    net.eval(inputs) ;
end

the key point is, in processEpoch, line 206

inputs = params.getBatch(params.imdb, batch,opts) ;

both of training and validation use function getBatch to generate inputs data.

and in function getBatch in train_id_net_res_2stream.m, line51~57:

for i=1:batchsize
    if(i<=half)
        batch2(i) = rand_same_class(imdb, batch(i));
    else
        batch2(i) = rand_diff_class(imdb, batch(i));
    end
end

and in rand_same_class.m line 5~8

while(output==index || imdb.images.set(output)~=1)
        selected = randi(numel(list));
        output = list(selected);
end

filter out image whose set is 2, meaning that function rand_same_class doesn't produce test data in validation as well as rand_diff_class.

Summary

Because of the same operation that functionrand_same_class and function rand_diff_class use in training and validation, the model validates with almost the same data from training, which will lead to unreliable accuracy.

Fix Advice

Add a parameter referred to the eval mode to function rand_same_class and rand_diff_class, and filter out image data whose set is 2 in training, filter out image data whose set is 1 in validation. If you confirm this bug, I can post a pull request to fix it.

how to make the activation maps

Dear @layumi
the visualization of the activation maps in your paper is wonderful. and i am very curiosity of how to make it. i got no answer after searching the internet. so please tell me the skill when you have relax time.
thanks a lot.

Attempt to execute SCRIPT vl_nnconv as a function:

Hello,

I am using gcc 4.7 and g++ 4.7. and Matlab version Matlab2016a. They are compatible with making the mex files.
I used the command vl_compilenn to compile the files in Matlab folder and making the mex files.
Now mex files of are existed in matlab/mex folder.

I called matlab in test folder and use this command to add the subdirectory and mex files.
addpath(genpath(../matlab))
But when I tried to run the test_gallery_query_crazy.m file it reaches to this error.

Attempt to execute SCRIPT vl_nnconv as a function:

What is the source of this error ?

Thanks in advance.
Sarah

About the share weights?

Hi, @layumi
Thanks a lot for your code.
There is a question which puzzles me. Are the two branches of Resnet in your code share the same weights? I find that you initialize the parameters by the pretrained model and change the learning rate of parameters in each branch. But I haven't found how to make the two branches share the same weights.
Can you help me that?
Thanks!

some issues about Oxford5k dataset and train order

Hello,thank you for your paper and codes.
I have some questions for you to answer.
1,I have read the paper that mentioned the data set Oxford5k,but I donot konw how to get it and does the experiment utilize ti ?
2.With regard to the experiment, in github, after Installation and Dataset is the Test?Do you omit the training step ?
I'm looking forward to your reply ,thank you !

the ratio of classification loss and verification loss is 1/2

dear @layumi
when i train the siamese net, the loss of verification shakes widly. and it is down in a very difficult way to understand.
(1)how about you view of the change(down) of the verification loss
(2)do you have tune the net in other ratio of the two loss, and could you tell me the result
and this is the fig of classification loss and verification loss
clsloss
difloss
and thanks for you kindly

some problem about softmax output

Thanks for sharing a wonderful code! This code don't have any issue and this is my private problem.
For positive pairs, the network final two-dimension FC layer output like [0.57, 0.43] vector (I add a softmax layer after original final FC layer). Even though the network can distinguish positive and negative (because positive pairs most greater than 0.5, negative opposite), for my own project it had better output positive close to 1 (such as 0.95).
So why this code final two-dimension FC layer output like [0.57, 0.43] rather than [0.95, 0.05] as usual softmax layer do.

the way of ResNet-50-Basel

hi @layumi
your paper and code were read carefully. and the ResNet-50-Basel in your paper is higher then others. the question is how to train the baseline. Is the resnet50 with softmaxloss finetuned in the market1501?
and ours is finetune the resnet50 with siamese loss(two losses) using the market1501?
the last question is that the training solver between ResNet-50-Basel and ours are same or not?

thanks for your kind
luo ze

Undefined function or variable 'net'

@layumi hi,i try to run your code,but there is a mistake,when i run the"train_id_net_res_2stream.m",it shows
`cnn_train_dag: resuming by loading epoch 75
Undefined function or variable 'net'。

wrong cnn_train_dag>loadState (line 406)
net = dagnn.DagNN.loadobj(net) ;

wrong cnn_train_dag (line 67)
[net, state, stats] = loadState(modelPath(start)) ;

wrong train_id_net_res_2stream (line 34)
printf(cnn_train_dag(net, imdb, @GetBatch,opts) );`
can you tell me what's wrong with it,I have tried this problem for several days and have not solved this problem.thank you!

可视化

老哥,请问要如何得到您A Discriminatively Learned CNN Embedding for Person Re-identification论文那张分类结构的可视化图。老哥有写过python版本的吗?
image

there is an error when i am running the train_id_net_res_2stream

When i run the 'train_id_net_res_2stream ',there is an error shows:
"The subscript index must be a positive integer type or a logical type.
Wrong in train_id_net_res_2stream (line 13)
net.params(net.getParamIndex('fc751f')).learningRate = 0.01;"
My enviroment is win10 +matlab2016.
Can you tell me where is the problem?Thank you.

Load data error ?

运行环境:centos7 /matlab2014
运行test2/test_gallery_res.m 的时候,提示data/imagenet-resnet-50-dag.mat Not a binary mat file , try load -ASCII。
运行train_id_net_res_2stream.m的时候,也是同样的问题。
不知为何,求解点

run zzd_evaluation_res_faster.m and got NULL

@layumi
hello
thankyou for the code,but when I run zzd_evaluation_res_faster.m,I cannot got rank and got many NULL.
I check the code and find that the code is compare the query and test images in the market1501 dataset.
but the query and test images is different.
Could you please tell me what is wrong?
Thankyou verymuch!

Use 2016_person_re-ID train DukeMTMC

Hi, Zhedong Zheng;
I used the master to train Duke Data , but the mAP and the r1 is too low. I just change faster.m and crazy.m the image path.

The variable "dagnn" or class "dagnn.DagNN.loadobj" is not defined.

@layumi my configuration is cpu+matlab 2016a+vs2015+win10.
first,i run 'gpu_compile' to compile the matconvnet,and shows that the compilation is successful.then i want to run 'test_gallery_query_razy',but there was an error shows that:
The variable "dagnn" or class "dagnn.DagNN.loadobj" is not defined error test_gallery_query_crazy (line 8) net = dagnn.DagNN.loadobj(netStruct.net);
i used the method from internet--add 'run /matlab/vl_setupnn.m',but it also have the same error.

about training the cuhk03 dataset

Hi, I am very sorry to bother you again.I change the line from fc751Block = dagnn.Conv('size',[1 1 2048 751],'hasBias',true,'stride',[1,1],'pad',[0,0,0,0]); to fc751Block = dagnn.Conv('size',[1 1 2048 1367],'hasBias',true,'stride',[1,1],'pad',[0,0,0,0]); ,And no other changes have been made elsewhere.Then i run 'resnet52_2stream.m' to recreat 'net.mat', after that i run the 'train_id_net_res_2stream.m', but there has an error shows
错误使用 gpuArray/subsref Index exceeds matrix dimension. 出错 vl_nnloss (line 234) t = Xmax + log(sum(ex,3)) - x(ci) ; 出错 dagnn.Loss/forward (line 14) outputs{1} = vl_nnloss(inputs{1}, inputs{2}, [], 'loss', obj.loss, obj.opts{:}) ; 出错 dagnn.Layer/forwardAdvanced (line 85) outputs = obj.forward(inputs, {net.params(par).value}) ; 出错 dagnn.DagNN/eval (line 91) obj.layers(l).block.forwardAdvanced(obj.layers(l)) ; 出错 cnn_train_dag>processEpoch (line 222) net.eval(inputs, params.derOutputs, 'holdOn', s < params.numSubBatches) ; 出错 cnn_train_dag (line 90) [net, state] = processEpoch(net, state, params, 'train',opts) ; 出错 train_id_net_res_2stream (line 34) [net,info] = cnn_train_dag(net, imdb, @getBatch,opts) ;
Can you tell me what's wrong with me?Thank you very much!

could junkimage affect the rank1?

respectable layumi:
i am very interest in person re-id, and i read the paper and code from your team. and when i evaluation the result of net. the njunk can improve the result of rank1, and i think the real rank1 is cmc(n:end)=1; rather than cmc(n-njunk:end) = 1;
and i am looking forward to your reply.
and the code from 2016_person_re-ID/evaluation/compute_AP_rerank.m
if ~isempty(find(good_image == index(n), 1)) cmc(n-njunk:end) = 1; flag = 1; % good image good_now = good_now+1; end

how to get the result of single query and multi query

hi @layumi
the result of your code is based on single query. single query in you code is that every image in query dateset to get the search result in gallery dateset.
1, am i right about single query?
2, how to get the result of multi query?

and thanks for your kindly

about the cuhk03 evaluation

thanks for your evaluation code , but i am a little confused about one line of it. could you tell me what 'ff = ff.ff1' and 'ff =ff.ff2' mean. i don't find where the 'ff , ff1' is.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.