Coder Social home page Coder Social logo

huanghoujing / eanet Goto Github PK

View Code? Open in Web Editor NEW
397.0 15.0 90.0 2.77 MB

EANet: Enhancing Alignment for Cross-Domain Person Re-identification

Python 96.32% Shell 3.68%
person-reidentification reid reid-baseline eanet person-reid cross-domain domain-adaptation pytorch

eanet's Introduction

Introduction

The code for our paper EANet: Enhancing Alignment for Cross-Domain Person Re-identification. A Chinese version of introduction for this paper can be found here.

This repository provides

  • Almost all experiments, with trained models
  • Used data
  • Easy-to-extend framework

Installation

  • Python 2.7 (Recommend to use Anaconda for easy package management.)
  • Pytorch 1.0.0
  • Torchvision 0.2.1

The other packages and versions are listed in requirements.txt. You can install them by pip install -r requirements.txt.

Dataset Structure

Prepare datasets to have following structure:

${project_dir}/dataset
    market1501
        Market-1501-v15.09.15                   # Extracted from Market-1501-v15.09.15.zip, http://www.liangzheng.org/Project/project_reid.html
        Market-1501-v15.09.15_ps_label
        bounding_box_train_duke_style
        im_path_to_kpt.pkl
    cuhk03_np_detected_jpg
        cuhk03-np                               # Extracted from cuhk03-np.zip, https://pan.baidu.com/s/1RNvebTccjmmj1ig-LVjw7A
        cuhk03-np-jpg_ps_label
        im_path_to_kpt.pkl
    duke
        DukeMTMC-reID                           # Extracted from DukeMTMC-reID.zip, https://github.com/layumi/DukeMTMC-reID_evaluation
        DukeMTMC-reID_ps_label
        bounding_box_train_market1501_style
        im_path_to_kpt.pkl
    msmt17
        MSMT17_V1                               # Extracted from MSMT17_V1.tar.gz, https://www.pkuvmc.com/publications/msmt17.html
        MSMT17_V1_ps_label
        im_path_to_kpt.pkl
    partial_reid
        Partial-REID_Dataset                    # Extracted from Partial-REID_Dataset.rar, http://isee.sysu.edu.cn/files/resource/Partial-REID_Dataset.rar
    partial_ilids
        Partial_iLIDS                           # Provided by https://github.com/lingxiao-he/Partial-Person-ReID
    coco
        images
        masks_7_parts
        im_name_to_kpt.pkl
        im_name_to_h_w.pkl

Keypoints and part segmentation labels: Baidu Cloud or Google Drive. Our keypoint model is currently not public, while this repo can be an alternative. For part segmentation, we release our code at this repo.

Keypoint Format

The following example shows the keypoint format.

from __future__ import print_function
import cPickle
res = cPickle.load(open('dataset/market1501/im_path_to_kpt.pkl'))
# 'Market-1501-v15.09.15/bounding_box_train/0742_c1s4_014906_01.jpg' ...
print(res.keys()[:5])
# ['kpt', 'im_h_w']
print(res.values()[0].keys())
# A numpy array with shape [17, 3], for 17 keypoints. Each row is (x, y, confidence); we treat those with confidence > 0.1 as visible.
print(res.values()[0]['kpt'])
# [h, w] of the image
print(res.values()[0]['im_h_w'])

For COCO, there is a bit difference.

from __future__ import print_function
import cPickle
res = cPickle.load(open('dataset/coco/im_name_to_kpt.pkl'))
# Currently only contain train set.
# 'COCO_train2014_000000426663_185693.jpg' ...
print(res.keys()[:5])
# A numpy array with shape [17, 3], each row is (x, y, visibility), visibility is one of [0, 1, 2], refer to COCO dataset for detail
print(res.values()[0])

# image size
res = cPickle.load(open('dataset/coco/im_name_to_h_w.pkl'))
print(res.keys()[0])
print(res.values()[0])

Part Segmentation Label Format

Part segmentation label for each image is a single-channel PNG file, with same resolution as the image. Label mapping is as follows

{
    'background': 0,
    'head': 1,
    'torso': 2,
    'upper_arm': 3,
    'lower_arm': 4,
    'upper_leg': 5,
    'lower_leg': 6,
    'foot': 7,
}

Train/Test/Inference Example

  • Our trained models: Baidu Cloud or Google Drive.

  • Train model GlobalPool on market1501

    cd ${project_dir}
    CUDA_VISIBLE_DEVICES=0 python -m package.optim.eanet_trainer --exp_dir exp/eanet/GlobalPool/market1501 --cfg_file package/config/default.py --ow_file paper_configs/GlobalPool.txt --ow_str "cfg.dataset.train.name = 'market1501'"
  • Test the GlobalPool model that was trained on market1501. Make sure directory exp_dir exists and a ckpt.pth is inside it.

    cd ${project_dir}
    CUDA_VISIBLE_DEVICES=0 python -m package.optim.eanet_trainer --exp_dir exp/eanet/GlobalPool/market1501 --cfg_file package/config/default.py --ow_file paper_configs/GlobalPool.txt --ow_str "cfg.dataset.train.name = 'market1501'; cfg.only_test = True"
  • Users can also use a trained model for inference on their own images, with or without identity labels. script/exp/visualize_rank_list.py takes a query image directory and a gallery directory, and then visualize the retrieving results. E.g. use PCB trained on Market1501 to perform retrieving on Market1501 query and gallery images. Make sure directory exp_dir exists and the ckpt.pth is inside it.

    CUDA_VISIBLE_DEVICES=0 \
    python script/exp/visualize_rank_list.py \
    --exp_dir exp/vis_rank_list_PCB_M_to_M_id_aware \
    --cfg_file package/config/default.py \
    --ow_file paper_configs/PCB.txt \
    --ow_str "cfg.only_infer = True" \
    --q_im_dir dataset/market1501/Market-1501-v15.09.15/query \
    --g_im_dir dataset/market1501/Market-1501-v15.09.15/bounding_box_test \
    --save_dir exp/vis_rank_list_PCB_M_to_M_id_aware/result \
    --id_aware true

    The result is shown in misc/PCB_rank_list_M_to_M.

  • (Almost) All experiments of the paper is in script/exp/train_all.sh. Look at it for details.

  • To test (almost) all models of the paper. Download and place the trained models in the following structure

    ${project_dir}/exp/eanet/test_paper_models
    ├── GlobalPool
    │   ├── cuhk03_np_detected_jpg
    │   │   └── ckpt.pth
    │   ├── duke
    │   │   └── ckpt.pth
    │   └── market1501
    │       └── ckpt.pth
    ├── PAP
    │   ├── cuhk03_np_detected_jpg
    │   │   └── ckpt.pth
    │   ├── duke
    │   │   └── ckpt.pth
    │   └── market1501
    │       └── ckpt.pth
    ├── PAP_6P
    │   ├── cuhk03_np_detected_jpg
    │   │   └── ckpt.pth
    │   ├── duke
    │   │   └── ckpt.pth
    │   └── market1501
    │       └── ckpt.pth
    ├── PAP_ST_PS
    │   ├── cuhk03_np_detected_jpg_to_duke
    │   │   └── ckpt.pth
    │   ├── cuhk03_np_detected_jpg_to_market1501
    │   │   └── ckpt.pth
    │   ├── duke_to_cuhk03_np_detected_jpg
    │   │   └── ckpt.pth
    │   ├── duke_to_market1501
    │   │   └── ckpt.pth
    │   ├── market1501_to_cuhk03_np_detected_jpg
    │   │   └── ckpt.pth
    │   └── market1501_to_duke
    │       └── ckpt.pth
    ├── PAP_ST_PS_SPGAN
    │   ├── duke_to_market1501
    │   │   └── ckpt.pth
    │   └── market1501_to_duke
    │       └── ckpt.pth
    ├── PAP_ST_PS_SPGAN_CFT
    │   ├── duke_to_market1501
    │   │   └── ckpt.pth
    │   └── market1501_to_duke
    │       └── ckpt.pth
    ├── PAP_S_PS
    │   ├── cuhk03_np_detected_jpg
    │   │   └── ckpt.pth
    │   ├── duke
    │   │   └── ckpt.pth
    │   └── market1501
    │       └── ckpt.pth
    ├── PAP_StC_PS
    │   ├── cuhk03_np_detected_jpg
    │   │   └── ckpt.pth
    │   ├── duke
    │   │   └── ckpt.pth
    │   └── market1501
    │       └── ckpt.pth
    └── PCB
        ├── cuhk03_np_detected_jpg
        │   └── ckpt.pth
        ├── duke
        │   └── ckpt.pth
        └── market1501
            └── ckpt.pth
    

    Then, run

    cd ${project_dir}
    bash script/exp/test_all.sh

    You should get the following testing scores (Refer to the paper for table format). Note: The original models for PAP-ST-PS and PAP_ST_PS_SPGAN_CFT are missing, so we train the models again and their scores are not identical to the paper's.

    M->M C->C D->D M->C M->D C->M C->D D->M D->C
    GlobalPool 88.2 (71.3) 42.4 (39.6) 79.2 (61.9) 10.7 ( 9.3) 38.7 (21.5) 45.7 (21.8) 32.5 (15.7) 47.9 (21.6) 9.1 ( 7.7)
    PCB 93.2 (81.1) 65.2 (60.0) 86.3 (72.7) 8.9 ( 7.8) 42.9 (23.8) 52.1 (26.5) 29.2 (15.2) 56.5 (27.7) 8.4 ( 6.9)
    PAP-6P 94.4 (84.2) 68.1 (62.4) 85.6 (72.4) 11.6 ( 9.9) 47.6 (28.3) 54.6 (29.3) 33.9 (18.1) 59.7 (31.4) 9.2 ( 8.2)
    PAP 94.4 (84.5) 72.0 (66.2) 86.1 (73.3) 11.4 ( 9.9) 46.4 (27.9) 55.5 (30.0) 34.0 (17.9) 59.5 (30.6) 9.7 ( 8.0)
    PAP-S-PS 94.6 (85.6) 72.5 (66.7) 87.5 (74.6) 14.2 (12.8) 51.4 (31.7) 59.4 (33.3) 39.3 (22.0) 61.7 (32.8) 11.4 ( 9.6)
    PAP-StC-PS 94.7 (84.9) 70.1 (64.4) 87.0 (73.4) 19.1 (16.4) 56.3 (35.1) 65.5 (38.6) 45.2 (26.1) 65.2 (35.7) 12.2 (10.5)
    PAP-ST-PS - - - 22.4 (19.5) 55.3 (35.7) 67.8 (40.7) 43.9 (25.9) 66.5 (36.6) 15.1 (13.4)
    PAP-ST-PS-SPGAN - - - - 61.4 (39.4) - - 69.6 (39.3) -
    PAP-ST-PS-SPGAN-CFT - - - - 67.0 (47.0) - - 76.4 (50.3) -

Code Explanation

Training

The training logic is defined in package/optim/eanet_trainer.py and package/optim/cft_trainer.py, the latter for Clustering and Finetuning. A training command looks like

cd ${project_dir}
CUDA_VISIBLE_DEVICES=0 python -m package.optim.${trainer} --exp_dir ${exp_dir} --cfg_file ${cfg_file} [--ow_file ${ow_file}] [--ow_str ${ow_str}]
  • ${trainer} is one of eanet_trainer or cft_trainer.
  • ${exp_dir} is the directory for experiment output.
  • ${cfg_file} is a file defining configurations. Look at package/config/default.py for an example.
  • [Optional] ${ow_file} is a text file defining configurations to overwrite your ${cfg_file}.
  • [Optional] ${ow_str} is a string defining configurations to overwrite your ${cfg_file}.
  • ${ow_file} is mainly for storing the configurations used in the paper. Look at paper_configs/*.txt for details.
  • ${ow_str} is a handy way to modify some settings in command line without manually modify the config file. This is convenient, e.g. when running the same model on many datasets.
  • The code will copy ${cfg_file} into ${exp_dir}, and then overwrite the items specified in ${ow_file} (if provided) and then those in ${ow_str} (if provided).

Testing

Test sets and testing interval can be set in config file, and the training script will test the model during training. If you want to test a trained model, create a exp_dir and place the ckpt.pth inside it, then set cfg.only_test = True in ${config_file} and run package/optim/eanet_trainer.py. In this case, the code only performs testing.

Inference

To use a trained model for inference (extracting feature), the overall logic is

  1. Create a exp_dir and place the ckpt.pth inside it
  2. Set cfg.only_infer = True
  3. trainer = EANetTrainer(), then try trainer.infer_one_im or trainer.infer_im_list or trainer.infer_dataloader, which is flexible.

NOTE: Our model inference (feature extractor) can be used as an API, not just run in command line. For example, if you want to use PCB feature extractor trained on Market1501 in another project, you can add our package path to $PYTHONPATH. Then in your project, do something like this

from package.optim.eanet_trainer import EANetTrainer
from package.eval.np_distance import compute_dist
from easydict import EasyDict

args = EasyDict()
args.exp_dir = 'exp/try_pcb_trained_on_market1501_for_reid_feature'  # There should be the corresponding `ckpt.pth` in it
args.cfg_file = '${EANet_PROJECT_DIR}/package/config/default.py'  # Set this `${EANet_PROJECT_DIR}`
args.ow_file = '${EANet_PROJECT_DIR}/paper_configs/PCB.txt'  # Set this `${EANet_PROJECT_DIR}`
args.ow_str = "cfg.only_infer = True"

eanet_trainer = EANetTrainer(args=args)
feature_dict1 = eanet_trainer.infer_one_im(im_path='YOUR/IMAGE/PATH/1.jpg', squeeze=False)  # You can also provide PIL Image instead of image path
feature_dict2 = eanet_trainer.infer_one_im(im_path='YOUR/IMAGE/PATH/2.jpg', squeeze=False)  # You can also provide PIL Image instead of image path
cosine_distance = compute_dist(feature_dict1['feat'], feature_dict2['feat'])[0][0]

NOTE: For your own images, if you want to perform Part Aligned Pooling for inference, you have to provide keypoint generated pap_mask. Though, as alternatives you can use GlobalPool or PCB, which also achieve satisfactory performance in our implementation.

For details of inference, refer to package/optim/reid_trainer.py.

Extension: Dataset

Current datasets

  • Market1501
  • CUHK03-NP detected Subset
  • DukeMTMC-reID
  • MSMT17
  • Partial-REID
  • Partial-iLIDs

You can create new dataset class in package/data/datasets/ and then register it in package/data/create_dataset.py.

Extension: Model

Current backbone is ResNet. You can implement new backbones and then register them in package/model/backbone.py. Or you can re-define the whole model package/model/model.py, as long as you implement the methods declared in package/model/base_model.py.

Note: If you re-implement the whole model, you may have to modify the model.forward() logic in following files as well

  • package/optim/eanet_trainer.py
  • package/optim/cft_trainer.py
  • package/eval/extract_feat.py

This model calling can be abstracted away in the future.

Extension: Training

package/optim/reid_trainer.py covers the common logic for ReID training, with some abstraction to be implemented by sub classes. package/optim/eanet_trainer.py and package/optim/cft_trainer.py are concrete implementations, which also demonstrate the usage of hybrid batches and multi losses, etc.

Design Logic

We heavily use dict for passing data / configuration arguments when calling functions. This simplifies function headers and reduces the amount of code to modify when changing experiment settings.

TODO

  • More datasets
  • More backbones
  • Run TripletLoss
  • Run warmup
  • Test TensorBoard
  • Implement forward_type == 'ps_reid_serial'
  • Write commit num to log
  • Debug why it prints
    Loaded pickle file dataset/market1501/im_path_to_kpt.pkl
    Loaded pickle file dataset/market1501/im_path_to_kpt.pkl
    
    at the beginning of every epoch?

Misc

  • Tricky! EasyDict.__setattr__ will transform tuple into list! So don't rely on it to store tuples! You have to transform them into tuples wherever tuple is needed.
  • If you meet error ImportError: /lib64/libstdc++.so.6: version CXXABI_1.3.9 not found (required by ${Anaconda}/lib/python2.7/site-packages/scipy/sparse/_sparsetools.so), try conda install libgcc; export LD_LIBRARY_PATH=${YOUR_ANACONDA_HOME}/lib:${LD_LIBRARY_PATH}
  • The CUHK03 dataset provides image data in .mat format. open-reid transforms it to JPG images, while CUHK03-NP provides PNG images. Throughout the paper, we use JPG version of CUHK03-NP, due to some historical reasons. After the paper, we find that CUHK03-NP PNG has better performance than JPG on the GlobalPool baseline; We did not perform further experiments on other model architectures, due to time limitation.

Citation

If you find our work useful, please kindly cite our paper:

@article{huang2018eanet,
  title={EANet: Enhancing Alignment for Cross-Domain Person Re-identification},
  author={Huang, Houjing and Yang, Wenjie and Chen, Xiaotang and Zhao, Xin and Huang, Kaiqi and Lin, Jinbin and Huang, Guan and Du, Dalong},
  journal={arXiv preprint arXiv:1812.11369},
  year={2018}
}

eanet'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  avatar  avatar  avatar  avatar

eanet's Issues

kpt_to_pap_mask.py

Thanks for your job,in the kpt_to_pap_mask.py
def _to_ind(y):
return min(H, max(0, int(1. * H * y / im_h_w[0] + 0.5)))
y is between in [0, 1] ,Why is this formula going to be calculated like this?

KeyError: 'Market-1501-v15.09.15/bounding_box_train\\0661_c5s2_040055_01.jpg'

"__main__", mod_spec)

File "C:\Users\padmashree\anaconda3\envs\savitri\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\project_dir\EANet\package\optim\eanet_trainer.py", line 135, in
trainer.train_phases()
File "D:\project_dir\EANet\package\optim\eanet_trainer.py", line 126, in train_phases
self.train()
File "D:\project_dir\EANet\package\optim\reid_trainer.py", line 338, in train
self.trainer.train_one_epoch(trial_run_steps=3 if cfg.trial_run else None)
File "D:\project_dir\EANet\package\optim\trainer.py", line 35, in train_one_epoch
for i, batch in enumerate(self.train_loader):
File "C:\Users\padmashree\anaconda3\envs\savitri\lib\site-packages\torch\utils\data\dataloader.py", line 615, in next
batch = self.collate_fn([self.dataset[i] for i in indices])
File "C:\Users\padmashree\anaconda3\envs\savitri\lib\site-packages\torch\utils\data\dataloader.py", line 615, in
batch = self.collate_fn([self.dataset[i] for i in indices])
File "D:\project_dir\EANet\package\data\dataset.py", line 41, in getitem
sample['pap_mask'] = self.get_pap_mask(im_path)
File "D:\project_dir\EANet\package\data\dataset.py", line 74, in get_pap_mask
kpt = self.im_path_to_kpt[key]['kpt']
KeyError: 'Market-1501-v15.09.15/bounding_box_train\0661_c5s2_040055_01.jpg'

help me to resolve this

TypeError:Device() received an invalid combination of arguments - got()

Hello,when I run the code, i encounter an error, score_dict = eval_dataloader(model_for_eval, loader_dict['query'], loader_dict['gallery'], deepcopy(cfg.eval))
TypeError:Device() received an invalid combination of arguments - got(),but expected one of
*(torch.device device)
*(str type,int index)
In cfg.eval, 'device':torch.device('cuda')

kpt_to_pap_mask.py

Thanks for your job,in the kpt_to_pap_mask.py
def _to_ind(y):
return min(H, max(0, int(1. * H * y / im_h_w[0] + 0.5)))
Why is this formula going to be calculated like this?

Error in evaluation

Hi @huanghoujing , thanks for the nice repo. I tried to test the model , I can run the GlobalPool experiment successfully. However I encouter the following errors when running PAP series evaluation.
the error msg as follows:

File "/opt/conda/lib/python3.6/runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "/opt/conda/lib/python3.6/runpy.py", line 85, in _run_code exec(code, run_globals) File "/workspace/EANet/package/optim/eanet_trainer.py", line 133, in <module> trainer.test() File "/workspace/EANet/package/optim/reid_trainer.py", line 170, in test score_dict = eval_dataloader(model_for_eval, loader_dict['query'], loader_dict['gallery'], deepcopy(cfg.eval)) File "/workspace/EANet/package/eval/eval_dataloader.py", line 18, in eval_dataloader q_feat_dict = extract_dataloader_feat(model, q_loader, cfg) File "/workspace/EANet/package/eval/extract_feat.py", line 32, in extract_dataloader_feat for batch in tqdm(loader, desc='Extract Feature', miniters=20, ncols=120, unit=' batches'): File "/opt/conda/lib/python3.6/site-packages/tqdm/_tqdm.py", line 979, in __iter__ for obj in iterable: File "/opt/conda/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 637, in __next__ return self._process_next_batch(batch) File "/opt/conda/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 658, in _process_next_batch raise batch.exc_type(batch.exc_msg) TypeError: function takes exactly 5 arguments (1 given)
I strictly follow your instruction, but this error still occurs, would you mind helping me out?

high baseline accuracy

Thanks for sharing your nice and clean code! I notice that the baseline method Globalpool and PCB both achieve higher accuracy than this repo on (M->M, D->D). Could you share your tricks for the improvements?

No valid query error after 5 epochs

Training a PAP_S_PS model on market1501 data I encounter the following error:

raise RuntimeError("No valid query")
RuntimeError: No valid query 

This happens at the end of the 5th epoch where the training goes into evaluation. I wonder what could be the issue? Have you encountered it? It looks like in metric.py num_valid_queries = 0 but I have not idea why or how

I should also say that I was trying to train it on market1501 data after applying SPGAN but I was very careful with file names so I'm pretty sure they are consistent.

Below is the full log

=> Eval Statistics: dic.keys(): dict_keys(['q_feat', 'q_label', 'q_cam', 'g_feat', 'g_label', 'g_cam', 'q_visible', 'g_visible']) dic['q_feat'].shape: (3368, 2304) dic['q_label'].shape: (3368,) dic['q_cam'].shape: (3368,) dic['g_feat'].shape: (9997, 2304) dic['g_label'].shape: (9997,) dic['g_cam'].shape: (9997,) /home/ed/EANet/package/eval/metric.py:179: RuntimeWarning: invalid value encountered in double_scalars return float(np.sum(aps)) / np.sum(is_valid_query) Traceback (most recent call last): File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "/usr/lib/python3.6/runpy.py", line 85, in _run_code exec(code, run_globals) File "/home/ed/EANet/package/optim/eanet_trainer.py", line 134, in <module> trainer.train_phases() File "/home/ed/EANet/package/optim/eanet_trainer.py", line 125, in train_phases self.train() File "/home/ed/EANet/package/optim/reid_trainer.py", line 343, in train score_str = self.may_test() File "/home/ed/EANet/package/optim/reid_trainer.py", line 329, in may_test score_str = self.test() File "/home/ed/EANet/package/optim/reid_trainer.py", line 184, in test score_dict = eval_dataloader(self.model_for_eval, loader_dict['query'], loader_dict['gallery'], deepcopy(cfg.eval)) File "/home/ed/EANet/package/eval/eval_dataloader.py", line 33, in eval_dataloader return eval_feat(dic, cfg) File "/home/ed/EANet/package/eval/eval_feat.py", line 47, in eval_feat **input_kwargs File "/home/ed/EANet/package/eval/metric.py", line 100, in cmc raise RuntimeError("No valid query") RuntimeError: No valid query

Can't reach the accuracy of your model

Hi, @huanghoujing ,
I trained many times , use [warm up learning rate] +[triplet loss]+[id loss]+[batch size 64], but never achieve the accuracy of the model you provide ‘test_paper_models/PAP_ST_PS/market1501_to_duke’, Can you provide your training parameter settings?
thanks very much.

i am rookie and encounter ValueError: need more than 0 values to unpack

Traceback (most recent call last):
File "/home/ff/anaconda3/envs/python27/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"main", fname, loader, pkg_name)
File "/home/ff/anaconda3/envs/python27/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/home/ff/桌面/EANet-master/package/optim/eanet_trainer.py", line 131, in
trainer = EANetTrainer()
File "package/optim/reid_trainer.py", line 49, in init
self.init_eval()
File "package/optim/reid_trainer.py", line 109, in init_eval
self.create_test_loaders()
File "package/optim/reid_trainer.py", line 154, in create_test_loaders
'query': self.create_dataloader(mode='test', name=name, split=q_split),
File "package/optim/reid_trainer.py", line 145, in create_dataloader
dataloader = create_dataloader(deepcopy(cfg.dataloader), deepcopy(cfg.dataset), samples=samples)
File "package/data/dataloader.py", line 8, in create_dataloader
dataset = create_dataset(dataset_cfg, samples=samples)
File "package/data/create_dataset.py", line 35, in create_dataset
return __factory[cfg.name](cfg, samples=samples)
File "package/data/dataset.py", line 24, in init
self.samples = self.load_split()
File "package/data/dataset.py", line 53, in load_split
self.save_split(self.split_spec[cfg.split], save_path)
File "package/data/datasets/market1501.py", line 46, in save_split
ids, cams = zip(*[self.parse_im_path(p) for p in im_paths])
ValueError: need more than 0 values to unpack

Is it correct that infer_one_im is not deterministic?

Hey, I am using the new inference api, which is awesome, but I noticed that each time I run a distance between two images I get a different result. The results are quite different, which is really not good. This is the code I'm running:

args = EasyDict()
args.exp_dir = '../EANet/exp/eanet/test_paper_models/GlobalPool/market1501'  # There should be the corresponding `ckpt.pth` in it
args.cfg_file = '../EANet/package/config/default.py'  # Set this `${EANet_PROJECT_DIR}`
args.ow_file = '../EANet/paper_configs/PCB.txt'  # Set this `${EANet_PROJECT_DIR}`
args.ow_str = "cfg.only_infer = True"

eanet_trainer = EANetTrainer(args=args)
path1 = 'ignore/temp_market1501/00000413_0002_00000001.jpg'
path2 = 'ignore/temp_market1501/00000413_0002_00000002.jpg'
feature_dict1 = eanet_trainer.infer_one_im(im_path=path1, squeeze=False)  # You can also provide PIL Image instead of image path
feature_dict2 = eanet_trainer.infer_one_im(im_path=path2, squeeze=False)  # You can also provide PIL Image instead of image path

cosine_distance = compute_dist(feature_dict1['feat'], feature_dict2['feat'])[0][0]
print(cosine_distance)

The results I get from this vary from 0.16 to 0.21. Any idea why could this be?

ImportError: No module named 'resnet'

在运行python -m package.optim.eanet_trainer --exp_dir exp/eanet/GlobalPool/market1501 --cfg_file package/config/default.py --ow_file paper_configs/GlobalPool.txt --ow_str "cfg.dataset.train.name = 'market1501'; cfg.only_test = True"时,报错如下图:
1
sorry, 报错提示是:moduleNotFoundError: No module named 'resnet',我下载了resnet从18到152所有的pth,也放在了c盘的user的.torch目录下,不知是不是放错了?!

TypeError: function takes exactly 5 arguments (1 given)

kindly help me to resolve this error.

Traceback (most recent call last):
File "C:\Users\ssbilakeri\Anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "C:\Users\ssbilakeri\Anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\project_dir\EANet-master\package\optim\eanet_trainer.py", line 135, in
trainer.train_phases()
File "D:\project_dir\EANet-master\package\optim\eanet_trainer.py", line 126, in train_phases
self.train()
File "D:\project_dir\EANet-master\package\optim\reid_trainer.py", line 338, in train
self.trainer.train_one_epoch(trial_run_steps=3 if cfg.trial_run else None)
File "D:\project_dir\EANet-master\package\optim\trainer.py", line 35, in train_one_epoch
for i, batch in enumerate(self.train_loader):
File "C:\Users\ssbilakeri\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 637, in next
return self._process_next_batch(batch)
File "C:\Users\ssbilakeri\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 658, in _process_next_batch
raise batch.exc_type(batch.exc_msg)
TypeError: function takes exactly 5 arguments (1 given)

About extracting features. What value should the cos distance be set ?

I I notice there is no any quantitative value of cosine distance. For example, I want to know whether two pedestrians are one person or not, and then I should calculate the cosine distence bewteen the two feature corresponding to two pedestrians respectively. But I don't know what value is suitable. So can you give me some advices. thank you!

Cant find files

For some reason I am getting assertion errors of the kind ckpt_file exp/eanet/test_paper_models/PAP_ST_PS_SPGAN_CFT/duke_to_market1501/ckpt.pth not found, but I am following the instructions pretty carefully. I downloaded all the models to exp/test_paper_models as instructed.

I am not understanding why it looks for the models in in exp/eanet/test_paper_models/ instead of exp/test_paper_models/. Even if I fix this I get a different need more than 0 values to unpack error, which looking at other issues here seems to be an error with how I downloaded the data. I just want to make sure though.

implement of triplet loss

Hi,
NIce work! There have already been mang implements of tripletloss in your program, while you didn't put the results in your paper and README document. I'm concerned about how the tripletloss perform based on your algorithms. Thanks!

how to use such repository in practicals.

i have done all the steps described in readme.md file, also getting the score of testing as expected.
but my query is that, i want to search and re-idntify one single person realtime, can it is possible to use the above model.
if it is possible, then anyone can explain me how we can make it sucessful for 1 person only.

notice that, we have few images of intrested person, and test it with 1 or max 2 images of intersted person.
when i am giving small amount of images in query and bounding_box_test folder, i am getting error such as ,
Extract Feature: 100%|##############################################################| 1/1 [00:01<00:00, 1.28s/ batches]
=> Eval Statistics:
dic.keys(): dict_keys(['q_feat', 'q_label', 'q_cam', 'g_feat', 'g_label', 'g_cam'])
dic['q_feat'].shape: (25, 512)
dic['q_label'].shape: (25,)
dic['q_cam'].shape: (25,)
dic['g_feat'].shape: (5, 512)
dic['g_label'].shape: (5,)
dic['g_cam'].shape: (5,)

File "/home/vikram/OBJECT DETECTION & TRACKING/EANet-master/package/eval/metric.py", line 101, in cmc
raise RuntimeError("No valid query")
RuntimeError: No valid query

thank you in advanced.

Initialise weights to train from scratch

I'm trying to train a PAP_ST_PS model from scratch but it seems that it requires a ckpt file. I could use the test model you provided with the paper but I wonder if it would be more productive to start with random weights or some other baseline model? If so, where could I find/generate it

Thanks!

Keypoints and part segmentation for inference

Hi,

Thanks for providing the source code for your project. I was trying to test this on some unseen data to understand how this works cross-domain and also how it could be used in the wild but I have the following questions:

  1. For inference, how do you incorporate keypoints and part segmentation data. Is this even used for inference or just for training?
  2. In the paper you mention adapting models to target domain, could you point me to a resource explaining how's this done?

So far I've only tried PCB trained on market-1501 and my objective is to build a custom code that uses your code as an API to track a person in my own dataset across multiple frames

Thank you

kpt = self.im_path_to_kpt[key]['kpt'] KeyError: 'Market-1501-v15.09.15/bounding_box_train/0685_c4s3_063304_03.jpg'

Traceback (most recent call last):
File "C:\Users\zs.conda\envs\py38\lib\site-packages\torch\utils\data\dataloader.py", line 652, in next
data = self._next_data()
File "C:\Users\zs.conda\envs\py38\lib\site-packages\torch\utils\data\dataloader.py", line 692, in _next_data
data = self._dataset_fetcher.fetch(index) # may raise StopIteration
File "C:\Users\zs.conda\envs\py38\lib\site-packages\torch\utils\data_utils\fetch.py", line 49, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "C:\Users\zs.conda\envs\py38\lib\site-packages\torch\utils\data_utils\fetch.py", line 49, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "E:\EANet-master\package\data\dataset.py", line 41, in getitem
sample['pap_mask'] = self.get_pap_mask(im_path)
File "E:\EANet-master\package\data\dataset.py", line 78, in get_pap_mask
kpt = self.im_path_to_kpt[key]['kpt']
KeyError: 'Market-1501-v15.09.15/bounding_box_train/0685_c4s3_063304_03.jpg'

help me to resolve this!thanks!

请问pkl存储关键点的顺序是怎么样的?

您好,我用了OPENPOSE提取了18个关键点,依次包含鼻、颈、右肩、右肘、右腕、左肩、左肘、左腕、右髋、右膝、右踝、左髋、左膝、左踝、右眼、左眼、右耳和左耳。但是您项目中应该是17个关键点存储在 im_path_to_kpt.pkl。我在自己生成pkl文件的时候,不知道您的17个关键点是哪17个,然后存放的顺序是怎么样的。感谢您的解答和帮助!

for triplet loss

is the python 2.7 and pytorch 1.0.0 are not supportive for tripletloss ??

Result of MSMT17

Hi,
Nice work! I have try experiment on MSMT17(data and experiment config is same to your paper), but I can't get results (PAP-6P, Rank-1:75.5%) as your paper shows. So, is there some different configs from other dataset ?

data issue

Thanks for your great work. I find a little problem that when I unzip duke-20190104T081615Z-001.zip there is bounding_box_train_market1501_style.tar.gz in the duke fold

file not found error for .pkl file

Hi,
I am reproducing your paper result . when enabled ps_loss, id_loss, tri_loss as true . im getting bellow error.

what could be the reason?
hepl me to resolve , please .

File "C:\Users\MAHE\anaconda3_new\envs\savitri\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "C:\Users\MAHE\anaconda3_new\envs\savitri\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\project_dir\EANet\package\optim\eanet_trainer.py", line 135, in
trainer.train_phases()
File "D:\project_dir\EANet\package\optim\eanet_trainer.py", line 126, in train_phases
self.train()
File "D:\project_dir\EANet\package\optim\reid_trainer.py", line 338, in train
self.trainer.train_one_epoch(trial_run_steps=3 if cfg.trial_run else None)
File "D:\project_dir\EANet\package\optim\trainer.py", line 35, in train_one_epoch
for i, batch in enumerate(self.train_loader):
File "C:\Users\MAHE\anaconda3_new\envs\savitri\lib\site-packages\torch\utils\data\dataloader.py", line 637, in next
return self._process_next_batch(batch)
File "C:\Users\MAHE\anaconda3_new\envs\savitri\lib\site-packages\torch\utils\data\dataloader.py", line 658, in _process_next_batch
raise batch.exc_type(batch.exc_msg)
AssertionError: Traceback (most recent call last):
File "C:\Users\MAHE\anaconda3_new\envs\savitri\lib\site-packages\torch\utils\data\dataloader.py", line 138, in _worker_loop
samples = collate_fn([dataset[i] for i in batch_indices])
File "C:\Users\MAHE\anaconda3_new\envs\savitri\lib\site-packages\torch\utils\data\dataloader.py", line 138, in
samples = collate_fn([dataset[i] for i in batch_indices])
File "D:\project_dir\EANet\package\data\dataset.py", line 41, in getitem
sample['pap_mask'] = self.get_pap_mask(im_path)
File "D:\project_dir\EANet\package\data\dataset.py", line 72, in get_pap_mask
self.im_path_to_kpt = load_pickle(osp.join(self.root, 'im_path_to_kpt.pkl'))
File "D:\project_dir\EANet\package\utils\file.py", line 34, in load_pickle
assert osp.exists(path), "File not exists: {}".format(path)
AssertionError: File not exists: D:/project_dir/ReID_dataset/duke\im_path_to_kpt.pkl

The part_segmentation model

Thanks for your wonderful job. I have retrained the part segmentation model that you implemented in the repo "https://github.com/huanghoujing/PyTorch-Encoding", but my result is only pixAcc: 0.8866, mIoU: 0.6208. It is much worse than the released model (pixAcc: 0.9034, mIoU: 0.6670). So I wonder whether the training hyper-params is different from yours. I have selected the default hyper-params as follows:
CUDA_VISIBLE_DEVICES=0
python experiments/coco_part/train.py
--norm_layer bn
--train-split train
--batch-size 16
--test-batch-size 16
--exp_dir exp/train

every few epochs, can not load data

Hi, i had a problem in training. when load source and target data simultaneously, everything was normal at begining few epoch, but after that, it appears that it can't keep on loading data, and I must restart the program. Have you met this problem? What can I do to solve it? Thanks

AssertionError: There are 0 images for split [query] of dataset [Market1501]. Please place your dataset in right position.

Hi
first thanks for your great job, I download your code and make dataset file then put just market1501 in it (path: Download\EANet-master\dataset\market1501) but when I run, I get
AssertionError: There are 0 images for split [query] of dataset [Market1501]. Please place your dataset in right position.

I check this Issue ("i am rookie and encounter ValueError: need more than 0 values to unpack #3" ), and I follow it, I get 12940 as result.
and I download the dataset again but my problem did not solve. can you help me, please?

BatchSize的计算

作者您好,假设cfg.dataloader.train.batch_size = 32,请问一机多卡训练的时候,是每个卡都分配batch_size=32的数据吗

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.