Git Product home page Git Product logo

person-reid-tiny-baseline's Introduction

Tiny Person ReID Baseline

Paper: "Bag of Tricks and A Strong Baseline for Deep Person Re-identification"[pdf]

This project refers the official code link and can reproduce the results as good as it on Market1501 when the input size is set to 256x128. If you find this project useful, please cite the offical paper.

@inproceedings{luo2019bag,
  title={Bag of Tricks and A Strong Baseline for Deep Person Re-identification},
  author={Luo, Hao and Gu, Youzhi and Liao, Xingyu and Lai, Shenqi and Jiang, Wei},
  booktitle={Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition Workshops},
  year={2019}
}

Updates (Difference from Official Code)

  • v0.1.2 (Feb. 2020)
    • Support Harder Example Mining, which achieve better performance. See docs for details.
    • Support visualizing augmented data
    • Support flipped features
    • Support search best parameters for reranking
  • v0.1.1 (Sep. 2019)
    • Support ArcFace loss
    • Support visualizing reID results
    • Add comments in config.py
  • v0.1.0 (Jun. 2019)
    • Develop based on the pytorch template
    • No need to install ignite and yacs
    • Support computing distance using cosine similarity
    • Set hyperparameters using a configuration class
    • Only support ResNet50 as the backbone

Directory layout

.
├── config                  # hyperparameters settings
│   └── ...                 
├── datasets                # data loader
│   └── ...           
├── log                     # log and model weights             
├── loss                    # loss function code
│   └── ...   
├── model                   # model
│   └── ...  
├── processor               # training and testing procedures
│   └── ...    
├── solver                  # optimization code
│   └── ...   
├── tools                   # tools
│   └── ...
├── utils                   # metrics code
│   └── ...
├── train.py                # train code 
├── test.py                 # test code 
├── get_vis_result.py       # get visualized results 
├── docs                    # docs for readme              
└── README.md

Pipeline

Pretrained Model

The pretrained (128x64) model can be downloaded now. Extraction code is u3q5.

Get Started

  1. cd to folder where you want to download this repo

  2. Run git clone https://github.com/lulujianjie/person-reid-tiny-baseline.git

  3. Install dependencies:

Train

python train.py

Test

python test.py

To get visualized reID results, first create results folder in log dir, then:

python ./tools/get_vis_result.py

You will get the ranked results (query|rank1|rank2|...), like:

Results

model method mAP Rank1
resnet50 triplet loss + softmax + center loss (B1) 85.8 94.1
resnet50 B1 + flipped feature 86.3 93.9
resnet50 B1 + Harder Example Mining 86.2 94.4
resnet50 B1 + flipped feature + Harder Example Mining 86.6 94.6
resnet50 B1 + Harder Example Mining + reranking 94.1 95.6
resnet50 B1 + Harder Example Mining + searched reranking 94.2 95.8

person-reid-tiny-baseline's People

Contributors

4review avatar lulujianjie 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

person-reid-tiny-baseline's Issues

KeyError: 'base.conv1.weight'

How to solve the following problems?
KeyError: 'base.conv1.weight'
$ python train.py 
2019-10-14 11:04:01,139 person-reid-tiny-baseline INFO: Running with config:
person-reid-tiny-baseline
=> Market1501 loaded
Dataset statistics:
  ----------------------------------------
  subset   | # ids | # images | # cameras
  ----------------------------------------
  train    |   751 |    12936 |         6
  query    |   750 |     3368 |         6
  gallery  |   751 |    15913 |         6
  ----------------------------------------
using triplet sampler
Traceback (most recent call last):
  File "train.py", line 23, in <module>
    model = make_model(Cfg, num_class=num_classes)
  File "/home/dd/wind/0ReID/person-reid-tiny-baseline/model/make_model.py", line 98, in make_model
    model = Backbone(num_class, Cfg)
  File "/home/dd/wind/0ReID/person-reid-tiny-baseline/model/make_model.py", line 48, in __init__
    self.base.load_param(model_path)
  File "/home/dd/wind/0ReID/person-reid-tiny-baseline/model/backbones/resnet.py", line 133, in load_param
    self.state_dict()[i].copy_(param_dict[i])
KeyError: 'base.conv1.weight'

weight

could you provide the google drive link for the resnet weight

Pretrained model

Could you please upload the pretrained model in google drive. Thanks you!!!

ValueError: too many values to unpack (expected 3)and KeyError: 'nv1.weight'

In training,after 5 epochs I recieved this error "ValueError: too many values to unpack (expected 3)" and I am not able to figure out after a lot of debugging.Screenshot is attached below

After not able to figure out I tried to test your pretained model,this error comes " KeyError: 'nv1.weight' ".Screenshot is attached below.

Can you tell whats wrong in errors
python train.py
Error
python test.py
error2

(url)

arcfaceloss ‘s performance

hello,have you tried replacing the original ce loss with arcfaceloss? if you have,is the performance better than the one with ce loss?

What's the licence?

Can I use your code/model in an open source plugin (MPL-2.0) for a commercial application (Video Management System)?

Problem with your code

I tried to visualize the results, but nothing
6 1TE$X P5EMEG24I99PKNS
}MKXQ}XTKM(9)`24W(51ZF7
No feats.pth file appeared at all, and I didn't find it where.
and there is no .cfg.WEIGHT definition in default at all, it is .TEST_WEIGHT? I don’t know what went wrong, help me, there are too many problems.

using se_resnext

Hi JackLu,

I really like your code, it's clean yet effective.
I want to adapt se_resnext from official code.
I copy the senet.py file to model/bacbones, then I add the following code in model/make_model.py line 46:

        elif model_name == 'se_resnext50':
            self.in_planes = 2048
            self.base = SENet(block=SEResNeXtBottleneck,
                              layers=[3, 4, 6, 3],
                              groups=32,
                              reduction=16,
                              dropout_p=None,
                              inplanes=64,
                              input_3x3=False,
                              downsample_kernel_size=1,
                              downsample_padding=0,
                              last_stride=last_stride)

I also prepared the ImageNet pre-traind weights and configs.
Then python train.py
The code runs well, but the mAP is not increasing even after many epochs, it stuck in about 0.2%.
I think do not modify other codes, do you have any idea about it?
Thanks a lot!!!

KeyError: 'base.conv1.weight'

Trying to run the code. Got the error

KeyError: 'base.conv1.weight' in backbone file.

Have any idea to solve this?

Thank you.

Harder Example Mining

Hi! Thanks for your great work!
Is harder example mining a method from a published paper? If yes, can you tell me the name of this paper? Thanks

what are the hyperparameters under the setting of triplet+softmax?

I appreciate your sententious work. However, I failed to reproduce your result under the setting of triplet+softmax, I thought it may result from the hyperparameters ( I only change COS_LAYER->no, LOSS_TYPE->triplet+softmax, TEST_METHOD->euclidean ). So, I hope you can provide the hyperparameters under the setting of triplet+softmax. Thank you!

Does this code able to fit Mac hardware which only has cpu?

" raise RuntimeError('Attempting to deserialize object on a CUDA '
RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location='cpu' to map your storages to the CPU."

anyone who can help this? and I change map as below, still report error while run "python train.py".

def load_param(self, trained_path):
    param_dict = torch.load(trained_path,**map_location='cpu'**)

def load_param(self, model_path):
param_dict = torch.load(model_path,map_location='cpu')

一个小问题

你好,谢谢你的实现,问一个比较愚蠢的问题,utils/metrics.py里,函数eval_func里代码matches = (g_pids[indices] == q_pids[:, np.newaxis]).astype(np.int32)是什么意思?matches没一行表示的是什么意思?

还有就是,如果re-id网络在实际运用的时候,是不是只需要计算下待查找的box的特征,然后和检索库中计算所有待检索box的特征相比较,把距离(欧式距离或者余弦距离)最近的前N(1 or 5 or 10)个待检索的box取出来就可以了?

小白一枚,刚接触person-reid,望不吝赐教,感谢

Mirror Model

Can you mirror the model to google drive or drop box

A strange mistake in triplet_loss.py

hi!
I run your code but reported a strange error:File "./code/triplet_loss.py", line 62, in hard_example_mining dist_ap, relative_p_inds = torch.max(dist_mat[is_pos].contiguous().view(N, -1), 1, keepdim=True)
RuntimeError: shape '[64, -1]' is invalid for input of size 288
I think it for a long time, but I don't know how to fix it, can anyone help me?

the arcface loss

do you use the arcfaceloss in the project , but I con't find it any where.

达不到所称的准确率

用给出的代码训练出的准确率是85.7%;将loss改为三种相加,也是百分之八十五多;请问有哪些注意事项吗

Dependencies

Hello,

I am trying to replicate your code, but apparently my environment is lacking something that I completely ignore.
Can you please provide me with a Dockerfile with all the required dependencies?
Many thanks!

How to get the best result?

hi, thank you for your good work! It's helpful for me! But I run your code can only get a result of map=86.2% rank-1=94.6%. How to get the best result as you described map=94.2% Rank -1=95.8%? and in “B1 + Harder Example Mining + searched reranking”, what does "B1" mean?

Low results

Nice work!
But I got low results on market dataset using your default config. (I see you get 88% Rank1)

The test feature is normalized
=> Computing DistMat with euclidean distance
2019-06-13 09:21:40,468 baseline-person-reid.train INFO: Validation Results - Epoch: 120
2019-06-13 09:21:40,468 baseline-person-reid.train INFO: mAP: 57.9%
2019-06-13 09:21:40,468 baseline-person-reid.train INFO: CMC curve, Rank-1  :82.7%
2019-06-13 09:21:40,468 baseline-person-reid.train INFO: CMC curve, Rank-5  :93.4%
2019-06-13 09:21:40,468 baseline-person-reid.train INFO: CMC curve, Rank-10 :95.8%

any suggestion ?
I also tested on Duke dataset, but the Rank1 and mAP are still low.

The test feature is normalized
=> Computing DistMat with euclidean distance
2019-06-13 00:16:53,749 baseline-person-reid.train INFO: Validation Results - Epoch: 120
2019-06-13 00:16:53,750 baseline-person-reid.train INFO: mAP: 48.3%
2019-06-13 00:16:53,750 baseline-person-reid.train INFO: CMC curve, Rank-1  :70.3%
2019-06-13 00:16:53,750 baseline-person-reid.train INFO: CMC curve, Rank-5  :83.8%
2019-06-13 00:16:53,750 baseline-person-reid.train INFO: CMC curve, Rank-10 :87.0%

learning rate

When I training the model using arcface loss,how should I adjust the learning rate?Thank you!

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.