Coder Social home page Coder Social logo

transreid's Introduction

Python >=3.5 PyTorch >=1.0

[ICCV2021] TransReID: Transformer-based Object Re-Identification [pdf]

The official repository for TransReID: Transformer-based Object Re-Identification achieves state-of-the-art performances on object re-ID, including person re-ID and vehicle re-ID.

News

  • 🌟 2023.11 VGSG for Text-based Person Search is accepted to TIP.
  • 🌟 2023.9 RGANet for Occluded Person Re-identification is accepted to TIFS.
  • 2023.3 The general human representation pre-training model. SOLIDER
  • 2021.12 We improve TransReID via self-supervised pre-training. Please refer to TransReID-SSL
  • 2021.3 We release the code of TransReID.

Pipeline

framework

Abaltion Study of Transformer-based Strong Baseline

framework

Requirements

Installation

pip install -r requirements.txt
(we use /torch 1.6.0 /torchvision 0.7.0 /timm 0.3.2 /cuda 10.1 / 16G or 32G V100 for training and evaluation.
Note that we use torch.cuda.amp to accelerate speed of training which requires pytorch >=1.6)

Prepare Datasets

mkdir data

Download the person datasets Market-1501, MSMT17, DukeMTMC-reID,Occluded-Duke, and the vehicle datasets VehicleID, VeRi-776, Then unzip them and rename them under the directory like

data
├── market1501
│   └── images ..
├── MSMT17
│   └── images ..
├── dukemtmcreid
│   └── images ..
├── Occluded_Duke
│   └── images ..
├── VehicleID_V1.0
│   └── images ..
└── VeRi
    └── images ..

Prepare DeiT or ViT Pre-trained Models

You need to download the ImageNet pretrained transformer model : ViT-Base, ViT-Small, DeiT-Small, DeiT-Base

Training

We utilize 1 GPU for training.

python train.py --config_file configs/transformer_base.yml MODEL.DEVICE_ID "('your device id')" MODEL.STRIDE_SIZE ${1} MODEL.SIE_CAMERA ${2} MODEL.SIE_VIEW ${3} MODEL.JPM ${4} MODEL.TRANSFORMER_TYPE ${5} OUTPUT_DIR ${OUTPUT_DIR} DATASETS.NAMES "('your dataset name')"

Arguments

  • ${1}: stride size for pure transformer, e.g. [16, 16], [14, 14], [12, 12]
  • ${2}: whether using SIE with camera, True or False.
  • ${3}: whether using SIE with view, True or False.
  • ${4}: whether using JPM, True or False.
  • ${5}: choose transformer type from 'vit_base_patch16_224_TransReID',(The structure of the deit is the same as that of the vit, and only need to change the imagenet pretrained model) 'vit_small_patch16_224_TransReID','deit_small_patch16_224_TransReID',
  • ${OUTPUT_DIR}: folder for saving logs and checkpoints, e.g. ../logs/market1501

or you can directly train with following yml and commands:

# DukeMTMC transformer-based baseline
python train.py --config_file configs/DukeMTMC/vit_base.yml MODEL.DEVICE_ID "('0')"
# DukeMTMC baseline + JPM
python train.py --config_file configs/DukeMTMC/vit_jpm.yml MODEL.DEVICE_ID "('0')"
# DukeMTMC baseline + SIE
python train.py --config_file configs/DukeMTMC/vit_sie.yml MODEL.DEVICE_ID "('0')"
# DukeMTMC TransReID (baseline + SIE + JPM)
python train.py --config_file configs/DukeMTMC/vit_transreid.yml MODEL.DEVICE_ID "('0')"
# DukeMTMC TransReID with stride size [12, 12]
python train.py --config_file configs/DukeMTMC/vit_transreid_stride.yml MODEL.DEVICE_ID "('0')"

# MSMT17
python train.py --config_file configs/MSMT17/vit_transreid_stride.yml MODEL.DEVICE_ID "('0')"
# OCC_Duke
python train.py --config_file configs/OCC_Duke/vit_transreid_stride.yml MODEL.DEVICE_ID "('0')"
# Market
python train.py --config_file configs/Market/vit_transreid_stride.yml MODEL.DEVICE_ID "('0')"
# VeRi
python train.py --config_file configs/VeRi/vit_transreid_stride.yml MODEL.DEVICE_ID "('0')"

# VehicleID (The dataset is large and we utilize 4 v100 GPUs for training )
CUDA_VISIBLE_DEVICES=0,1,2,3 python -m torch.distributed.launch --nproc_per_node=4 --master_port 66666 train.py --config_file configs/VehicleID/vit_transreid_stride.yml MODEL.DIST_TRAIN True
#  or using following commands:
Bash dist_train.sh 

Tips: For person datasets with size 256x128, TransReID with stride occupies 12GB GPU memory and TransReID occupies 7GB GPU memory.

Evaluation

python test.py --config_file 'choose which config to test' MODEL.DEVICE_ID "('your device id')" TEST.WEIGHT "('your path of trained checkpoints')"

Some examples:

# DukeMTMC
python test.py --config_file configs/DukeMTMC/vit_transreid_stride.yml MODEL.DEVICE_ID "('0')"  TEST.WEIGHT '../logs/duke_vit_transreid_stride/transformer_120.pth'
# MSMT17
python test.py --config_file configs/MSMT17/vit_transreid_stride.yml MODEL.DEVICE_ID "('0')" TEST.WEIGHT '../logs/msmt17_vit_transreid_stride/transformer_120.pth'
# OCC_Duke
python test.py --config_file configs/OCC_Duke/vit_transreid_stride.yml MODEL.DEVICE_ID "('0')" TEST.WEIGHT '../logs/occ_duke_vit_transreid_stride/transformer_120.pth'
# Market
python test.py --config_file configs/Market/vit_transreid_stride.yml MODEL.DEVICE_ID "('0')"  TEST.WEIGHT '../logs/market_vit_transreid_stride/transformer_120.pth'
# VeRi
python test.py --config_file configs/VeRi/vit_transreid_stride.yml MODEL.DEVICE_ID "('0')" TEST.WEIGHT '../logs/veri_vit_transreid_stride/transformer_120.pth'

# VehicleID (We test 10 times and get the final average score to avoid randomness)
python test.py --config_file configs/VehicleID/vit_transreid_stride.yml MODEL.DEVICE_ID "('0')" TEST.WEIGHT '../logs/vehicleID_vit_transreid_stride/transformer_120.pth'

Trained Models and logs (Size 256)

framework

DatasetsMSMT17MarketDukeOCC_DukeVeRiVehicleID
ModelmAP | R1mAP | R1mAP | R1mAP | R1mAP | R1R1 | R5
Baseline(ViT) 61.8 | 81.887.1 | 94.679.6 | 89.053.8 | 61.179.0 | 96.683.5 | 96.7
model | logmodel | logmodel | logmodel | logmodel | logmodel | test
TransReID*(ViT) 67.8 | 85.389.0 | 95.182.2 | 90.759.5 | 67.482.1 | 97.485.2 | 97.4
model | logmodel | logmodel | logmodel | logmodel | logmodel | test
TransReID*(DeiT) 66.3 | 84.088.5 | 95.181.9 | 90.757.7 | 65.282.4 | 97.186.0 | 97.6
model | logmodel | logmodel | logmodel | logmodel | logmodel | test

Note: We reorganize code and the performances are slightly different from the paper's.

Acknowledgement

Codebase from reid-strong-baseline , pytorch-image-models

We import veri776 viewpoint label from repo: https://github.com/Zhongdao/VehicleReIDKeyPointData

Citation

If you find this code useful for your research, please cite our paper

@InProceedings{He_2021_ICCV,
    author    = {He, Shuting and Luo, Hao and Wang, Pichao and Wang, Fan and Li, Hao and Jiang, Wei},
    title     = {TransReID: Transformer-Based Object Re-Identification},
    booktitle = {Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV)},
    month     = {October},
    year      = {2021},
    pages     = {15013-15022}
}

Contact

If you have any question, please feel free to contact us. E-mail: [email protected] , [email protected]

transreid's People

Contributors

heshuting555 avatar michuanhaohao 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

transreid's Issues

跨域测性能好吗?

跨域测性能好吗?做了一次伸手党。。模型下载速度有点慢,想问一问

the influence of batch_size

  Hi, I run the code as: python train.py --config_file configs/VeRi/vit_transreid_stride.yml MODEL.DEVICE_ID "('0')" and don't change the arguments except  batch_size, because of limited GPU. I set batch_size as 12 and mAP for VeRi-776 dataset is 70.3%, 10% lower than the original.
  Is this normal or something wrong happened?

How to train on TransReID's pretrained Veri/VehicleID weights?

I'm trying to train my custom dataset on your Veri/VehicleID pretrained weights but haven't got it right.

First approach was the simple:

imagenet_pretrained

but got this error:

error_imagenet

Second approach was changing PRETRAIN_CHOICE: 'self' and also on train.py:

normal

but got this error:

error_normal

Third approach was basically the same as the second but change the train.py:

finetune

the same error as the second approach

error_finetune

Can anyone guide me? Nowhere in the repo I have seen the code asking if PRETRAIN_CHOICE equals to 'self' or 'finetune', but in configs/default.py it says that those are the remaining options.

pretrain_choices

Question on performance

Hi, thanks for your awesome work.
I met some problem when trying to reproduce the results of vit-base on MSMT17. all default settings were not changed. I only got 58.2% mAP and 78.8% Rank1 that results is far lower than your reported, 61% mAP and 81% Rank1.

In addition, could you provide the config file that is used for ResNet50 to achieve 51.3% mAP?

关于Label Smooth

大佬你好!对于基于CNN的行人再识别来说,LabelSmooth是一个提升性能的比较常用的trick。而你的代码中没有使用LabelSmooth,我也测试过加入LabelSmooth反而会使性能降低。请问您有做实验对比过吗?您觉得原因是什么呢,是CNN和Transformer的差异决定的吗?

visualization

Could you please open source the visualization code in your project?It is a really nice work!

关于混合模型

请问一下怎么设置可以跑CNN+几层transformer的结构呢?我看代码里面是有这个HybridEmbed模型的

微调后的预训练权重

作者你好,我想问一下,在ImageNet-21K上预训练,然后在 ImageNet-1K上微调的预训练模型权重是您在代码中给的那几个链接吗?还是需要自己去训练?

camid一定要int吗

我看camid也参与了网络的计算,请问下camid具体参与什么计算呢,一般不是测试的时候才会用到camid吗?

请问训练ID增加之后训练效果越来越差怎么回事呢

我用market的数据训练的结果还是不错的,map能到89。但是换成我自己的数据总共2w多ID,训练的精度越来越低怎么回事呢?

训练log简略如下

`2021-06-04 00:48:20,521 transreid.train INFO: Epoch[20] Iteration[9650/9664] Loss: 0.258, Acc: 0.990, Base Lr: 7.47e-03
2021-06-04 00:48:23,076 transreid.train INFO: Epoch 20 done. Time per batch: 0.479[s] Speed: 200.2[samples/s]
2021-06-04 00:57:57,701 transreid.train INFO: Validation Results - Epoch: 20
2021-06-04 00:57:57,702 transreid.train INFO: mAP: 81.2%
2021-06-04 00:57:57,702 transreid.train INFO: CMC curve, Rank-1 :87.8%
2021-06-04 00:57:57,702 transreid.train INFO: CMC curve, Rank-5 :94.9%
2021-06-04 00:57:57,702 transreid.train INFO: CMC curve, Rank-10 :96.7%

2021-06-05 02:08:35,194 transreid.train INFO: Epoch[40] Iteration[9650/9664] Loss: 0.222, Acc: 0.992, Base Lr: 6.00e-03
2021-06-05 02:08:37,790 transreid.train INFO: Epoch 40 done. Time per batch: 0.465[s] Speed: 206.2[samples/s]
2021-06-05 02:25:14,449 transreid.train INFO: Validation Results - Epoch: 40
2021-06-05 02:25:14,449 transreid.train INFO: mAP: 75.3%
2021-06-05 02:25:14,449 transreid.train INFO: CMC curve, Rank-1 :83.8%
2021-06-05 02:25:14,449 transreid.train INFO: CMC curve, Rank-5 :92.7%
2021-06-05 02:25:14,449 transreid.train INFO: CMC curve, Rank-10 :95.0%

2021-06-06 03:36:32,438 transreid.train INFO: Epoch[60] Iteration[9650/9664] Loss: 0.192, Acc: 0.994, Base Lr: 4.01e-03
2021-06-06 03:36:34,616 transreid.train INFO: Epoch 60 done. Time per batch: 0.477[s] Speed: 201.5[samples/s]
2021-06-06 03:44:21,223 transreid.train INFO: Validation Results - Epoch: 60
2021-06-06 03:44:21,224 transreid.train INFO: mAP: 73.8%
2021-06-06 03:44:21,224 transreid.train INFO: CMC curve, Rank-1 :82.6%
2021-06-06 03:44:21,224 transreid.train INFO: CMC curve, Rank-5 :92.1%
2021-06-06 03:44:21,224 transreid.train INFO: CMC curve, Rank-10 :94.8%

2021-06-07 05:17:49,856 transreid.train INFO: Epoch[80] Iteration[9650/9664] Loss: 0.163, Acc: 0.996, Base Lr: 2.01e-03
2021-06-07 05:17:52,963 transreid.train INFO: Epoch 80 done. Time per batch: 0.475[s] Speed: 202.1[samples/s]
2021-06-07 05:23:11,936 transreid.train INFO: Validation Results - Epoch: 80
2021-06-07 05:23:11,937 transreid.train INFO: mAP: 76.2%
2021-06-07 05:23:11,937 transreid.train INFO: CMC curve, Rank-1 :84.0%
2021-06-07 05:23:11,937 transreid.train INFO: CMC curve, Rank-5 :92.9%
2021-06-07 05:23:11,937 transreid.train INFO: CMC curve, Rank-10 :95.3%

2021-06-08 07:02:58,814 transreid.train INFO: Epoch[100] Iteration[9650/9664] Loss: 0.132, Acc: 0.997, Base Lr: 5.51e-04
2021-06-08 07:03:02,568 transreid.train INFO: Epoch 100 done. Time per batch: 0.481[s] Speed: 199.7[samples/s]
2021-06-08 07:13:33,157 transreid.train INFO: Validation Results - Epoch: 100
2021-06-08 07:13:33,158 transreid.train INFO: mAP: 77.5%
2021-06-08 07:13:33,158 transreid.train INFO: CMC curve, Rank-1 :84.7%
2021-06-08 07:13:33,158 transreid.train INFO: CMC curve, Rank-5 :93.0%
2021-06-08 07:13:33,158 transreid.train INFO: CMC curve, Rank-10 :95.4%

2021-06-09 09:06:40,634 transreid.train INFO: Epoch[120] Iteration[9650/9664] Loss: 0.114, Acc: 0.998, Base Lr: 1.60e-05
2021-06-09 09:06:44,437 transreid.train INFO: Epoch 120 done. Time per batch: 0.482[s] Speed: 199.3[samples/s]
2021-06-09 09:10:12,020 transreid.train INFO: Validation Results - Epoch: 120
2021-06-09 09:10:12,021 transreid.train INFO: mAP: 77.3%
2021-06-09 09:10:12,021 transreid.train INFO: CMC curve, Rank-1 :84.3%
2021-06-09 09:10:12,021 transreid.train INFO: CMC curve, Rank-5 :92.9%
2021-06-09 09:10:12,021 transreid.train INFO: CMC curve, Rank-10 :95.1%`

训练配置如下

`MODEL:
PRETRAIN_CHOICE: 'imagenet'
PRETRAIN_PATH: '/home/tiantong/.cache/torch/hub/checkpoints/jx_vit_base_p16_224-80ecf9dd.pth'
METRIC_LOSS_TYPE: 'triplet'
IF_LABELSMOOTH: 'off'
IF_WITH_CENTER: 'no'
NAME: 'transformer'
NO_MARGIN: True
DEVICE_ID: ('2')
TRANSFORMER_TYPE: 'vit_base_patch16_224_TransReID'
STRIDE_SIZE: [12, 12]
SIE_CAMERA: True
SIE_COE: 3.0
JPM: True
RE_ARRANGE: True

INPUT:
SIZE_TRAIN: [256, 128]
SIZE_TEST: [256, 128]
PROB: 0.5 # random horizontal flip
RE_PROB: 0.5 # random erasing
PADDING: 10
PIXEL_MEAN: [0.5, 0.5, 0.5]
PIXEL_STD: [0.5, 0.5, 0.5]

DATASETS:
NAMES: ('yintai3')
ROOT_DIR: ('../../data')

DATALOADER:
SAMPLER: 'softmax_triplet'
NUM_INSTANCE: 4
NUM_WORKERS: 8

SOLVER:
OPTIMIZER_NAME: 'SGD'
MAX_EPOCHS: 120
BASE_LR: 0.008
IMS_PER_BATCH: 96
WARMUP_METHOD: 'linear'
LARGE_FC_LR: False
CHECKPOINT_PERIOD: 10 # 120
LOG_PERIOD: 50
EVAL_PERIOD: 20 # 120
WEIGHT_DECAY: 1e-4
WEIGHT_DECAY_BIAS: 1e-4
BIAS_LR_FACTOR: 2

TEST:
EVAL: True
IMS_PER_BATCH: 256
RE_RANKING: False
WEIGHT: ''
NECK_FEAT: 'before'
FEAT_NORM: 'yes'

OUTPUT_DIR: 'logs/market_vit_transreid_stride'

2021-06-02 23:19:55,969 transreid INFO: Running with config:
DATALOADER:
NUM_INSTANCE: 4
NUM_WORKERS: 8
SAMPLER: softmax_triplet
DATASETS:
NAMES: yintai3
ROOT_DIR: ../../data
INPUT:
PADDING: 10
PIXEL_MEAN: [0.5, 0.5, 0.5]
PIXEL_STD: [0.5, 0.5, 0.5]
PROB: 0.5
RE_PROB: 0.5
SIZE_TEST: [256, 128]
SIZE_TRAIN: [256, 128]
MODEL:
ATT_DROP_RATE: 0.0
COS_LAYER: False
DEVICE: cuda
DEVICE_ID: 2
DEVIDE_LENGTH: 4
DIST_TRAIN: False
DROP_OUT: 0.0
DROP_PATH: 0.1
ID_LOSS_TYPE: softmax
ID_LOSS_WEIGHT: 1.0
IF_LABELSMOOTH: off
IF_WITH_CENTER: no
JPM: True
LAST_STRIDE: 1
METRIC_LOSS_TYPE: triplet
NAME: transformer
NECK: bnneck
NO_MARGIN: True
PRETRAIN_CHOICE: imagenet
PRETRAIN_PATH: /home/tiantong/.cache/torch/hub/checkpoints/jx_vit_base_p16_224-80ecf9dd.pth
RE_ARRANGE: True
SHIFT_NUM: 5
SHUFFLE_GROUP: 2
SIE_CAMERA: True
SIE_COE: 3.0
SIE_VIEW: False
STRIDE_SIZE: [12, 12]
TRANSFORMER_TYPE: vit_base_patch16_224_TransReID
TRIPLET_LOSS_WEIGHT: 1.0
OUTPUT_DIR: logs/market_vit_transreid_stride_0602_231955
SOLVER:
BASE_LR: 0.008
BIAS_LR_FACTOR: 2
CENTER_LOSS_WEIGHT: 0.0005
CENTER_LR: 0.5
CHECKPOINT_PERIOD: 10
COSINE_MARGIN: 0.5
COSINE_SCALE: 30
EVAL_PERIOD: 20
GAMMA: 0.1
IMS_PER_BATCH: 96
LARGE_FC_LR: False
LOG_PERIOD: 50
MARGIN: 0.3
MAX_EPOCHS: 120
MOMENTUM: 0.9
OPTIMIZER_NAME: SGD
SEED: 1234
STEPS: (40, 70)
WARMUP_EPOCHS: 5
WARMUP_FACTOR: 0.01
WARMUP_METHOD: linear
WEIGHT_DECAY: 0.0001
WEIGHT_DECAY_BIAS: 0.0001
TEST:
DIST_MAT: dist_mat.npy
EVAL: True
FEAT_NORM: yes
IMS_PER_BATCH: 256
NECK_FEAT: before
RE_RANKING: False
WEIGHT: `

'pos_embed'

when run train.py,i have this question,thanks!!!

Question about the cls token

Awesome work of introducing transformer into ReID! But maybe I don't totaly understand the paper, having some confusion about the cls token. As shown in your paper, the cls token is a learnable embedding. And the code just initialize it as a parameter with normal distribution, and expand it to match the examples' shape in every batch. That is to say, the cls's value is no difference for each data when the model has completed training, Right? So I don't understand the meaning of setting it...
Thanks a lot for your help!

增加卷积层性能下降

您好!
很抱歉打扰到您,我想请问一下为什么我在PatchEmbed_overlap块增加convolution了以后性能大幅下降,我没有更改其他代码,只是将卷积层增加到了四层。这是我的部分代码:
self.conv1 = nn.Conv2d(in_chans, 128, kernel_size=7, stride=2, padding=3, bias=False)
self.bn1 = nn.BatchNorm2d(128)
self.relu = nn.ReLU(inplace=True)
self.proj = nn.Conv2d(128, embed_dim, kernel_size=new_patch_size, stride=new_patch_size)
def forward(self, x):
x = self.conv1(x)
x = self.bn1(x)
x = self.relu(x)

CUDA out of memory.

推荐的显存大小是16GB,请问显存小的时候有其他办法可以训练或评估吗?

关于学习率调整

我看代码中所提供的是SGD+CosineLRScheduler的优化组合。
想问下有没有尝试过别的学习率调整策略呢?例如WarmupMultiStepLR,效果如何呢?
训练VIT based 模型有什么特殊的技巧吗?

how to do attention visualization?

I refer to the online attention visualization tutorial on vit, but it can't achieve the effect in your paper. Can you share the code of the visualization part? Thank you very much

comparison of different backbone

hi~ @heshuting555
As you mention in the paper, you compare different backbones.
the ResNeSt50 can reach to mAP=61.2, which is comparable to the ViT-B/16.
Is that true?
Do you mean that use totally ResNeSt50 as you implemented in your code by using resnet50 followed by classifier and triplet layer directly,
Or relpace the blocks in the TransReID class?

look for more specific reply

Are center loss and ArcFace loss useful?

I found that there are center loss and ArcFace loss codes in the code, but they don’t seem to be used. I can’t find the results of comparative experiments in the paper. Are they useful?
Thank you!

关于Jigsaw Branch的问题

罗博士,您好。
关于您的代码中Global Branch和Jigsaw Branch部分,是不是在原有vit的基础上增加了一个block呢?
block = self.base.blocks[-1]
layer_norm = self.base.norm
self.b1 = nn.Sequential(
copy.deepcopy(block),
copy.deepcopy(layer_norm))

Question about Overlapping Patches

As shown in your paper, the shape of area where two adjacent patches overlap is (P - S) x P.
When P = S = 16, does this degenerate into a non-overlapping patches?
https://github.com/damo-cv/TransReID/blob/main/model/backbones/vit_pytorch.py
In your vit_pytorch.py, is the main difference between PatchEmbed and PatchEmbed_overlap that in Conv2d, the kernel_size of the former is equal to stride and equal to patch_size, while the stride and kernel_size of the latter can be different?
Thanks a lot for your help.

Change Backbone to Swin Transformer

Hello, first of all thank you guys for your excellent work. Have you ever tried to replace the backbone network of TransReID with Swin Transformer, because Swin seems to surpass ViT and DeiT in various fields of computer vision. I don’t know if Swin is in the re-identification field will also perform better. I look forward to your reply, thank you.

关于多数据集一起训练

大佬你好!
请问您的车辆reid模型在veri wild数据集上测试过结果吗?
另外想请教一个问题,我想用多个车辆数据集训练一个鲁棒性较好的模型,不知道有没有比较好的方法?
如果直接用您在veri776上训练好的模型再去其他数据集比如VehicleID上做一下迁移学习,不知道效果咋样?
还是直接用Imagenet的预训练模型在veri776+vehicleID+其他数据集上一起训练,不知道哪种效果会好一些?

Pretraining matters?

Many thanks for you breakthrough work of introducing transformer into Person Re-id. I have tried your code locally and it works
well as expected. However, I just find that the pretraining models from imagenet may have a significant influence on the downstream reid performance. The vit-base model was pretrained on imagenet21k and finetuned on imagenet 1k afterwards, while other cnn-based networks were mostly pretrained on imagenet 1k directly instead. So in fair, I think we have to compare these models by using the pretrained model from the same data scale.
I have also replaced the vit with the swin architecture which provides 1k pretrained model as well as 22k. The experiments with 22k pretrained models on market1501 and msmt17 outperforms those with 1k greatly. I suppose if using vit models pretrained on 1k imagenet dataset, the gap between TransReID and other cnn-based networks could be narrowed.
Anyway, transformer benefits a lot from dataset scale which can also be considered as a trick for downstream works like person reid. If you have also tried some experiments over such pretraining issues, I would appreciate if you can share some findings with me.

keypoint info

Hi, the num of images in keypoint_test.txt is 12080 (in this txt, 2 images have the same name), and there are 38632 images in keypoint_train.txt, so, there are 50712 in total.
But, the dataset of image_train has 37778 images, 1678 in query, and 11579 in gallery, 51035 in total;
In summary, 50712 keypoint info VS 51035 images, How to deal with the 323 images in TransReID??? Refer to the veri.py under datasets folder, it seems that there is no special operation for this case.
Looking forward to your reply, thank you very much!

visualize results

I complete train and test with market1501 dataset.
But I don't know how to show result : query and gallery example , so can you help me?
thank you so much!

base.sie_embed

Hello, I have a problem now. This problem is that when I use the trained model to test, a keyError:'base.sie_embed' appears. Where should I start to solve this? I look forward to your reply.

Training on external dataset without query images

Good afternoon!
Will you provide the code for training on external datasets? There are a lot of tasks, where datasets provided in format

 <folder1 "class name1"> : [img11,img21,...],
 <folder2 "class name2"> : [img21,img22,...],

It would be nice to test this approach on other datasets.
Thank you!

如何获取market的label分类

我使用market数据集训练好模型之后,可以获取pid的得分,请问如何对应到market的各个label中呢?

Training on KITTI Tracking benchmark

Hi, Thanks for your great work
Do you have code for testing your solution on KITTI Tracking benchmark or if you can guide me how to test it against KITTI Tracking benchmark?
I would really appreciate any help

多卡训练

请问你们的模型可以jinx多卡并行训练吗?
你们在做实验时有这样训练并测试性能吗,对模型性能是否有影响?

单机多卡训练

作者您好,您的代码好像只写了分布式的多卡和单卡训练是吗?

Test method for vehicleid dataset

Since the vehicleid dataset is different from other datasets, an error will be reported if the vehicleid dataset is tested according to the test method of other datasets.

RuntimeError: The size of tensor a (173) must match the size of tensor b (160) at non-singleton dimension 0

想问一下,我自己写了veri wild 的数据读入部分,我想直接用在veri数据集上训练的模型测试一下在veri wild上的结果,然后报错了,请问还要修改哪里呢?
完整的报错信息是这样的:
Traceback (most recent call last): File "test.py", line 53, in model.load_param(cfg.TEST.WEIGHT) File "E:\Win_Pycharm_Project\TransReID-main\TransReID-main\model\make_model.py", line 376, in load_param self.state_dict()[i.replace('module.', '')].copy_(param_dict[i]) RuntimeError: The size of tensor a (173) must match the size of tensor b (160) at non-singleton dimension 0

麻烦大佬了~~~

RuntimeError: CUDA error: CUBLAS_STATUS_NOT_INITIALIZED when calling `cublasCreate(handle)`

Traceback (most recent call last):
File "D:/Project/TransReID-main/train.py", line 86, in
num_query, args.local_rank
File "D:\Project\TransReID-main\processor\processor.py", line 58, in do_train
score, feat = model(img, target, cam_label=target_cam, view_label=target_view )
File "D:\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "D:\Project\TransReID-main\model\make_model.py", line 182, in forward
global_feat = self.base(x, cam_label=cam_label, view_label=view_label)
File "D:\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "D:\Project\TransReID-main\model\backbones\vit_pytorch.py", line 407, in forward
x = self.forward_features(x, cam_label, view_label)
File "D:\Project\TransReID-main\model\backbones\vit_pytorch.py", line 400, in forward_features
x = blk(x)
File "D:\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "D:\Project\TransReID-main\model\backbones\vit_pytorch.py", line 182, in forward
x = x + self.drop_path(self.attn(self.norm1(x)))
File "D:\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "D:\Project\TransReID-main\model\backbones\vit_pytorch.py", line 154, in forward
qkv = self.qkv(x).reshape(B, N, 3, self.num_heads, C // self.num_heads).permute(2, 0, 3, 1, 4)
File "D:\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "D:\Anaconda3\lib\site-packages\torch\nn\modules\linear.py", line 93, in forward
return F.linear(input, self.weight, self.bias)
File "D:\Anaconda3\lib\site-packages\torch\nn\functional.py", line 1692, in linear
output = input.matmul(weight.t())
RuntimeError: CUDA error: CUBLAS_STATUS_NOT_INITIALIZED when calling cublasCreate(handle)
我遇到了这个error,请问是什么情况啊?

stays at "transreid.train INFO: start training "

Hi,

Your work regarding Reid using Transformers is really appreciated.

I am trying to train the "Market" dataset using the terminal command:
python train.py --config_file configs/Market/vit_transreid_stride.yml MODEL.DEVICE_ID "('0')"
Model is initiallized but it remains in the state "transreid.train INFO: start training" and do not proceed further for training. While trying to debug, I found that program enters in the main loop of epochs but doesn't enters in the nested loop as shown below:
https://github.com/heshuting555/TransReID/blob/5901746360fc5c02b415f4dafb191d8d20d6e1c2/processor/processor.py#L43-L50
I don't know how to resolve this issue. Meanwhile i also looked into this but this didn't help me out. I shall be thankful for the fruitful response.

Kind Regards,

加载模型参数

您好!我将跑了一半的模型保存,然后重新加载模型参数想要继续跑,发现在imagenet预训练模式下找不到base.cls_token,报错信息为:KeyError: 'base.cls_token',这是为什么呢?self和finetune模式下不会报错,但精度很低。
期待您的回复!谢谢!

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.