GithubHelp home page GithubHelp logo

huanghoujing / person-reid-triplet-loss-baseline Goto Github PK

View Code? Open in Web Editor NEW
484.0 11.0 129.0 426 KB

Rank-1 89% (Single Query) on Market1501 with raw triplet loss, In Defense of the Triplet Loss for Person Re-Identification, using Pytorch

Python 100.00%

person-reid-triplet-loss-baseline's Introduction

Related Project: Strong Identification Loss Baseline

This project provides a strong triplet loss baseline in person re-identification, using pytorch.

Current Results

Triplet loss with settings:

  • ResNet-50, stride = 2 or stride = 1 in last conv block
  • NOT normalizing feature to unit length, with margin 0.3
  • Only horizontal flipping used for data augmentation
  • im_w x im_h = 128 x 256, ims_per_id = 4, ids_per_batch = 32
  • Adam optimizer, base learning rate 2e-4, decaying exponentially after 150 epochs. Train for 300 epochs in total.

The results are as follows. S1 and S2 means stride = 1 and stride = 2 respectively; R.R. means using re-ranking.

Rank-1 (%) mAP (%) R.R. Rank-1 (%) R.R. mAP (%)
Market1501-S2 86.43 71.50 89.82 85.55
Market1501-S1 89.04 75.29 91.57 87.82
Duke-S2 78.82 61.09 83.98 79.15
Duke-S1 79.76 64.27 85.32 81.48
CUHK03-S2 56.36 50.82 65.21 65.76
CUHK03-S1 59.14 54.43 69.86 70.03

We see that stride = 1 (higher spatial resolution before global pooling) has obvious improvement over stride = 2 (original ResNet). I tried this inspired by paper Beyond Part Models: Person Retrieval with Refined Part Pooling.

Other details of setting can be found in the code. To test my trained models or reproduce these results, see the Examples section.

Resources

This repository contains following resources

  • A beginner-level dataset interface independent of Pytorch, Tensorflow, etc, supporting multi-thread prefetching (README file is under way)
  • Three most used ReID datasets, Market1501, CUHK03 (new protocol) and DukeMTMC-reID
  • Python version ReID evaluation code (Originally from open-reid)
  • Python version Re-ranking (Originally from re_ranking)
  • Triplet Loss

Installation

It's recommended that you create and enter a python virtual environment, if versions of the packages required here conflict with yours.

I use Python 2.7 and Pytorch 0.3. For installing Pytorch, follow the official guide. Other packages are specified in requirements.txt.

pip install -r requirements.txt

Then clone the repository:

git clone https://github.com/huanghoujing/person-reid-triplet-loss-baseline.git
cd person-reid-triplet-loss-baseline

Dataset Preparation

Inspired by Tong Xiao's open-reid project, dataset directories are refactored to support a unified dataset interface.

Transformed dataset has following features

  • All used images, including training and testing images, are inside the same folder named images
  • Images are renamed, with the name mapping from original images to new ones provided in a file named ori_to_new_im_name.pkl. The mapping may be needed in some cases.
  • The train/val/test partitions are recorded in a file named partitions.pkl which is a dict with the following keys
    • 'trainval_im_names'
    • 'trainval_ids2labels'
    • 'train_im_names'
    • 'train_ids2labels'
    • 'val_im_names'
    • 'val_marks'
    • 'test_im_names'
    • 'test_marks'
  • Validation set consists of 100 persons (configurable during transforming dataset) unseen in training set, and validation follows the same ranking protocol of testing.
  • Each val or test image is accompanied by a mark denoting whether it is from
    • query (mark == 0), or
    • gallery (mark == 1), or
    • multi query (mark == 2) set

Market1501

You can download what I have transformed for the project from Google Drive or BaiduYun. Otherwise, you can download the original dataset and transform it using my script, described below.

Download the Market1501 dataset from here. Run the following script to transform the dataset, replacing the paths with yours.

python script/dataset/transform_market1501.py \
--zip_file ~/Dataset/market1501/Market-1501-v15.09.15.zip \
--save_dir ~/Dataset/market1501

CUHK03

We follow the new training/testing protocol proposed in paper

@article{zhong2017re,
  title={Re-ranking Person Re-identification with k-reciprocal Encoding},
  author={Zhong, Zhun and Zheng, Liang and Cao, Donglin and Li, Shaozi},
  booktitle={CVPR},
  year={2017}
}

Details of the new protocol can be found here.

You can download what I have transformed for the project from Google Drive or BaiduYun. Otherwise, you can download the original dataset and transform it using my script, described below.

Download the CUHK03 dataset from here. Then download the training/testing partition file from Google Drive or BaiduYun. This partition file specifies which images are in training, query or gallery set. Finally run the following script to transform the dataset, replacing the paths with yours.

python script/dataset/transform_cuhk03.py \
--zip_file ~/Dataset/cuhk03/cuhk03_release.zip \
--train_test_partition_file ~/Dataset/cuhk03/re_ranking_train_test_split.pkl \
--save_dir ~/Dataset/cuhk03

DukeMTMC-reID

You can download what I have transformed for the project from Google Drive or BaiduYun. Otherwise, you can download the original dataset and transform it using my script, described below.

Download the DukeMTMC-reID dataset from here. Run the following script to transform the dataset, replacing the paths with yours.

python script/dataset/transform_duke.py \
--zip_file ~/Dataset/duke/DukeMTMC-reID.zip \
--save_dir ~/Dataset/duke

Combining Trainval Set of Market1501, CUHK03, DukeMTMC-reID

Larger training set tends to benefit deep learning models, so I combine trainval set of three datasets Market1501, CUHK03 and DukeMTMC-reID. After training on the combined trainval set, the model can be tested on three test sets as usual.

Transform three separate datasets as introduced above if you have not done it.

For the trainval set, you can download what I have transformed from Google Drive or BaiduYun. Otherwise, you can run the following script to combine the trainval sets, replacing the paths with yours.

python script/dataset/combine_trainval_sets.py \
--market1501_im_dir ~/Dataset/market1501/images \
--market1501_partition_file ~/Dataset/market1501/partitions.pkl \
--cuhk03_im_dir ~/Dataset/cuhk03/detected/images \
--cuhk03_partition_file ~/Dataset/cuhk03/detected/partitions.pkl \
--duke_im_dir ~/Dataset/duke/images \
--duke_partition_file ~/Dataset/duke/partitions.pkl \
--save_dir ~/Dataset/market1501_cuhk03_duke

Configure Dataset Path

The project requires you to configure the dataset paths. In tri_loss/dataset/__init__.py, modify the following snippet according to your saving paths used in preparing datasets.

# In file tri_loss/dataset/__init__.py

########################################
# Specify Directory and Partition File #
########################################

if name == 'market1501':
  im_dir = ospeu('~/Dataset/market1501/images')
  partition_file = ospeu('~/Dataset/market1501/partitions.pkl')

elif name == 'cuhk03':
  im_type = ['detected', 'labeled'][0]
  im_dir = ospeu(ospj('~/Dataset/cuhk03', im_type, 'images'))
  partition_file = ospeu(ospj('~/Dataset/cuhk03', im_type, 'partitions.pkl'))

elif name == 'duke':
  im_dir = ospeu('~/Dataset/duke/images')
  partition_file = ospeu('~/Dataset/duke/partitions.pkl')

elif name == 'combined':
  assert part in ['trainval'], \
    "Only trainval part of the combined dataset is available now."
  im_dir = ospeu('~/Dataset/market1501_cuhk03_duke/trainval_images')
  partition_file = ospeu('~/Dataset/market1501_cuhk03_duke/partitions.pkl')

Evaluation Protocol

Datasets used in this project all follow the standard evaluation protocol of Market1501, using CMC and mAP metric. According to open-reid, the setting of CMC is as follows

# In file tri_loss/dataset/__init__.py

cmc_kwargs = dict(separate_camera_set=False,
                  single_gallery_shot=False,
                  first_match_break=True)

To play with different CMC options, you can modify it accordingly.

# In open-reid's reid/evaluators.py

# Compute all kinds of CMC scores
cmc_configs = {
  'allshots': dict(separate_camera_set=False,
                   single_gallery_shot=False,
                   first_match_break=False),
  'cuhk03': dict(separate_camera_set=True,
                 single_gallery_shot=True,
                 first_match_break=False),
  'market1501': dict(separate_camera_set=False,
                     single_gallery_shot=False,
                     first_match_break=True)}

Examples

Inference

You can use a trained model to extract features for a list of images, and then perform whatever you desire with these features. An example is

python script/experiment/infer_images_example.py \
--model_weight_file YOUR_MODEL_WEIGHT_FILE

Test

My training log and saved model weights for three datasets can be downloaded from Google Drive or BaiduYun.

Specify

  • a dataset name (one of market1501, cuhk03, duke)
  • stride, 1 or 2
  • an experiment directory for saving testing log
  • the path of the downloaded model_weight.pth

in the following command and run it.

python script/experiment/train.py \
-d '(0,)' \
--only_test true \
--dataset DATASET_NAME \
--last_conv_stride STRIDE \
--normalize_feature false \
--exp_dir EXPERIMENT_DIRECTORY \
--model_weight_file THE_DOWNLOADED_MODEL_WEIGHT_FILE

Train

You can also train it by yourself. The following command performs training, validation and finally testing automatically.

Specify

  • a dataset name (one of ['market1501', 'cuhk03', 'duke'])
  • stride, 1 or 2
  • training on trainval set or train set (for tuning parameters)
  • an experiment directory for saving training log

in the following command and run it.

python script/experiment/train.py \
-d '(0,)' \
--only_test false \
--dataset DATASET_NAME \
--last_conv_stride STRIDE \
--normalize_feature false \
--trainset_part TRAINVAL_OR_TRAIN \
--exp_dir EXPERIMENT_DIRECTORY \
--steps_per_log 10 \
--epochs_per_val 5

Log

During training, you can run the TensorBoard and access port 6006 to watch the loss curves etc. E.g.

# Modify the path for `--logdir` accordingly.
tensorboard --logdir YOUR_EXPERIMENT_DIRECTORY/tensorboard

For more usage of TensorBoard, see the website and the help:

tensorboard --help

Visualize Ranking List

Specify

  • a dataset name (one of ['market1501', 'cuhk03', 'duke'])
  • stride, 1 or 2
  • either model_weight_file (the downloaded model_weight.pth) OR ckpt_file (saved ckpt.pth during training)
  • an experiment directory for saving images and log

in the following command and run it.

python script/experiment/visualize_rank_list.py \
-d '(0,)' \
--num_queries 16 \
--rank_list_size 10 \
--dataset DATASET_NAME \
--last_conv_stride STRIDE \
--normalize_feature false \
--exp_dir EXPERIMENT_DIRECTORY \
--model_weight_file '' \
--ckpt_file ''

Each query image and its ranking list would be saved to an image in directory EXPERIMENT_DIRECTORY/rank_lists. As shown in following examples, green boundary is added to true positive, and red to false positve.

Time and Space Consumption

Test with CentOS 7, Intel(R) Xeon(R) CPU E5-2618L v3 @ 2.30GHz, GeForce GTX TITAN X.

Note that the following time consumption is not gauranteed across machines, especially when the system is busy.

GPU Consumption in Training

For following settings

  • ResNet-50, stride=1 in last block
  • identities_per_batch = 32, images_per_identity = 4, images_per_batch = 32 x 4 = 128
  • image size h x w = 256 x 128

it occupies ~11000MB GPU memory.

If not having a 12 GB GPU, you have to either decrease identities_per_batch or use multiple GPUs.

Training Time

Taking Market1501 as an example, it contains 31969 training images of 751 identities, thus 1 epoch = 751 / 32 = 24 iterations. Each iteration takes ~1.08s, so each epoch ~27s. Training for 300 epochs takes ~2.25 hours.

Testing Time

Taking Market1501 as an example

  • With images_per_batch = 32, extracting feature of whole test set (12936 images) takes ~160s.
  • Computing query-gallery global distance, the result is a 3368 x 15913 matrix, ~2s
  • Computing CMC and mAP scores, ~15s
  • Re-ranking requires computing query-query distance (a 3368 x 3368 matrix) and gallery-gallery distance (a 15913 x 15913 matrix, most time-consuming), ~90s

References & Credits

person-reid-triplet-loss-baseline's People

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

person-reid-triplet-loss-baseline's Issues

Other CNN Models

Dear @huanghoujing,
Have you ever trained other ConvNets (e.g., ResNet101, ResNet152, ResNext, Inception-ResNet-V2, DenseNet) as the backbone of your code?

what's the function of the mirrored image?

Hello, your code is very good.
I have a question. The dataloader returns mirrored image, but I don't see you use the mirrored image in triplet loss baseline. What's the function of the mirrored?

the different with open-reid

Hello, I find your evaluate score is high than open-reid on market1501 and dukemtmc. You got 75% mAP which open-reid just 67% before ReRank. Why? because the set of query&gallery ?

reproduce results

Hi

I train and test the Market1501 with the default parameters but only got 66% for CMC1 and 43.3% for mAP.

The precision in training is about 99.99%. Do you have any idea what might be wrong?

Cheers

except Exception, msg: ^ SyntaxError: invalid syntax

When I tried testing the pre-trained model on market1501 dataset using python3 the given command
"python script/experiment/train.py
-d '(0,)'
--only_test true
--dataset DATASET_NAME
--last_conv_stride STRIDE
--normalize_feature false
--exp_dir EXPERIMENT_DIRECTORY
--model_weight_file THE_DOWNLOADED_MODEL_WEIGHT_FILE"
I am getting the error
"except Exception, msg:
^
SyntaxError: invalid syntax"
and when testing it with python 2.7, I am getting the following error "train.py: error: unrecognized arguments:"
Any help would be appreciated !!
Thanks !

损失函数是不是可以更直接呢

TripletLoss 里面根据margin传入与否使用了MarginRankingLoss/SoftMarginLoss()。我看了几个Triplet-Loss的代码,大家都避开直接使用TripletMarginLoss和TripletMarginWithDistanceLoss,这到底是为什么呀。

About evaluation metric

Hello sir,
Thanks for your terrific implementation of triplet-loss-based person re-id method! I have a small question about the evaluation metric. As is pointed out by your document, the evaluation code is borrowed from Open Re-ID project(https://github.com/Cysu/open-reid).
In the open re-id project, it seems that some images(to be specific, those with id -1) in the original "bounding_box_test" folder are ignored while calculating CMC/MAP. I found when these images are added, the CMC1 drops from 87%+ to around 80%. I wonder whether the evaluation part of most person re-id papers also ignore these distractors with label -1.
I would be very appreciated for your reply.
Best wishes!

Rank 1, 5, 10 are high, but mAP is low

Hi. I use this code to train my own dataset, and when I train this model many times and then test them separately, some of them have high rank values but low mAP values. What is the reason? Thank.

String typeError in Python 3

I am using python 3 to run the program but at line 59 im_paths = [ospj(im_dir, n) for n in partitions['trainval_im_names']] typeError: Can't mix strings and bytes in path components will occur.
Is there a way to change this in python 3?

The performance in Table

Hi @huanghoujing ,
I am training the Mkaert1501 dataset only, but the performance is worse than your table's.
Are the results in the table training on all the datasets combined, or I have done something wrong.
I do as the following steps:
1
python script/dataset/transform_market1501.py
--zip_file ~/Dataset/market1501/Market-1501-v15.09.15.zip
--save_dir ~/Dataset/market1501
2
python script/experiment/train.py
-d '(0,)'
--only_test false
--dataset DATASET_NAME
--last_conv_stride STRIDE
--normalize_feature false
--trainset_part TRAINVAL_OR_TRAIN
--exp_dir EXPERIMENT_DIRECTORY
--steps_per_log 10
--epochs_per_val 5

Compare 2 photographs and get distance based on model

I've been trying to write up code that would allow me to extract features of a person, given by jpg, extract the features based on the model and then calculate the distance to other features extracted from other person shot.

Any pointers on this would be most appreciated.

Some queries regarding the model design

Hi! Great work!
I am trying to understand your model and implemented it in keras myself. There are few areas which I am uncertain of so could u give me some enlightenments?

  1. For the base model Resnet-50, other than changing the stride to 1 and removing the top layer, is there any other changes you have made on it? Besides, I notice that for your model, unlike the paper, you have
    i) x = F.avg_pool2d(x, x.size()[2:])
    ii) x = x.view(x.size(0), -1)
    after coming out from Resnet. May I know what are some of the reasons you chose to do these two layers, instead of following the paper, which suggest 2 dense layer and a batchnorm in between? In your case, what would be the output shape of your last flatten layer?

  2. It seems that you did not use the default dataset split provided by market1501. What are some of potential advantages using your split? In addition, why there are only 100 persons in the validation set? Shouldnt it be the same number of classes in the training set?

  3. I noticed that you also did preprocessing before passing images to the model, however, the values for your image mean ([0.486, 0.459, 0.408]) are different from that provided in imagenet.preprocess ([0.485, 0.456, 0.406]) specified in keras source code. May I know what is the reason for the change?

  4. In short, my keras implementation did not perform well on market1501, for the map and top1 top5 are quite low. Is it possible to give me some suggestions (anything) so that I can try to improve my model?

Thank you and hope to hear from you soon!

热图

你好,请问一下,我在运行visula_heatmap.py文件时,一直显示No such file or directory: '../Market-1501/pytorch/test_data'。但是我这个文件夹是存在的,这是为什么呢?

NO valid query

when training is over, when I test on dataset, it's wrong, it turn out No valid query

meet error in test (unknown error at /pytorch/aten/src/THC/THCTensorRandom.cu:25)

when I run test.
I meet error like:

THCudaCheck FAIL file=/pytorch/aten/src/THC/THCTensorRandom.cu line=25 error=30 : unknown error
Traceback (most recent call last):
File "train.py", line 561, in
main()
File "train.py", line 347, in main
model_w = DataParallel(model)
File "/home/moonuke/.local/lib/python2.7/site-packages/torch/nn/parallel/data_parallel.py", line 102, in init
_check_balance(self.device_ids)
File "/home/moonuke/.local/lib/python2.7/site-packages/torch/nn/parallel/data_parallel.py", line 17, in _check_balance
dev_props = [torch.cuda.get_device_properties(i) for i in device_ids]
File "/home/moonuke/.local/lib/python2.7/site-packages/torch/cuda/init.py", line 290, in get_device_properties
init() # will define _get_device_properties and _CudaDeviceProperties
File "/home/moonuke/.local/lib/python2.7/site-packages/torch/cuda/init.py", line 143, in init
_lazy_init()
File "/home/moonuke/.local/lib/python2.7/site-packages/torch/cuda/init.py", line 161, in _lazy_init
torch._C._cuda_init()
RuntimeError: cuda runtime error (30) : unknown error at /pytorch/aten/src/THC/THCTensorRandom.cu:25

it seems like when doing TensorRandom it happens?
how to deal with it ?
very thx

hard triplet convergence

I use triple loss between data of two modalities to reduce the distance between different modalities of the same class and increase the distance between different modalities of different class. But when I use batch_all loss, the valid set loss has not changed; now using hard_loss, the valid set loss still has not changed. What is the reason? I found some answers that triplet is difficult to converge. What do you do to deal with triplet loss convergence?

"val" set for combined dataset

Hi, there is an obvious error about "val" set for the combined dataset. In script/experiment/train.py, you set part='val' at Line 165 and use that to create val_set at Line 324. However, in tri_loss/dataset/__init__.py, there is assert part in ['trainval'], "Only trainval part of the combined dataset is available now." at Line 40. So, this is a conflict and if I fix with part='trainval' at Line 165 in train.py, there will be much more problems.

How to inference my own test set?

I want to use my own photos to inference, how to set up?
Can I migrate to my own test set with a pre-trained model? Or do I have to train my training set first?
thanks

Reasons for better results

Hi, as we can see from the paper 'In Defense of the Triplet Loss for Person Re-Identification', rank1 on Market1501 without test augmentation is 82.51%, while yours is 86.43%, I doubt that which settings make your network better, network architecture? batch size ? sampling for a batch?

Do you add some layer after Resnet50

I find that you didn't add any conv layer after Resnet50. So, you are trainning Resnet50, which is surprising to my, because normal net just fine-tune Resnet50, and use the after layer to discriminate, like PCB

cannot reproduce from pre-trained model on martket 1501 stride 1

Respected Author,
I am getting a very weird result from loading your pre-trained model and trying to run the evaluation, gave the following command as described in your readme.

python script/experiment/train.py \
-d '(0,)' \
--only_test true \
--dataset market1501 \
--last_conv_stride 1 \
--normalize_feature false \
--exp_dir ~/results \
--model_weight_file ~/weights/market1501_stride1/model_weight.pth

I am getting map of 2.42 and CMC rank1 of 11.
Any pointers would really be appreciated. Thanks in advance!

errors when loading model trained by myself for evaluation

I can use the provided model for evaluation and get reasonable results, but meet errors when loading the model trained by myself for evaluation. The following is the script I used to test using my own trained model:

python script/experiment/train.py
-d '(0,)'
--only_test true
--dataset duke
--last_conv_stride 1
--normalize_feature false
--exp_dir /export/reid_datasets/transformed_collection/trained_models/duke_stride1_evaluation
--model_weight_file /export/reid_datasets/transformed_collection/self_train/market_weight_c1000_t1_x0/ckpt.pth

The below is the error log:

Keys not found in source state_dict:
base.layer2.1.conv3.weight
base.layer3.0.conv2.weight
base.layer3.2.bn2.bias
base.layer1.0.bn2.running_mean
base.layer4.0.conv2.weight
base.layer2.0.conv2.weight
base.layer4.1.bn3.running_mean
base.layer1.2.bn1.weight
base.layer2.3.bn3.bias
base.layer3.5.bn3.bias
base.layer1.0.bn3.weight
base.layer2.1.bn3.weight
base.layer3.0.bn3.running_mean
base.layer3.5.conv2.weight
base.layer1.0.bn1.running_var
base.bn1.running_mean
base.layer3.3.bn1.weight
base.layer3.5.conv1.weight
base.layer4.2.bn3.running_var
base.layer3.2.bn1.running_var
base.layer3.0.bn3.running_var
base.layer3.2.bn3.bias
base.layer3.5.bn2.weight
base.layer2.2.bn1.running_var
base.layer1.1.bn1.weight
base.layer2.2.bn2.weight
base.layer2.2.bn1.running_mean
base.layer1.0.conv3.weight
base.layer3.2.conv2.weight
base.layer4.1.bn3.running_var
base.layer3.0.downsample.1.running_var
base.layer3.2.bn3.running_var
base.layer2.2.bn2.running_var
base.layer2.0.bn3.running_var
base.layer3.2.bn1.running_mean
base.layer2.2.bn3.running_mean
base.layer3.1.bn1.running_mean
base.layer4.2.bn2.weight
base.layer3.2.bn2.running_mean
base.layer4.0.conv1.weight
base.layer3.3.bn3.bias
base.layer2.3.conv2.weight
base.layer4.1.bn2.running_mean
base.layer4.0.downsample.0.weight
base.layer4.1.conv3.weight
base.layer3.3.conv2.weight
base.layer3.4.conv2.weight
base.layer4.2.conv1.weight
base.layer3.5.bn1.bias
base.layer3.5.bn3.running_var
base.layer1.2.bn2.running_mean
base.layer1.1.conv2.weight
base.layer1.1.bn3.bias
base.layer1.0.conv1.weight
base.layer2.2.conv2.weight
base.layer2.1.bn1.running_mean
base.layer1.1.bn3.running_var
base.layer1.2.bn3.running_mean
base.layer3.1.bn3.running_var
base.layer2.2.bn2.bias
base.layer2.1.bn2.weight
base.layer3.2.bn2.weight
base.layer2.0.downsample.1.weight
base.layer3.0.downsample.1.weight
base.layer3.3.bn2.running_mean
base.layer2.3.bn2.bias
base.layer4.0.bn2.weight
base.layer3.0.bn2.weight
base.layer3.2.bn3.weight
base.layer2.1.bn2.running_mean
base.layer2.1.bn3.bias
base.layer2.3.bn1.running_mean
base.layer4.0.bn2.running_var
base.layer1.1.conv1.weight
base.layer3.3.conv1.weight
base.layer3.5.bn1.running_var
base.layer1.2.bn2.running_var
base.layer3.4.bn3.running_mean
base.layer1.1.conv3.weight
base.layer1.1.bn3.running_mean
base.layer1.0.bn2.running_var
base.layer3.3.bn1.running_var
base.layer4.0.bn1.running_var
base.layer1.0.downsample.1.weight
base.layer3.5.conv3.weight
base.layer1.0.downsample.1.running_var
base.layer1.0.bn3.bias
base.layer3.4.bn1.running_var
base.layer3.4.bn2.bias
base.layer2.3.bn2.running_var
base.layer3.3.bn3.running_var
base.layer3.4.conv3.weight
base.layer3.5.bn3.weight
base.layer3.1.bn2.running_mean
base.layer2.2.bn3.running_var
base.layer3.5.bn2.bias
base.layer2.2.conv1.weight
base.layer4.0.bn1.bias
base.layer1.2.bn1.running_var
base.layer4.2.bn2.running_var
base.layer4.2.conv3.weight
base.layer4.2.bn2.bias
base.layer3.4.bn1.bias
base.bn1.bias
base.layer2.0.bn2.bias
base.layer3.3.bn1.bias
base.layer1.2.bn1.running_mean
base.layer4.0.bn3.running_mean
base.layer2.3.bn1.weight
base.layer2.0.bn2.weight
base.layer3.2.bn3.running_mean
base.layer3.0.bn2.running_var
base.layer3.2.bn2.running_var
base.layer2.3.bn3.running_mean
base.layer1.1.bn1.running_var
base.layer1.0.bn1.bias
base.layer1.2.conv1.weight
base.layer4.1.bn1.running_mean
base.layer1.2.bn3.running_var
base.layer1.2.bn2.bias
base.layer1.1.bn2.running_var
base.layer4.0.bn1.weight
base.layer2.0.downsample.0.weight
base.layer4.0.bn2.running_mean
base.layer2.2.bn3.bias
base.layer3.5.bn2.running_var
base.layer4.0.bn3.running_var
base.layer2.1.bn2.bias
base.layer3.0.bn2.bias
base.layer3.0.bn2.running_mean
base.layer3.4.bn1.weight
base.layer2.0.downsample.1.running_mean
base.conv1.weight
base.layer4.1.bn2.running_var
base.layer1.0.downsample.1.running_mean
base.layer4.1.bn1.weight
base.layer2.0.bn2.running_mean
base.layer3.0.downsample.0.weight
base.layer4.1.bn1.bias
base.layer2.2.bn1.bias
base.layer1.2.conv3.weight
base.layer1.0.downsample.1.bias
base.layer4.0.bn3.weight
base.layer2.2.bn1.weight
base.layer3.2.conv1.weight
base.layer3.0.bn1.bias
base.layer2.2.conv3.weight
base.layer4.1.bn2.weight
base.layer1.0.bn2.weight
base.layer3.0.bn3.weight
base.layer3.5.bn1.running_mean
base.layer2.3.bn1.running_var
base.layer3.0.bn1.weight
base.layer4.0.downsample.1.running_mean
base.layer1.1.bn2.bias
base.layer3.5.bn1.weight
base.layer3.0.bn3.bias
base.layer3.2.conv3.weight
base.layer3.1.bn3.bias
base.layer4.0.conv3.weight
base.layer3.4.bn3.running_var
base.layer2.0.bn3.weight
base.layer2.1.bn1.bias
base.layer3.0.conv1.weight
base.layer2.3.bn3.running_var
base.layer3.4.bn2.running_mean
base.layer3.3.bn3.weight
base.layer2.1.bn3.running_mean
base.layer3.5.bn3.running_mean
base.layer3.4.bn3.bias
base.layer3.1.bn1.weight
base.layer4.0.bn3.bias
base.layer4.1.bn3.weight
base.layer3.3.conv3.weight
base.layer4.2.bn1.running_var
base.layer4.2.bn3.weight
base.layer2.3.bn1.bias
base.layer3.2.bn1.weight
base.layer1.0.bn1.running_mean
base.layer2.0.conv1.weight
base.layer2.0.bn1.weight
base.layer3.1.bn3.weight
base.layer3.1.bn1.running_var
base.layer3.4.bn2.running_var
base.layer2.0.bn3.running_mean
base.layer4.2.bn3.bias
base.layer3.3.bn1.running_mean
base.layer4.2.bn1.weight
base.bn1.weight
base.layer1.1.bn2.weight
base.layer1.0.conv2.weight
base.layer2.0.bn1.bias
base.layer1.2.bn2.weight
base.layer1.1.bn1.bias
base.layer3.4.bn2.weight
base.layer4.2.bn3.running_mean
base.layer2.0.conv3.weight
base.layer2.2.bn3.weight
base.layer3.5.bn2.running_mean
base.layer3.0.downsample.1.bias
base.layer1.2.bn3.weight
base.layer1.2.conv2.weight
base.layer2.0.bn2.running_var
base.layer2.1.bn3.running_var
base.layer3.0.bn1.running_mean
base.layer2.0.bn3.bias
base.layer3.0.bn1.running_var
base.layer4.2.bn2.running_mean
base.layer1.2.bn3.bias
base.layer4.2.conv2.weight
base.layer1.0.bn1.weight
base.layer2.3.bn3.weight
base.layer3.1.bn2.weight
base.layer4.1.bn2.bias
base.layer2.0.bn1.running_var
base.layer2.0.downsample.1.running_var
base.layer2.3.bn2.weight
base.layer2.3.conv3.weight
base.layer3.1.bn1.bias
base.layer1.0.downsample.0.weight
base.layer2.3.bn2.running_mean
base.layer4.0.bn2.bias
base.layer3.3.bn2.bias
base.layer2.1.conv2.weight
base.layer3.1.conv3.weight
base.layer3.1.bn2.bias
base.layer1.1.bn1.running_mean
base.layer3.2.bn1.bias
base.layer3.3.bn3.running_mean
base.layer1.2.bn1.bias
base.layer4.0.downsample.1.running_var
base.layer3.3.bn2.weight
base.layer4.0.downsample.1.bias
base.layer2.2.bn2.running_mean
base.layer3.4.bn1.running_mean
base.layer4.0.bn1.running_mean
base.layer4.1.conv2.weight
base.layer3.4.conv1.weight
base.layer2.3.conv1.weight
base.layer1.0.bn3.running_var
base.layer3.0.conv3.weight
base.layer3.1.bn2.running_var
base.layer2.1.bn2.running_var
base.layer3.1.conv2.weight
base.layer2.0.downsample.1.bias
base.layer4.1.bn3.bias
base.layer1.1.bn3.weight
base.layer2.1.bn1.running_var
base.layer1.1.bn2.running_mean
base.layer1.0.bn3.running_mean
base.layer3.3.bn2.running_var
base.layer3.1.bn3.running_mean
base.layer2.0.bn1.running_mean
base.layer2.1.conv1.weight
base.layer1.0.bn2.bias
base.layer3.0.downsample.1.running_mean
base.layer4.2.bn1.bias
base.bn1.running_var
base.layer4.0.downsample.1.weight
base.layer3.4.bn3.weight
base.layer3.1.conv1.weight
base.layer4.1.bn1.running_var
base.layer4.2.bn1.running_mean
base.layer2.1.bn1.weight
base.layer4.1.conv1.weight
Keys not found in destination state_dict:
ep
scores
state_dicts

How does this happens? Thanks!

The problem of the intersection of person ids betweem trainval and gallery

Thank you for sharing the code!

when I write the codes as follow ,

if osp.exists(train_test_partition_file):
            train_test_partition = load_pickle(train_test_partition_file)
        else:
            raise RuntimeError("Train/test partition file should be provided.'") 
trainval_pids=set()
query_pids = set()
gallery_pids = set()
for im_type in ['detected','labeled']:
            trainval_im_names = train_test_partition[im_type]['train_im_names']
            query_im_names = train_test_partition[im_type]['query_im_names']
            gallery_im_names = train_test_partition[im_type]['gallery_im_names']
            
            trainval_pids.update(set([parse_im_name(n,'id') for n in trainval_im_names]))
            
            query_pids.update(set([parse_im_name(n,'id') for n in query_im_names]))
            gallery_pids.update(set([parse_im_name(n,'id') for n in gallery_im_names]))
           
        
print (trainval_pids & gallery_pids)
assert query_pids <= gallery_pids
assert trainval_pids.isdisjoint(gallery_pids)

It causes "AssertionError".
I find that there is an intersection between trainval and gallery. (set([1201, 1389]))
The training/testing partition file is “re_ranking_train_test_split.pkl” downloaded from the given link.
Looking forward for your reply, thank you.

关于一个epoch中的step数目

你好,我想请教一下:关于一个epoch中的step数目 。假如--ids_per_batch=32,--ims_per_id=4,那么就意味着一个batch的大小是128,参与训练的数据大小是12936,那么一个epoch是不是应该包含101或者102个step吗?为什么我输出了一下一个epoch中step的个数只有23个呢?是我的理解有问题,还是我哪里弄错了呢?谢谢!

Can't see a fully connected layer in the resnet network and Model

Hi,
I tried to go through your code but couldn't find any fully connected layer. In your base resnet50


no fc layer. In your model; after the avg pool, no fc

Can you tell me where it is located? I was expecting to see a fc layer after this x = x.view(x.size(0), -1) Model.py Line 19

关于d_ap的值

你好,请问在训练过程中会出现d_ap以及d_an逐渐增大,但是d_ap依然是小于d_an的,出现这样的情况是为什么呢?

关于实验性能请教

你好,
非常感谢实现了这么好的代码,最近基本将整个源码整体读了一遍。
在我复现的结果中,各项测试指标与你所提供的值基本吻合,但是在与其他方法对比的过程中,发现也有很多类似用到batch hard triplet loss的方法,但是发现此方法得到的结果超过了大多数的同类方法,因此对这一点有点疑惑。
按我理解,这个方法不同的可能在于last_conv_stride,在数据增强上只做了水平翻转,网络模型也很简洁,只提取了简单的全局特征,想探讨一下您认为是什么因素导致性能优于其他同类方法呢,是学习率设置、epoch等等的这些训练技巧吗?

关于实现和paper的区别,请指点一下

大佬你好,关于market1501数据集,paper中TriNet的mAP大概是69.1%,我在stride1的情况下训练出来大概是71%,差2%感觉有点多,自己也仔细的对照了一下区别。

下面的3个问题有点啰嗦,其实我就是想问一下:如果想达到69.1%(而不是71%)的mAP,需要调哪些args?如果你时间比较紧,可以忽略下面的问题,回答这个就足够了。十分期待你的回答,谢谢!

1.训练集共有751个人,按照P=32,算下来就是751/32=24个iteration=1epoch,但是为什么paper中他搞了25k个iteration啊,算下来就是1000+个epoch左右了,这和300个epoch比起来也太夸张了吧。是有什么地方我没算对么?
2.数据增强。我看原文中是"four corner crops and one center crop, as well as a horizontally flipped copy of each",代码中train_set是通过create_dataset函数创建的,但是create_dataset函数中没有关于数据增强的部分,请问数据增强是在什么地方做的?
3.我看model创建的时候pretrain默认是True,所以不管用trainval还是train,初始模型都是ImageNet上的ResNet50的预训练模型,对吧?

Performance is worse than yours

Hi @huanghoujing ,
I try to train model on Market1501, but evaluation result is worse than yours.
Your score is mAP=75.29 and rank-1=89.04 on Market1501-S1, but my score is mAP=64.90 and rank-1=81.59.

My training parameters are as following (refer to your description on github):
python3 script/experiment/train.py
-d '(0,)'
--only_test false
--dataset market1501
--last_conv_stride 1
--normalize_feature false
--exp_dir out
--steps_per_log 10
--epochs_per_val 5

other parameters are default,
--trainset_part trainval
--lr_decay_type exp
--exp_decay_at_epoch 151
--total_epochs 300

I train model on Python 2.7 and Pytorch 0.3, and pip install with requirements. But I don't know why evaluation result is worse than yours. Could you give me some hints? Thanks.

rerank

@huanghoujing ,Hello, if I don't want to use rerank, please tell me how should I set parameters?

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.