├── .gitignore
├── LUP-NL
├── README.md
├── convert_lmdb.py
├── download.py
└── extract.py
├── PNL
├── README.md
├── libs
│ ├── __init__.py
│ ├── dataset.py
│ ├── encoder.py
│ ├── lars.py
│ ├── loader.py
│ ├── losses.py
│ ├── moco_builder.py
│ ├── pnl_builder.py
│ ├── simclr_builder.py
│ ├── supcont_builder.py
│ ├── transform.py
│ └── utils.py
├── lup_moco.py
├── lup_pnl.py
├── lup_simclr.py
├── lup_supcont.py
└── scripts
│ ├── run_moco.sh
│ ├── run_pnl.sh
│ ├── run_simclr.sh
│ └── run_supcont.sh
├── README.md
└── fast-reid
├── LICENSE
├── README.md
├── configs
├── Base-AGW.yml
├── Base-MGN.yml
├── Base-Strongerbaseline.yml
├── Base-bagtricks.yml
├── CMDM
│ ├── mgn_R101.yml
│ ├── mgn_R101_moco.yml
│ ├── mgn_R50.yml
│ ├── mgn_R50_cmdm.yml
│ ├── mgn_R50_img_moco.yml
│ ├── mgn_R50_lup200.yml
│ ├── mgn_R50_lup300.yml
│ └── mgn_R50_moco.yml
├── DukeMTMC
│ ├── AGW_R101-ibn.yml
│ ├── AGW_R50-ibn.yml
│ ├── AGW_R50.yml
│ ├── AGW_S50.yml
│ ├── bagtricks_R101-ibn.yml
│ ├── bagtricks_R50-ibn.yml
│ ├── bagtricks_R50.yml
│ ├── bagtricks_S50.yml
│ ├── mgn_R50-ibn.yml
│ ├── sbs_R101-ibn.yml
│ ├── sbs_R50-ibn.yml
│ ├── sbs_R50.yml
│ └── sbs_S50.yml
├── LUP
│ ├── agw_R50.yml
│ ├── bot_R50.yml
│ └── mgn_R50.yml
├── MSMT17
│ ├── AGW_R101-ibn.yml
│ ├── AGW_R50-ibn.yml
│ ├── AGW_R50.yml
│ ├── AGW_S50.yml
│ ├── bagtricks_R101-ibn.yml
│ ├── bagtricks_R50-ibn.yml
│ ├── bagtricks_R50.yml
│ ├── bagtricks_S50.yml
│ ├── mgn_R50-ibn.yml
│ ├── sbs_R101-ibn.yml
│ ├── sbs_R50-ibn.yml
│ ├── sbs_R50.yml
│ └── sbs_S50.yml
├── Market1501
│ ├── AGW_R101-ibn.yml
│ ├── AGW_R50-ibn.yml
│ ├── AGW_R50.yml
│ ├── AGW_S50.yml
│ ├── bagtricks_R101-ibn.yml
│ ├── bagtricks_R50-ibn.yml
│ ├── bagtricks_R50.yml
│ ├── bagtricks_S50.yml
│ ├── mgn_R50-ibn.yml
│ ├── sbs_R101-ibn.yml
│ ├── sbs_R50-ibn.yml
│ ├── sbs_R50.yml
│ └── sbs_S50.yml
├── VERIWild
│ └── bagtricks_R50-ibn.yml
├── VeRi
│ └── sbs_R50-ibn.yml
└── VehicleID
│ └── bagtricks_R50-ibn.yml
├── datasets
├── cuhk03_np
│ ├── detected
│ │ ├── few_ids
│ │ │ ├── used_ids_0.10.txt
│ │ │ ├── used_ids_0.20.txt
│ │ │ ├── used_ids_0.30.txt
│ │ │ ├── used_ids_0.40.txt
│ │ │ ├── used_ids_0.50.txt
│ │ │ ├── used_ids_0.60.txt
│ │ │ ├── used_ids_0.70.txt
│ │ │ ├── used_ids_0.80.txt
│ │ │ ├── used_ids_0.90.txt
│ │ │ └── used_ids_1.00.txt
│ │ └── few_ims
│ │ │ ├── used_ims_0.10.txt
│ │ │ ├── used_ims_0.20.txt
│ │ │ ├── used_ims_0.30.txt
│ │ │ ├── used_ims_0.40.txt
│ │ │ ├── used_ims_0.50.txt
│ │ │ ├── used_ims_0.60.txt
│ │ │ ├── used_ims_0.70.txt
│ │ │ ├── used_ims_0.80.txt
│ │ │ ├── used_ims_0.90.txt
│ │ │ └── used_ims_1.00.txt
│ └── labeled
│ │ ├── few_ids
│ │ ├── used_ids_0.10.txt
│ │ ├── used_ids_0.20.txt
│ │ ├── used_ids_0.30.txt
│ │ ├── used_ids_0.40.txt
│ │ ├── used_ids_0.50.txt
│ │ ├── used_ids_0.60.txt
│ │ ├── used_ids_0.70.txt
│ │ ├── used_ids_0.80.txt
│ │ ├── used_ids_0.90.txt
│ │ └── used_ids_1.00.txt
│ │ └── few_ims
│ │ ├── used_ims_0.10.txt
│ │ ├── used_ims_0.20.txt
│ │ ├── used_ims_0.30.txt
│ │ ├── used_ims_0.40.txt
│ │ ├── used_ims_0.50.txt
│ │ ├── used_ims_0.60.txt
│ │ ├── used_ims_0.70.txt
│ │ ├── used_ims_0.80.txt
│ │ ├── used_ims_0.90.txt
│ │ └── used_ims_1.00.txt
├── duke
│ ├── few_ids
│ │ ├── used_ids_0.10.txt
│ │ ├── used_ids_0.20.txt
│ │ ├── used_ids_0.30.txt
│ │ ├── used_ids_0.40.txt
│ │ ├── used_ids_0.50.txt
│ │ ├── used_ids_0.60.txt
│ │ ├── used_ids_0.70.txt
│ │ ├── used_ids_0.80.txt
│ │ ├── used_ids_0.90.txt
│ │ └── used_ids_1.00.txt
│ └── few_ims
│ │ ├── used_ims_0.10.txt
│ │ ├── used_ims_0.20.txt
│ │ ├── used_ims_0.30.txt
│ │ ├── used_ims_0.40.txt
│ │ ├── used_ims_0.50.txt
│ │ ├── used_ims_0.60.txt
│ │ ├── used_ims_0.70.txt
│ │ ├── used_ims_0.80.txt
│ │ ├── used_ims_0.90.txt
│ │ └── used_ims_1.00.txt
├── market1501
│ ├── few_ids
│ │ ├── used_ids_0.10.txt
│ │ ├── used_ids_0.20.txt
│ │ ├── used_ids_0.30.txt
│ │ ├── used_ids_0.40.txt
│ │ ├── used_ids_0.50.txt
│ │ ├── used_ids_0.60.txt
│ │ ├── used_ids_0.70.txt
│ │ ├── used_ids_0.80.txt
│ │ ├── used_ids_0.90.txt
│ │ └── used_ids_1.00.txt
│ └── few_ims
│ │ ├── used_ims_0.10.txt
│ │ ├── used_ims_0.20.txt
│ │ ├── used_ims_0.30.txt
│ │ ├── used_ims_0.40.txt
│ │ ├── used_ims_0.50.txt
│ │ ├── used_ims_0.60.txt
│ │ ├── used_ims_0.70.txt
│ │ ├── used_ims_0.80.txt
│ │ ├── used_ims_0.90.txt
│ │ └── used_ims_1.00.txt
└── msmt17
│ ├── few_ids
│ ├── used_ids_0.10.txt
│ ├── used_ids_0.20.txt
│ ├── used_ids_0.30.txt
│ ├── used_ids_0.40.txt
│ ├── used_ids_0.50.txt
│ ├── used_ids_0.60.txt
│ ├── used_ids_0.70.txt
│ ├── used_ids_0.80.txt
│ ├── used_ids_0.90.txt
│ └── used_ids_1.00.txt
│ └── few_ims
│ ├── used_ims_0.10.txt
│ ├── used_ims_0.20.txt
│ ├── used_ims_0.30.txt
│ ├── used_ims_0.40.txt
│ ├── used_ims_0.50.txt
│ ├── used_ims_0.60.txt
│ ├── used_ims_0.70.txt
│ ├── used_ims_0.80.txt
│ ├── used_ims_0.90.txt
│ └── used_ims_1.00.txt
├── demo
├── README.md
├── demo.py
├── plot_roc_with_pickle.py
├── predictor.py
└── visualize_result.py
├── docs
├── GETTING_STARTED.md
├── INSTALL.md
├── MODEL_ZOO.md
└── requirements
├── fastreid
├── __init__.py
├── config
│ ├── __init__.py
│ ├── config.py
│ └── defaults.py
├── data
│ ├── __init__.py
│ ├── build.py
│ ├── common.py
│ ├── data_utils.py
│ ├── datasets
│ │ ├── AirportALERT.py
│ │ ├── __init__.py
│ │ ├── bases.py
│ │ ├── caviara.py
│ │ ├── cmdm.py
│ │ ├── cuhk03.py
│ │ ├── cuhk_sysu.py
│ │ ├── dukemtmcreid.py
│ │ ├── iLIDS.py
│ │ ├── lpw.py
│ │ ├── lup.py
│ │ ├── market1501.py
│ │ ├── msmt17.py
│ │ ├── pes3d.py
│ │ ├── pku.py
│ │ ├── prai.py
│ │ ├── sensereid.py
│ │ ├── shinpuhkan.py
│ │ ├── sysu_mm.py
│ │ ├── thermalworld.py
│ │ ├── vehicleid.py
│ │ ├── veri.py
│ │ ├── veriwild.py
│ │ ├── viper.py
│ │ └── wildtracker.py
│ ├── samplers
│ │ ├── __init__.py
│ │ ├── data_sampler.py
│ │ └── triplet_sampler.py
│ └── transforms
│ │ ├── __init__.py
│ │ ├── autoaugment.py
│ │ ├── build.py
│ │ ├── functional.py
│ │ └── transforms.py
├── engine
│ ├── __init__.py
│ ├── defaults.py
│ ├── hooks.py
│ ├── launch.py
│ └── train_loop.py
├── evaluation
│ ├── __init__.py
│ ├── evaluator.py
│ ├── query_expansion.py
│ ├── rank.py
│ ├── rank_cylib
│ │ ├── Makefile
│ │ ├── __init__.py
│ │ ├── rank_cy.pyx
│ │ ├── roc_cy.pyx
│ │ ├── setup.py
│ │ └── test_cython.py
│ ├── reid_evaluation.py
│ ├── rerank.py
│ ├── roc.py
│ └── testing.py
├── layers
│ ├── __init__.py
│ ├── activation.py
│ ├── am_softmax.py
│ ├── arc_softmax.py
│ ├── batch_drop.py
│ ├── batch_norm.py
│ ├── circle_softmax.py
│ ├── context_block.py
│ ├── frn.py
│ ├── gather_layer.py
│ ├── non_local.py
│ ├── pooling.py
│ ├── se_layer.py
│ └── splat.py
├── modeling
│ ├── __init__.py
│ ├── backbones
│ │ ├── __init__.py
│ │ ├── build.py
│ │ ├── osnet.py
│ │ ├── regnet
│ │ │ ├── __init__.py
│ │ │ ├── config.py
│ │ │ ├── effnet.py
│ │ │ ├── effnet
│ │ │ │ ├── EN-B0_dds_8gpu.yaml
│ │ │ │ ├── EN-B1_dds_8gpu.yaml
│ │ │ │ ├── EN-B2_dds_8gpu.yaml
│ │ │ │ ├── EN-B3_dds_8gpu.yaml
│ │ │ │ ├── EN-B4_dds_8gpu.yaml
│ │ │ │ └── EN-B5_dds_8gpu.yaml
│ │ │ ├── regnet.py
│ │ │ ├── regnetx
│ │ │ │ ├── RegNetX-1.6GF_dds_8gpu.yaml
│ │ │ │ ├── RegNetX-12GF_dds_8gpu.yaml
│ │ │ │ ├── RegNetX-16GF_dds_8gpu.yaml
│ │ │ │ ├── RegNetX-200MF_dds_8gpu.yaml
│ │ │ │ ├── RegNetX-3.2GF_dds_8gpu.yaml
│ │ │ │ ├── RegNetX-32GF_dds_8gpu.yaml
│ │ │ │ ├── RegNetX-4.0GF_dds_8gpu.yaml
│ │ │ │ ├── RegNetX-400MF_dds_8gpu.yaml
│ │ │ │ ├── RegNetX-6.4GF_dds_8gpu.yaml
│ │ │ │ ├── RegNetX-600MF_dds_8gpu.yaml
│ │ │ │ ├── RegNetX-8.0GF_dds_8gpu.yaml
│ │ │ │ └── RegNetX-800MF_dds_8gpu.yaml
│ │ │ └── regnety
│ │ │ │ ├── RegNetY-1.6GF_dds_8gpu.yaml
│ │ │ │ ├── RegNetY-12GF_dds_8gpu.yaml
│ │ │ │ ├── RegNetY-16GF_dds_8gpu.yaml
│ │ │ │ ├── RegNetY-200MF_dds_8gpu.yaml
│ │ │ │ ├── RegNetY-3.2GF_dds_8gpu.yaml
│ │ │ │ ├── RegNetY-32GF_dds_8gpu.yaml
│ │ │ │ ├── RegNetY-4.0GF_dds_8gpu.yaml
│ │ │ │ ├── RegNetY-400MF_dds_8gpu.yaml
│ │ │ │ ├── RegNetY-6.4GF_dds_8gpu.yaml
│ │ │ │ ├── RegNetY-600MF_dds_8gpu.yaml
│ │ │ │ ├── RegNetY-8.0GF_dds_8gpu.yaml
│ │ │ │ └── RegNetY-800MF_dds_8gpu.yaml
│ │ ├── resnest.py
│ │ ├── resnet.py
│ │ └── resnext.py
│ ├── heads
│ │ ├── __init__.py
│ │ ├── attr_head.py
│ │ ├── build.py
│ │ └── embedding_head.py
│ ├── losses
│ │ ├── __init__.py
│ │ ├── circle_loss.py
│ │ ├── cross_entroy_loss.py
│ │ ├── focal_loss.py
│ │ ├── smooth_ap.py
│ │ ├── triplet_loss.py
│ │ └── utils.py
│ └── meta_arch
│ │ ├── __init__.py
│ │ ├── baseline.py
│ │ ├── build.py
│ │ └── mgn.py
├── solver
│ ├── __init__.py
│ ├── build.py
│ ├── lr_scheduler.py
│ └── optim
│ │ ├── __init__.py
│ │ ├── adam.py
│ │ ├── lamb.py
│ │ ├── sgd.py
│ │ └── swa.py
└── utils
│ ├── __init__.py
│ ├── checkpoint.py
│ ├── collect_env.py
│ ├── comm.py
│ ├── env.py
│ ├── events.py
│ ├── file_io.py
│ ├── history_buffer.py
│ ├── logger.py
│ ├── precision_bn.py
│ ├── registry.py
│ ├── summary.py
│ ├── timer.py
│ ├── visualizer.py
│ └── weight_init.py
├── projects
├── Cross-domain-reid
│ └── README.md
├── DistillReID
│ ├── README.md
│ ├── configs
│ │ ├── Base-bot-kd.yml
│ │ ├── Base-sbs-kd.yml
│ │ └── DukeMTMC
│ │ │ ├── KD-bot101ibn-bot18ibn.yml
│ │ │ ├── KD-bot101ibn-bot50ibn.yml
│ │ │ ├── KD-bot50ibn-bot18ibn.yml
│ │ │ ├── KD-sbs101ibn-sbs18ibn.yml
│ │ │ ├── KD-sbs101ibn-sbs50ibn.yml
│ │ │ ├── KD-sbs50ibn-sbs18ibn.yml
│ │ │ ├── bot101ibn.yml
│ │ │ ├── bot18ibn.yml
│ │ │ ├── bot50ibn.yml
│ │ │ ├── sbs101ibn.yml
│ │ │ ├── sbs18ibn.yml
│ │ │ └── sbs50ibn.yml
│ ├── kdreid
│ │ ├── __init__.py
│ │ ├── config.py
│ │ ├── kd_trainer.py
│ │ └── modeling
│ │ │ ├── __init__.py
│ │ │ └── backbones
│ │ │ ├── __init__.py
│ │ │ └── shufflenetv2
│ │ │ ├── __init__.py
│ │ │ ├── blocks.py
│ │ │ └── network.py
│ └── train_net.py
├── HAA
│ └── Readme.md
├── HPOReID
│ ├── README.md
│ ├── configs
│ │ └── baseline.yml
│ ├── hporeid
│ │ ├── __init__.py
│ │ └── tune_hooks.py
│ └── train_hpo.py
├── PartialReID
│ ├── README.md
│ ├── configs
│ │ └── partial_market.yml
│ ├── partialreid
│ │ ├── __init__.py
│ │ ├── config.py
│ │ ├── dsr_distance.py
│ │ ├── dsr_evaluation.py
│ │ ├── dsr_head.py
│ │ ├── partial_dataset.py
│ │ └── partialbaseline.py
│ └── train_net.py
├── README.md
└── attribute_recognition
│ ├── README.md
│ ├── attribute_baseline
│ ├── __init__.py
│ ├── attr_baseline.py
│ ├── attr_evaluation.py
│ ├── attr_trainer.py
│ ├── bce_loss.py
│ ├── common_attr.py
│ ├── config.py
│ ├── data_build.py
│ └── datasets
│ │ ├── __init__.py
│ │ ├── bases.py
│ │ └── pa100k.py
│ ├── configs
│ ├── Base-attribute.yml
│ └── pa100.yml
│ └── train_net.py
├── tests
├── __init__.py
├── dataset_test.py
├── feature_align.py
├── interp_test.py
├── lr_scheduler_test.py
├── model_test.py
└── sampler_test.py
└── tools
├── deploy
├── Caffe
│ ├── ReadMe.md
│ ├── __init__.py
│ ├── caffe.proto
│ ├── caffe_lmdb.py
│ ├── caffe_net.py
│ ├── caffe_pb2.py
│ ├── layer_param.py
│ └── net.py
├── README.md
├── caffe_export.py
├── caffe_inference.py
├── onnx_export.py
├── onnx_inference.py
├── pytorch_to_caffe.py
├── test_data
│ ├── 0022_c6s1_002976_01.jpg
│ ├── 0027_c2s2_091032_02.jpg
│ ├── 0032_c6s1_002851_01.jpg
│ ├── 0048_c1s1_005351_01.jpg
│ └── 0065_c6s1_009501_02.jpg
├── trt_export.py
└── trt_inference.py
└── train_net.py
/LUP-NL/README.md:
--------------------------------------------------------------------------------
1 | # The Process to build LUPerson-NL
2 |
3 | All the videos' YouTube key can be found at [vnames.txt](https://drive.google.com/file/d/19XPcO61QGrcNcqYE1pRZ1Hk3Z4CNu-6X/view?usp=sharing)
4 |
5 | All detection results can be found at [dets.zip](https://drive.google.com/file/d/1-bFKMRglmD_e3wdtq4jlpjX3N3xGo2d2/view?usp=sharing)
6 |
7 | **!! The following scripts are not well tested, you may fail to download some videos, but the scripts provide the main procedure !!**.
8 |
9 | ## Download the raw videos
10 | ```
11 | python download.py -f ${YOUR_VIDEO_NAME_FILE_DIR}/vname.txt -s ${YOUR_VIDEO_DIR}
12 | ```
13 | [youtube-dl](https://github.com/ytdl-org/youtube-dl) is needed.
14 |
15 | ## Extract images from raw videos and their detections
16 | ```
17 | python extract.py -v ${YOUR_VIDEO_DIR} -d ${DETECTION_DIR} -s ${SAVE_DIR}
18 | ```
19 |
20 | ## Convert extracted images to lmdb data
21 | ```
22 | python convert_lmdb.py
23 | ```
24 |
25 | # You can also download our processed LUPerson-NL from [BaiDuDisk](https://pan.baidu.com/s/1sNV62vxm2VtgkVa7V4VmIA) code:plnl
26 |
--------------------------------------------------------------------------------
/LUP-NL/download.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding: utf-8 -*-
3 | # @Date : 2022-03-20 13:30:30
4 | # @Author : Dengpan Fu (fdpan@mail.ustc.edu.cn)
5 |
6 | import os
7 | import numpy as np
8 | import argparse
9 | from tqdm import tqdm
10 |
11 |
12 | def download_one_video(vid, save_dir, save_name=None):
13 | url = "https://www.youtube.com/watch?v=" + vid
14 | if save_name is None:
15 | save_name = vid
16 | fpath = os.path.join(save_dir, save_name + '".%(ext)s"')
17 | if os.path.exists(fpath.replace('".%(ext)s"', '.mp4')):
18 | return
19 | cmd = 'youtube-dl -o {:s} -f "bestvideo[ext=mp4][height<=?720][filesize<=500M]/best[height<=?720][filesize<=500M]" {:s}'.format(fpath, url)
20 | os.system(cmd)
21 |
22 |
23 | def parse_args():
24 | """ Parse input arguments """
25 | parser = argparse.ArgumentParser(description='download LUP-NL raw videos')
26 | parser.add_argument('-f', '--vid_name_file', type=str, default='vname.txt')
27 | parser.add_argument('-s', '--save_dir', type=str, default='videos')
28 | args = parser.parse_args()
29 | return args
30 |
31 |
32 | if __name__ == '__main__':
33 | args = parse_args()
34 | if not os.path.isfile(args.vid_name_file):
35 | raise IOError(f'video name records file: {args.vid_name_file} does not exist')
36 | with open(args.vid_name_file, 'r') as f:
37 | lines = f.readlines()
38 | lines = [line.strip() for line in lines]
39 | for item in tqdm(lines):
40 | country, city, vid = item.split('+')
41 | save_dir = os.path.join(args.save_dir, country, city)
42 | if not os.path.exists(save_dir):
43 | os.makedirs(save_dir)
44 | download_one_video(vid, save_dir, save_name=item)
45 |
46 |
--------------------------------------------------------------------------------
/PNL/README.md:
--------------------------------------------------------------------------------
1 | # Person Re-Identification Pre-training with PNL on LUPerson-NL
2 |
3 | ## Train
4 |
5 | ```shell
6 | bash scripts/run_pnl.sh
7 | ```
--------------------------------------------------------------------------------
/PNL/libs/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
2 |
--------------------------------------------------------------------------------
/PNL/libs/supcont_builder.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding: utf-8 -*-
3 | # @Date : 2021-01-31 20:36:12
4 | # @Author : Dengpan Fu (fdpan@mail.ustc.edu.cn)
5 |
6 | import os
7 | import numpy as np
8 |
9 | import torch
10 | import torch.nn as nn
11 |
12 |
13 | class SupCont(nn.Module):
14 | def __init__(self, base_encoder, dim=128, mlp=True, has_bn=True):
15 | """
16 | dim: feature dimension (default: 128)
17 | """
18 | super(SupCont, self).__init__()
19 |
20 | # create the encoders
21 | self.encoder = base_encoder(num_classes=dim)
22 | self.mlp = mlp
23 |
24 | if mlp:
25 | dim_mlp = self.encoder.fc.weight.shape[1]
26 | if has_bn:
27 | self.encoder.fc = nn.Sequential(nn.Linear(dim_mlp, dim_mlp),
28 | nn.BatchNorm2d(dim_mlp), nn.ReLU(), self.encoder.fc)
29 | else:
30 | self.encoder.fc = nn.Sequential(nn.Linear(dim_mlp, dim_mlp),
31 | nn.ReLU(), self.encoder.fc)
32 |
33 | def forward(self, im_q=None, im_k=None, label=None):
34 | """
35 | Input:
36 | im_q: a batch of query images
37 | im_k: a batch of key images
38 | Output:
39 | encoded q and k
40 | """
41 | if not self.training:
42 | return nn.functional.normalize(self.encoder(im_q), dim=1)
43 |
44 | q = self.encoder(im_q) # queries: NxC
45 | q = nn.functional.normalize(q, dim=1)
46 | k = self.encoder(im_k) # keys: NxC
47 | k = nn.functional.normalize(k, dim=1)
48 |
49 | all_q = concat_all_gather(q)
50 | all_k = concat_all_gather(k)
51 | all_qk = torch.cat([all_q.unsqueeze(1), all_k.unsqueeze(1)], dim=1)
52 | all_label = concat_all_gather(label)
53 |
54 | return all_qk, all_label
55 |
56 |
57 | # utils
58 | def concat_all_gather(tensor):
59 | """
60 | Performs all_gather operation on the provided tensors.
61 | *** Warning ***: torch.distributed.all_gather has no gradient.
62 | """
63 | tensors_gather = [torch.ones_like(tensor)
64 | for _ in range(torch.distributed.get_world_size())]
65 | torch.distributed.all_gather(tensors_gather, tensor, async_op=False)
66 |
67 | # need to do this to restore propagation of the gradients
68 | rank = torch.distributed.get_rank()
69 | tensors_gather[rank] = tensor
70 |
71 | output = torch.cat(tensors_gather, dim=0)
72 | return output
73 |
--------------------------------------------------------------------------------
/PNL/scripts/run_moco.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | DATA_DIR="/home/dengpanfu/data"
4 | EXP_DIR="/home/dengpanfu/project/lupnl/moco"
5 |
6 | CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python lup_moco.py \
7 | --data_path "${DATA_DIR}/lupnl_lmdb/lmdb" \
8 | --info_path "${DATA_DIR}/lupnl_lmdb/keys.pkl" \
9 | --eval_path "${DATA_DIR}/reid" \
10 | --eval_name "market" \
11 | --snap_dir "${EXP_DIR}/snapshots" \
12 | --log_dir "${EXP_DIR}/logs" \
13 | -a "resnet50" \
14 | --lr 0.3 \
15 | --optimizer "SGD" \
16 | -j 32 \
17 | --batch-size 2560 \
18 | --dist-url 'tcp://localhost:13701' \
19 | --multiprocessing-distributed 1 \
20 | --world-size 1 \
21 | --rank 0 \
22 | --T 0.07 \
23 | --aug_type 'ori-cj+sre' \
24 | --cos 1 \
25 | --mix 1 \
26 | --auto_resume 1 \
27 | --save_freq 20 \
28 | --print-freq 10 \
29 | --epochs 200 \
30 | --mean_type "lmdb_200_20" \
31 | --moco_dim 128 \
32 | --eval_freq -1
--------------------------------------------------------------------------------
/PNL/scripts/run_pnl.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | DATA_DIR="/home/dengpanfu/data"
4 | EXP_DIR="/home/dengpanfu/project/lupnl/pnl"
5 |
6 | CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python lup_pnl.py \
7 | --data_path "${DATA_DIR}/lupnl_lmdb/lmdb" \
8 | --info_path "${DATA_DIR}/lupnl_lmdb/keys.pkl" \
9 | --eval_path "${DATA_DIR}/reid" \
10 | --eval_name "market" \
11 | --snap_dir "${EXP_DIR}/snapshots" \
12 | --log_dir "${EXP_DIR}/logs" \
13 | -a "resnet50" \
14 | --lr 0.4 \
15 | -j 32 \
16 | --batch-size 1536 \
17 | --multiprocessing-distributed 1 \
18 | --dist-url "tcp://localhost:23791" \
19 | --world-size 1 \
20 | --rank 0 \
21 | --mix 1 \
22 | --auto_resume 1 \
23 | --save_freq 10 \
24 | --print-freq 10 \
25 | --eval_freq 3 \
26 | --schedule "40,80" \
27 | --mean_type "lmdb_200_20" \
28 | --aug_type "ori-cj+sre" \
29 | --optimizer "SGD" \
30 | --epochs 90 \
31 | --cos 0 \
32 | --moco_dim 128 \
33 | --cls_dim 256 \
34 | --T 0.07 \
35 | --moco_k 65536 \
36 | --alpha 0.5 \
37 | --pseudo_th 0.8 \
38 | --start_clean_epoch 11 \
39 | --start_supcont_epoch 15
--------------------------------------------------------------------------------
/PNL/scripts/run_simclr.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | DATA_DIR="/home/dengpanfu/data"
4 | EXP_DIR="/home/dengpanfu/project/lupnl/simclr"
5 |
6 | CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python lup_simclr.py \
7 | --data_path "${DATA_DIR}/lupnl_lmdb/lmdb" \
8 | --info_path "${DATA_DIR}/lupnl_lmdb/keys.pkl" \
9 | --eval_path "${DATA_DIR}/reid" \
10 | --eval_name "market" \
11 | --snap_dir "${EXP_DIR}/snapshots" \
12 | --log_dir "${EXP_DIR}/logs" \
13 | -a "resnet50" \
14 | --lr 0.3 \
15 | -j 32 \
16 | --batch-size 2048 \
17 | --optimizer "LARS" \
18 | --dist-url 'tcp://localhost:13701' \
19 | --multiprocessing-distributed 1 \
20 | --world-size 1 \
21 | --rank 0 \
22 | --T 0.1 \
23 | --aug_type 'ori-cj+sre' \
24 | --cos 1 \
25 | --mix 1 \
26 | --auto_resume 1 \
27 | --save_freq 20 \
28 | --print-freq 10 \
29 | --epochs 200 \
30 | --mean_type "lmdb_200_20" \
31 | --eval_freq -1 \
32 | --warmup_epochs 10
--------------------------------------------------------------------------------
/PNL/scripts/run_supcont.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | DATA_DIR="/home/dengpanfu/data"
4 | EXP_DIR="/home/dengpanfu/project/lupnl/supcont"
5 |
6 | CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python lup_supcont.py \
7 | --data_path "${DATA_DIR}/lupnl_lmdb/lmdb" \
8 | --info_path "${DATA_DIR}/lupnl_lmdb/keys.pkl" \
9 | --eval_path "${DATA_DIR}/reid" \
10 | --eval_name "market" \
11 | --snap_dir "${EXP_DIR}/snapshots" \
12 | --log_dir "${EXP_DIR}/logs" \
13 | -a resnet50 \
14 | --embed_dim 2048 \
15 | --lr 0.1 \
16 | --optimizer 'LARS' \
17 | -j 32 \
18 | --batch-size 2048 \
19 | --optimizer "LARS" \
20 | --dist-url 'tcp://localhost:13701' \
21 | --multiprocessing-distributed 1 \
22 | --world-size 1 \
23 | --rank 0 \
24 | --mix 1 \
25 | --auto_resume 1 \
26 | --save_freq 20 \
27 | --print-freq 10 \
28 | --epochs 200 \
29 | --mean_type "lmdb_200_20" \
30 | --eval_freq -1 \
31 | --cos 1
--------------------------------------------------------------------------------
/fast-reid/configs/Base-AGW.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "Base-bagtricks.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | WITH_NL: True
6 |
7 | HEADS:
8 | POOL_LAYER: "gempool"
9 |
10 | LOSSES:
11 | NAME: ("CrossEntropyLoss", "TripletLoss")
12 | CE:
13 | EPSILON: 0.1
14 | SCALE: 1.0
15 |
16 | TRI:
17 | MARGIN: 0.0
18 | HARD_MINING: False
19 | SCALE: 1.0
20 |
--------------------------------------------------------------------------------
/fast-reid/configs/Base-MGN.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "Base-Strongerbaseline.yml"
2 |
3 | MODEL:
4 | META_ARCHITECTURE: 'MGN'
5 |
6 | FREEZE_LAYERS: ["backbone", "b1", "b2", "b3",]
7 |
8 | BACKBONE:
9 | WITH_NL: False
10 |
11 | HEADS:
12 | EMBEDDING_DIM: 256
13 |
14 | LOSSES:
15 | NAME: ("CrossEntropyLoss", "TripletLoss",)
16 | CE:
17 | EPSILON: 0.1
18 | SCALE: 1.0
19 |
20 | TRI:
21 | MARGIN: 0.0
22 | HARD_MINING: True
23 | NORM_FEAT: False
24 | SCALE: 1.0
25 |
26 |
--------------------------------------------------------------------------------
/fast-reid/configs/Base-Strongerbaseline.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "Base-bagtricks.yml"
2 |
3 | MODEL:
4 | FREEZE_LAYERS: ["backbone"]
5 |
6 | BACKBONE:
7 | WITH_NL: True
8 |
9 | HEADS:
10 | NECK_FEAT: "after"
11 | POOL_LAYER: "gempoolP"
12 | CLS_LAYER: "circleSoftmax"
13 | SCALE: 64
14 | MARGIN: 0.35
15 |
16 | LOSSES:
17 | NAME: ("CrossEntropyLoss", "TripletLoss",)
18 | CE:
19 | EPSILON: 0.1
20 | SCALE: 1.0
21 | TRI:
22 | MARGIN: 0.0
23 | HARD_MINING: True
24 | NORM_FEAT: False
25 | SCALE: 1.0
26 |
27 | INPUT:
28 | SIZE_TRAIN: [384, 128]
29 | SIZE_TEST: [384, 128]
30 | DO_AUTOAUG: True
31 |
32 | DATALOADER:
33 | NUM_INSTANCE: 16
34 |
35 | SOLVER:
36 | OPT: "Adam"
37 | MAX_ITER: 60
38 | BASE_LR: 0.00035
39 | BIAS_LR_FACTOR: 1.
40 | WEIGHT_DECAY: 0.0005
41 | WEIGHT_DECAY_BIAS: 0.0005
42 | IMS_PER_BATCH: 64
43 |
44 | SCHED: "WarmupCosineAnnealingLR"
45 | DELAY_ITERS: 30
46 | ETA_MIN_LR: 0.00000077
47 |
48 | WARMUP_FACTOR: 0.01
49 | WARMUP_ITERS: 10
50 | FREEZE_ITERS: 10
51 |
52 | CHECKPOINT_PERIOD: 30
53 |
54 | TEST:
55 | EVAL_PERIOD: 30
56 | IMS_PER_BATCH: 128
57 |
58 | CUDNN_BENCHMARK: True
59 |
60 |
--------------------------------------------------------------------------------
/fast-reid/configs/Base-bagtricks.yml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | META_ARCHITECTURE: "Baseline"
3 |
4 | BACKBONE:
5 | NAME: "build_resnet_backbone"
6 | NORM: "BN"
7 | DEPTH: "50x"
8 | LAST_STRIDE: 1
9 | FEAT_DIM: 2048
10 | WITH_IBN: False
11 | PRETRAIN: True
12 | PRETRAIN_PATH: "/export/home/lxy/.cache/torch/checkpoints/resnet50-19c8e357.pth"
13 |
14 | HEADS:
15 | NAME: "EmbeddingHead"
16 | NORM: "BN"
17 | WITH_BNNECK: True
18 | POOL_LAYER: "avgpool"
19 | NECK_FEAT: "before"
20 | CLS_LAYER: "linear"
21 |
22 | LOSSES:
23 | NAME: ("CrossEntropyLoss", "TripletLoss",)
24 |
25 | CE:
26 | EPSILON: 0.1
27 | SCALE: 1.
28 |
29 | TRI:
30 | MARGIN: 0.3
31 | HARD_MINING: True
32 | NORM_FEAT: False
33 | SCALE: 1.
34 |
35 | INPUT:
36 | SIZE_TRAIN: [256, 128]
37 | SIZE_TEST: [256, 128]
38 | REA:
39 | ENABLED: True
40 | PROB: 0.5
41 | MEAN: [123.675, 116.28, 103.53]
42 | DO_PAD: True
43 |
44 | DATALOADER:
45 | PK_SAMPLER: True
46 | NAIVE_WAY: True
47 | NUM_INSTANCE: 4
48 | NUM_WORKERS: 8
49 |
50 | SOLVER:
51 | OPT: "Adam"
52 | MAX_ITER: 120
53 | BASE_LR: 0.00035
54 | BIAS_LR_FACTOR: 2.
55 | WEIGHT_DECAY: 0.0005
56 | WEIGHT_DECAY_BIAS: 0.0005
57 | IMS_PER_BATCH: 64
58 |
59 | SCHED: "WarmupMultiStepLR"
60 | STEPS: [40, 90]
61 | GAMMA: 0.1
62 |
63 | WARMUP_FACTOR: 0.01
64 | WARMUP_ITERS: 10
65 |
66 | CHECKPOINT_PERIOD: 60
67 |
68 | TEST:
69 | EVAL_PERIOD: 30
70 | IMS_PER_BATCH: 128
71 |
72 | CUDNN_BENCHMARK: True
73 |
74 |
--------------------------------------------------------------------------------
/fast-reid/configs/CMDM/mgn_R101.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-MGN.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | WITH_IBN: False
6 | EXTRA_BN: False
7 | DEPTH: "101x"
8 | PIXEL_MEAN: [123.675, 116.280, 103.530]
9 | PIXEL_STD: [58.395, 57.120, 57.375]
10 | INPUT:
11 | REA:
12 | MEAN: [0.0, 0.0, 0.0]
13 | DO_AUTOAUG: True
14 | SOLVER:
15 | HEADS_LR_FACTOR: 1.0
16 | BACKBONE_BN_LR_FACTOR: 1.0
17 | CHECKPOINT_PERIOD: -1
18 |
19 | DATASETS:
20 | NAMES: ("CMDM",)
21 | TESTS: ("CMDM",)
22 | KWARGS: 'data_name:duke+split_mode:id+split_ratio:1.0'
23 | ROOT: "/home/dengpanfu/data"
24 |
25 | OUTPUT_DIR: "logs/cmdm/mgn_R101"
26 |
--------------------------------------------------------------------------------
/fast-reid/configs/CMDM/mgn_R101_moco.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-MGN.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | WITH_IBN: False
6 | EXTRA_BN: True
7 | DEPTH: "101x"
8 | PIXEL_MEAN: [89.896, 79.200, 80.073]
9 | PIXEL_STD: [63.872, 64.305, 63.839]
10 | INPUT:
11 | REA:
12 | MEAN: [0.0, 0.0, 0.0]
13 | DO_AUTOAUG: False
14 | SOLVER:
15 | HEADS_LR_FACTOR: 1.0
16 | BACKBONE_BN_LR_FACTOR: 1.0
17 | CHECKPOINT_PERIOD: -1
18 |
19 | DATASETS:
20 | NAMES: ("CMDM",)
21 | TESTS: ("CMDM",)
22 | KWARGS: 'data_name:duke+split_mode:id+split_ratio:1.0'
23 | ROOT: "/home/dengpanfu/data"
24 |
25 | OUTPUT_DIR: "logs/cmdm/mgn_R101_moco"
26 |
--------------------------------------------------------------------------------
/fast-reid/configs/CMDM/mgn_R50.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-MGN.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | WITH_IBN: False
6 | EXTRA_BN: False
7 | PIXEL_MEAN: [123.675, 116.280, 103.530]
8 | PIXEL_STD: [58.395, 57.120, 57.375]
9 | INPUT:
10 | REA:
11 | MEAN: [0.0, 0.0, 0.0]
12 | DO_AUTOAUG: False
13 | SOLVER:
14 | HEADS_LR_FACTOR: 1.0
15 | BACKBONE_BN_LR_FACTOR: 1.0
16 | CHECKPOINT_PERIOD: -1
17 |
18 | DATASETS:
19 | NAMES: ("CMDM",)
20 | TESTS: ("CMDM",)
21 | KWARGS: 'data_name:duke+split_mode:id+split_ratio:1.0'
22 | ROOT: "/home/dengpanfu/data"
23 |
24 | TEST:
25 | EVAL_PERIOD: 60
26 |
27 | OUTPUT_DIR: "logs/cmdm/mgn_IN_sup"
28 |
--------------------------------------------------------------------------------
/fast-reid/configs/CMDM/mgn_R50_cmdm.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-MGN.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | WITH_IBN: False
6 | EXTRA_BN: True
7 | PIXEL_MEAN: [83.022, 77.974, 80.642]
8 | PIXEL_STD: [66.372, 63.468, 60.974]
9 | INPUT:
10 | REA:
11 | MEAN: [0.0, 0.0, 0.0]
12 | DO_AUTOAUG: False
13 | SOLVER:
14 | HEADS_LR_FACTOR: 1.0
15 | BACKBONE_BN_LR_FACTOR: 1.0
16 | CHECKPOINT_PERIOD: -1
17 |
18 | DATASETS:
19 | NAMES: ("CMDM",)
20 | TESTS: ("CMDM",)
21 | KWARGS: 'data_name:duke+split_mode:id+split_ratio:1.0'
22 | ROOT: "/home/dengpanfu/data"
23 |
24 | OUTPUT_DIR: "logs/cmdm/mgn_R50_cmdm_moco"
25 |
--------------------------------------------------------------------------------
/fast-reid/configs/CMDM/mgn_R50_img_moco.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-MGN.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | WITH_IBN: False
6 | EXTRA_BN: True
7 | PIXEL_MEAN: [123.675, 116.280, 103.530]
8 | PIXEL_STD: [58.395, 57.120, 57.375]
9 | INPUT:
10 | REA:
11 | MEAN: [0.0, 0.0, 0.0]
12 | DO_AUTOAUG: False
13 | SOLVER:
14 | HEADS_LR_FACTOR: 1.0
15 | BACKBONE_BN_LR_FACTOR: 1.0
16 | CHECKPOINT_PERIOD: -1
17 |
18 | DATASETS:
19 | NAMES: ("CMDM",)
20 | TESTS: ("CMDM",)
21 | KWARGS: 'data_name:duke+split_mode:id+split_ratio:1.0'
22 | ROOT: "/home/dengpanfu/data"
23 |
24 | TEST:
25 | EVAL_PERIOD: 60
26 |
27 | OUTPUT_DIR: "logs/cmdm/mgn_IN_unsup"
--------------------------------------------------------------------------------
/fast-reid/configs/CMDM/mgn_R50_lup200.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-MGN.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | WITH_IBN: False
6 | EXTRA_BN: True
7 | PIXEL_MEAN: [88.026, 78.285, 79.407]
8 | PIXEL_STD: [67.142, 63.750, 63.240]
9 | INPUT:
10 | REA:
11 | MEAN: [0.0, 0.0, 0.0]
12 | DO_AUTOAUG: False
13 | SOLVER:
14 | HEADS_LR_FACTOR: 1.0
15 | BACKBONE_BN_LR_FACTOR: 1.0
16 | CHECKPOINT_PERIOD: -1
17 |
18 | DATASETS:
19 | NAMES: ("CMDM",)
20 | TESTS: ("CMDM",)
21 | KWARGS: 'data_name:duke+split_mode:id+split_ratio:1.0'
22 | ROOT: "/home/dengpanfu/data"
23 |
24 | TEST:
25 | EVAL_PERIOD: 60
26 |
27 | OUTPUT_DIR: "logs/cmdm/mgn_lup200_unsup"
28 |
--------------------------------------------------------------------------------
/fast-reid/configs/CMDM/mgn_R50_lup300.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-MGN.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | WITH_IBN: False
6 | EXTRA_BN: True
7 | PIXEL_MEAN: [88.306, 78.464, 79.560]
8 | PIXEL_STD: [67.524, 64.056, 63.546]
9 | INPUT:
10 | REA:
11 | MEAN: [0.0, 0.0, 0.0]
12 | DO_AUTOAUG: False
13 | SOLVER:
14 | HEADS_LR_FACTOR: 1.0
15 | BACKBONE_BN_LR_FACTOR: 1.0
16 | CHECKPOINT_PERIOD: -1
17 |
18 | DATASETS:
19 | NAMES: ("CMDM",)
20 | TESTS: ("CMDM",)
21 | KWARGS: 'data_name:duke+split_mode:id+split_ratio:1.0'
22 | ROOT: "/home/dengpanfu/data"
23 |
24 | TEST:
25 | EVAL_PERIOD: 60
26 |
27 | OUTPUT_DIR: "logs/cmdm/mgn_R50_moco"
28 |
--------------------------------------------------------------------------------
/fast-reid/configs/CMDM/mgn_R50_moco.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-MGN.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | WITH_IBN: False
6 | EXTRA_BN: True
7 | PIXEL_MEAN: [89.896, 79.200, 80.073]
8 | PIXEL_STD: [63.872, 64.305, 63.839]
9 | INPUT:
10 | REA:
11 | MEAN: [0.0, 0.0, 0.0]
12 | DO_AUTOAUG: False
13 | SOLVER:
14 | HEADS_LR_FACTOR: 1.0
15 | BACKBONE_BN_LR_FACTOR: 1.0
16 | CHECKPOINT_PERIOD: -1
17 |
18 | DATASETS:
19 | NAMES: ("CMDM",)
20 | TESTS: ("CMDM",)
21 | KWARGS: 'data_name:duke+split_mode:id+split_ratio:1.0'
22 | ROOT: "/home/dengpanfu/data"
23 |
24 | TEST:
25 | EVAL_PERIOD: 60
26 |
27 | OUTPUT_DIR: "logs/cmdm/mgn_lup_unsup"
28 |
--------------------------------------------------------------------------------
/fast-reid/configs/DukeMTMC/AGW_R101-ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-AGW.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | DEPTH: "101x"
6 | WITH_IBN: True
7 |
8 | DATASETS:
9 | NAMES: ("DukeMTMC",)
10 | TESTS: ("DukeMTMC",)
11 |
12 | OUTPUT_DIR: "logs/dukemtmc/agw_R101-ibn"
13 |
--------------------------------------------------------------------------------
/fast-reid/configs/DukeMTMC/AGW_R50-ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-AGW.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | WITH_IBN: True
6 |
7 | DATASETS:
8 | NAMES: ("DukeMTMC",)
9 | TESTS: ("DukeMTMC",)
10 |
11 | OUTPUT_DIR: "logs/dukemtmc/agw_R50-ibn"
12 |
--------------------------------------------------------------------------------
/fast-reid/configs/DukeMTMC/AGW_R50.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-AGW.yml"
2 |
3 | DATASETS:
4 | NAMES: ("DukeMTMC",)
5 | TESTS: ("DukeMTMC",)
6 |
7 | OUTPUT_DIR: "logs/dukemtmc/agw_R50"
8 |
--------------------------------------------------------------------------------
/fast-reid/configs/DukeMTMC/AGW_S50.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-AGW.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | NAME: "build_resnest_backbone"
6 |
7 | DATASETS:
8 | NAMES: ("DukeMTMC",)
9 | TESTS: ("DukeMTMC",)
10 |
11 | OUTPUT_DIR: "logs/dukemtmc/agw_S50"
12 |
--------------------------------------------------------------------------------
/fast-reid/configs/DukeMTMC/bagtricks_R101-ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-bagtricks.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | DEPTH: "101x"
6 | WITH_IBN: True
7 |
8 | DATASETS:
9 | NAMES: ("DukeMTMC",)
10 | TESTS: ("DukeMTMC",)
11 |
12 | OUTPUT_DIR: "logs/dukemtmc/bagtricks_R101-ibn"
13 |
--------------------------------------------------------------------------------
/fast-reid/configs/DukeMTMC/bagtricks_R50-ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-bagtricks.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | WITH_IBN: True
6 |
7 | DATASETS:
8 | NAMES: ("DukeMTMC",)
9 | TESTS: ("DukeMTMC",)
10 |
11 | OUTPUT_DIR: "logs/dukemtmc/bagtricks_R50-ibn"
12 |
--------------------------------------------------------------------------------
/fast-reid/configs/DukeMTMC/bagtricks_R50.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-bagtricks.yml"
2 |
3 | DATASETS:
4 | NAMES: ("DukeMTMC",)
5 | TESTS: ("DukeMTMC",)
6 |
7 | OUTPUT_DIR: "logs/dukemtmc/bagtricks_R50"
8 |
--------------------------------------------------------------------------------
/fast-reid/configs/DukeMTMC/bagtricks_S50.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-bagtricks.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | NAME: "build_resnest_backbone"
6 |
7 | DATASETS:
8 | NAMES: ("DukeMTMC",)
9 | TESTS: ("DukeMTMC",)
10 |
11 | OUTPUT_DIR: "logs/dukemtmc/bagtricks_S50"
12 |
--------------------------------------------------------------------------------
/fast-reid/configs/DukeMTMC/mgn_R50-ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-MGN.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | WITH_IBN: True
6 |
7 | DATASETS:
8 | NAMES: ("DukeMTMC",)
9 | TESTS: ("DukeMTMC",)
10 |
11 | OUTPUT_DIR: "logs/dukemtmc/mgn_R50-ibn"
12 |
--------------------------------------------------------------------------------
/fast-reid/configs/DukeMTMC/sbs_R101-ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-Strongerbaseline.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | DEPTH: "101x"
6 | WITH_IBN: True
7 |
8 | DATASETS:
9 | NAMES: ("DukeMTMC",)
10 | TESTS: ("DukeMTMC",)
11 |
12 | OUTPUT_DIR: "logs/dukemtmc/sbs_R101-ibn"
13 |
--------------------------------------------------------------------------------
/fast-reid/configs/DukeMTMC/sbs_R50-ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-Strongerbaseline.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | WITH_IBN: True
6 |
7 | DATASETS:
8 | NAMES: ("DukeMTMC",)
9 | TESTS: ("DukeMTMC",)
10 |
11 | OUTPUT_DIR: "logs/dukemtmc/sbs_R50-ibn"
12 |
--------------------------------------------------------------------------------
/fast-reid/configs/DukeMTMC/sbs_R50.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-Strongerbaseline.yml"
2 |
3 | DATASETS:
4 | NAMES: ("DukeMTMC",)
5 | TESTS: ("DukeMTMC",)
6 |
7 | OUTPUT_DIR: "logs/dukemtmc/sbs_R50"
8 |
--------------------------------------------------------------------------------
/fast-reid/configs/DukeMTMC/sbs_S50.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-Strongerbaseline.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | NAME: "build_resnest_backbone"
6 |
7 | DATASETS:
8 | NAMES: ("DukeMTMC",)
9 | TESTS: ("DukeMTMC",)
10 |
11 | OUTPUT_DIR: "logs/dukemtmc/sbs_S50"
12 |
--------------------------------------------------------------------------------
/fast-reid/configs/LUP/agw_R50.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-AGW.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | WITH_IBN: False
6 | EXTRA_BN: False
7 | PIXEL_MEAN: [123.675, 116.280, 103.530]
8 | PIXEL_STD: [58.395, 57.120, 57.375]
9 | INPUT:
10 | REA:
11 | MEAN: [0.0, 0.0, 0.0]
12 | SOLVER:
13 | HEADS_LR_FACTOR: 1.0
14 | BACKBONE_BN_LR_FACTOR: 1.0
15 | CHECKPOINT_PERIOD: -1
16 |
17 | DATALOADER:
18 | NUM_WORKERS: 0
19 |
20 | DATASETS:
21 | NAMES: ("CMDM",)
22 | TESTS: ("CMDM",)
23 | KWARGS: 'data_name:duke+split_mode:id+split_ratio:1.0'
24 | ROOT: "/home/dengpanfu/data"
25 |
26 | OUTPUT_DIR: "logs/lup/agw_R50"
--------------------------------------------------------------------------------
/fast-reid/configs/LUP/bot_R50.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-bagtricks.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | WITH_IBN: False
6 | EXTRA_BN: False
7 | PIXEL_MEAN: [123.675, 116.280, 103.530]
8 | PIXEL_STD: [58.395, 57.120, 57.375]
9 | HEADS:
10 | EMBEDDING_DIM: 128
11 | INPUT:
12 | REA:
13 | MEAN: [0.0, 0.0, 0.0]
14 | SOLVER:
15 | HEADS_LR_FACTOR: 1.0
16 | BACKBONE_BN_LR_FACTOR: 1.0
17 | CHECKPOINT_PERIOD: -1
18 | BASE_LR: 0.001
19 | IMS_PER_BATCH: 256
20 |
21 |
22 | DATALOADER:
23 | NUM_INSTANCE: 4
24 | NUM_WORKERS: 4
25 |
26 | DATASETS:
27 | NAMES: ("LUP",)
28 | TESTS: ("CMDM",)
29 | KWARGS: 'data_name:market+sub_name:lmdb_300_30'
30 | ROOT: "/home/dengpanfu/data"
31 | IS_LMDB: True
32 |
33 | OUTPUT_DIR: "logs/lup/agw_R50"
--------------------------------------------------------------------------------
/fast-reid/configs/LUP/mgn_R50.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-MGN.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | WITH_IBN: False
6 | EXTRA_BN: False
7 | PIXEL_MEAN: [123.675, 116.280, 103.530]
8 | PIXEL_STD: [58.395, 57.120, 57.375]
9 | INPUT:
10 | REA:
11 | MEAN: [0.0, 0.0, 0.0]
12 | SOLVER:
13 | HEADS_LR_FACTOR: 1.0
14 | BACKBONE_BN_LR_FACTOR: 1.0
15 | CHECKPOINT_PERIOD: -1
16 |
17 | DATASETS:
18 | NAMES: ("CMDM",)
19 | TESTS: ("CMDM",)
20 | KWARGS: 'data_name:duke+split_mode:id+split_ratio:1.0'
21 | ROOT: "/home/dengpanfu/data"
22 |
23 | OUTPUT_DIR: "logs/cmdm/mgn_R50"
24 |
--------------------------------------------------------------------------------
/fast-reid/configs/MSMT17/AGW_R101-ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-AGW.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | DEPTH: "101x"
6 | WITH_IBN: True
7 |
8 | DATASETS:
9 | NAMES: ("MSMT17",)
10 | TESTS: ("MSMT17",)
11 |
12 | OUTPUT_DIR: "logs/msmt17/agw_R101-ibn"
13 |
--------------------------------------------------------------------------------
/fast-reid/configs/MSMT17/AGW_R50-ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-AGW.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | WITH_IBN: True
6 |
7 | DATASETS:
8 | NAMES: ("MSMT17",)
9 | TESTS: ("MSMT17",)
10 |
11 | OUTPUT_DIR: "logs/msmt17/agw_R50-ibn"
12 |
--------------------------------------------------------------------------------
/fast-reid/configs/MSMT17/AGW_R50.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-AGW.yml"
2 |
3 | DATASETS:
4 | NAMES: ("MSMT17",)
5 | TESTS: ("MSMT17",)
6 |
7 | OUTPUT_DIR: "logs/msmt17/agw_R50"
8 |
--------------------------------------------------------------------------------
/fast-reid/configs/MSMT17/AGW_S50.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-AGW.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | NAME: "build_resnest_backbone"
6 |
7 | DATASETS:
8 | NAMES: ("MSMT17",)
9 | TESTS: ("MSMT17",)
10 |
11 | OUTPUT_DIR: "logs/msmt17/agw_S50"
12 |
--------------------------------------------------------------------------------
/fast-reid/configs/MSMT17/bagtricks_R101-ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-bagtricks.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | DEPTH: "101x"
6 | WITH_IBN: True
7 |
8 | DATASETS:
9 | NAMES: ("MSMT17",)
10 | TESTS: ("MSMT17",)
11 |
12 | OUTPUT_DIR: "logs/msmt17/bagtricks_R101-ibn"
13 |
14 |
--------------------------------------------------------------------------------
/fast-reid/configs/MSMT17/bagtricks_R50-ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-bagtricks.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | WITH_IBN: True
6 |
7 | DATASETS:
8 | NAMES: ("MSMT17",)
9 | TESTS: ("MSMT17",)
10 |
11 | OUTPUT_DIR: "logs/msmt17/bagtricks_R50-ibn"
12 |
13 |
--------------------------------------------------------------------------------
/fast-reid/configs/MSMT17/bagtricks_R50.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-bagtricks.yml"
2 |
3 | DATASETS:
4 | NAMES: ("MSMT17",)
5 | TESTS: ("MSMT17",)
6 |
7 | OUTPUT_DIR: "logs/msmt17/bagtricks_R50"
8 |
--------------------------------------------------------------------------------
/fast-reid/configs/MSMT17/bagtricks_S50.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-bagtricks.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | NAME: "build_resnest_backbone"
6 |
7 | DATASETS:
8 | NAMES: ("MSMT17",)
9 | TESTS: ("MSMT17",)
10 |
11 | OUTPUT_DIR: "logs/msmt17/bagtricks_S50"
12 |
13 |
--------------------------------------------------------------------------------
/fast-reid/configs/MSMT17/mgn_R50-ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-MGN.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | WITH_IBN: True
6 |
7 | DATASETS:
8 | NAMES: ("MSMT17",)
9 | TESTS: ("MSMT17",)
10 |
11 | OUTPUT_DIR: "logs/msmt17/mgn_R50-ibn"
12 |
--------------------------------------------------------------------------------
/fast-reid/configs/MSMT17/sbs_R101-ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-Strongerbaseline.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | DEPTH: "101x"
6 | WITH_IBN: True
7 |
8 | DATASETS:
9 | NAMES: ("MSMT17",)
10 | TESTS: ("MSMT17",)
11 |
12 | OUTPUT_DIR: "logs/msmt17/sbs_R101-ibn"
13 |
--------------------------------------------------------------------------------
/fast-reid/configs/MSMT17/sbs_R50-ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-Strongerbaseline.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | WITH_IBN: True
6 |
7 | DATASETS:
8 | NAMES: ("MSMT17",)
9 | TESTS: ("MSMT17",)
10 |
11 | OUTPUT_DIR: "logs/msmt17/sbs_R50-ibn"
12 |
--------------------------------------------------------------------------------
/fast-reid/configs/MSMT17/sbs_R50.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-Strongerbaseline.yml"
2 |
3 | DATASETS:
4 | NAMES: ("MSMT17",)
5 | TESTS: ("MSMT17",)
6 |
7 | OUTPUT_DIR: "logs/msmt17/sbs_R50"
8 |
--------------------------------------------------------------------------------
/fast-reid/configs/MSMT17/sbs_S50.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-Strongerbaseline.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | NAME: "build_resnest_backbone"
6 |
7 | DATASETS:
8 | NAMES: ("MSMT17",)
9 | TESTS: ("MSMT17",)
10 |
11 | OUTPUT_DIR: "logs/msmt17/sbs_S50"
12 |
--------------------------------------------------------------------------------
/fast-reid/configs/Market1501/AGW_R101-ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-AGW.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | DEPTH: "101x"
6 | WITH_IBN: True
7 |
8 | DATASETS:
9 | NAMES: ("Market1501",)
10 | TESTS: ("Market1501",)
11 |
12 | OUTPUT_DIR: "logs/market1501/agw_R101-ibn"
13 |
--------------------------------------------------------------------------------
/fast-reid/configs/Market1501/AGW_R50-ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-AGW.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | WITH_IBN: True
6 |
7 | DATASETS:
8 | NAMES: ("Market1501",)
9 | TESTS: ("Market1501",)
10 |
11 | OUTPUT_DIR: "logs/market1501/agw_R50-ibn"
12 |
--------------------------------------------------------------------------------
/fast-reid/configs/Market1501/AGW_R50.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-AGW.yml"
2 |
3 | DATASETS:
4 | NAMES: ("Market1501",)
5 | TESTS: ("Market1501",)
6 |
7 | OUTPUT_DIR: "logs/market1501/agw_R50"
8 |
--------------------------------------------------------------------------------
/fast-reid/configs/Market1501/AGW_S50.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-AGW.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | NAME: "build_resnest_backbone"
6 |
7 | DATASETS:
8 | NAMES: ("Market1501",)
9 | TESTS: ("Market1501",)
10 |
11 | OUTPUT_DIR: "logs/market1501/agw_S50"
12 |
--------------------------------------------------------------------------------
/fast-reid/configs/Market1501/bagtricks_R101-ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-bagtricks.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | DEPTH: "101x"
6 | WITH_IBN: True
7 |
8 | DATASETS:
9 | NAMES: ("Market1501",)
10 | TESTS: ("Market1501",)
11 |
12 | OUTPUT_DIR: "logs/market1501/bagtricks_R101-ibn"
13 |
--------------------------------------------------------------------------------
/fast-reid/configs/Market1501/bagtricks_R50-ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-bagtricks.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | WITH_IBN: True
6 |
7 | DATASETS:
8 | NAMES: ("Market1501",)
9 | TESTS: ("Market1501",)
10 |
11 | OUTPUT_DIR: "logs/market1501/bagtricks_R50-ibn"
12 |
--------------------------------------------------------------------------------
/fast-reid/configs/Market1501/bagtricks_R50.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-bagtricks.yml"
2 |
3 | DATASETS:
4 | NAMES: ("Market1501",)
5 | TESTS: ("Market1501",)
6 |
7 | OUTPUT_DIR: "logs/market1501/bagtricks_R50"
8 |
--------------------------------------------------------------------------------
/fast-reid/configs/Market1501/bagtricks_S50.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-bagtricks.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | NAME: "build_resnest_backbone"
6 |
7 | DATASETS:
8 | NAMES: ("Market1501",)
9 | TESTS: ("Market1501",)
10 |
11 | OUTPUT_DIR: "logs/market1501/bagtricks_S50"
12 |
--------------------------------------------------------------------------------
/fast-reid/configs/Market1501/mgn_R50-ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-MGN.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | WITH_IBN: True
6 |
7 | DATASETS:
8 | NAMES: ("Market1501",)
9 | TESTS: ("Market1501",)
10 |
11 | OUTPUT_DIR: "logs/market1501/mgn_R50-ibn"
12 |
--------------------------------------------------------------------------------
/fast-reid/configs/Market1501/sbs_R101-ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-Strongerbaseline.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | DEPTH: "101x"
6 | WITH_IBN: True
7 |
8 | DATASETS:
9 | NAMES: ("Market1501",)
10 | TESTS: ("Market1501",)
11 |
12 | OUTPUT_DIR: "logs/market1501/sbs_R101-ibn"
13 |
--------------------------------------------------------------------------------
/fast-reid/configs/Market1501/sbs_R50-ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-Strongerbaseline.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | WITH_IBN: True
6 |
7 | DATASETS:
8 | NAMES: ("Market1501",)
9 | TESTS: ("Market1501",)
10 |
11 | OUTPUT_DIR: "logs/market1501/sbs_R50-ibn"
12 |
--------------------------------------------------------------------------------
/fast-reid/configs/Market1501/sbs_R50.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-Strongerbaseline.yml"
2 |
3 | DATASETS:
4 | NAMES: ("Market1501",)
5 | TESTS: ("Market1501",)
6 |
7 | OUTPUT_DIR: "logs/market1501/sbs_R50"
8 |
--------------------------------------------------------------------------------
/fast-reid/configs/Market1501/sbs_S50.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-Strongerbaseline.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | NAME: "build_resnest_backbone"
6 |
7 | DATASETS:
8 | NAMES: ("Market1501",)
9 | TESTS: ("Market1501",)
10 |
11 | OUTPUT_DIR: "logs/market1501/sbs_S50"
12 |
--------------------------------------------------------------------------------
/fast-reid/configs/VERIWild/bagtricks_R50-ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-bagtricks.yml"
2 |
3 | INPUT:
4 | SIZE_TRAIN: [256, 256]
5 | SIZE_TEST: [256, 256]
6 |
7 | MODEL:
8 | BACKBONE:
9 | WITH_IBN: True
10 | HEADS:
11 | POOL_LAYER: gempool
12 | LOSSES:
13 | TRI:
14 | HARD_MINING: False
15 | MARGIN: 0.0
16 |
17 | DATASETS:
18 | NAMES: ("VeRiWild",)
19 | TESTS: ("SmallVeRiWild", "MediumVeRiWild", "LargeVeRiWild",)
20 |
21 | SOLVER:
22 | IMS_PER_BATCH: 128
23 | MAX_ITER: 60
24 | STEPS: [30, 50]
25 | WARMUP_ITERS: 10
26 |
27 | CHECKPOINT_PERIOD: 20
28 |
29 | TEST:
30 | EVAL_PERIOD: 20
31 | IMS_PER_BATCH: 128
32 |
33 | OUTPUT_DIR: "logs/veriwild/bagtricks_R50-ibn_4gpu"
34 |
--------------------------------------------------------------------------------
/fast-reid/configs/VeRi/sbs_R50-ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-Strongerbaseline.yml"
2 |
3 | INPUT:
4 | SIZE_TRAIN: [256, 256]
5 | SIZE_TEST: [256, 256]
6 |
7 | MODEL:
8 | BACKBONE:
9 | WITH_IBN: True
10 |
11 | SOLVER:
12 | OPT: "SGD"
13 | BASE_LR: 0.01
14 | ETA_MIN_LR: 7.7e-5
15 |
16 | IMS_PER_BATCH: 64
17 | MAX_ITER: 60
18 | DELAY_ITERS: 30
19 | WARMUP_ITERS: 10
20 | FREEZE_ITERS: 10
21 |
22 | CHECKPOINT_PERIOD: 20
23 |
24 | DATASETS:
25 | NAMES: ("VeRi",)
26 | TESTS: ("VeRi",)
27 |
28 | TEST:
29 | EVAL_PERIOD: 20
30 | IMS_PER_BATCH: 128
31 |
32 | OUTPUT_DIR: "logs/veri/sbs_R50-ibn"
33 |
--------------------------------------------------------------------------------
/fast-reid/configs/VehicleID/bagtricks_R50-ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-bagtricks.yml"
2 |
3 | INPUT:
4 | SIZE_TRAIN: [256, 256]
5 | SIZE_TEST: [256, 256]
6 |
7 | MODEL:
8 | BACKBONE:
9 | WITH_IBN: True
10 | HEADS:
11 | POOL_LAYER: gempool
12 | LOSSES:
13 | TRI:
14 | HARD_MINING: False
15 | MARGIN: 0.0
16 |
17 | DATASETS:
18 | NAMES: ("VehicleID",)
19 | TESTS: ("SmallVehicleID", "MediumVehicleID", "LargeVehicleID",)
20 |
21 | SOLVER:
22 | BIAS_LR_FACTOR: 1.
23 |
24 | IMS_PER_BATCH: 512
25 | MAX_ITER: 60
26 | STEPS: [30, 50]
27 | WARMUP_ITERS: 10
28 |
29 | CHECKPOINT_PERIOD: 20
30 |
31 | TEST:
32 | EVAL_PERIOD: 20
33 | IMS_PER_BATCH: 128
34 |
35 | OUTPUT_DIR: "logs/vehicleid/bagtricks_R50-ibn_4gpu"
36 |
--------------------------------------------------------------------------------
/fast-reid/datasets/cuhk03_np/detected/few_ids/used_ids_0.10.txt:
--------------------------------------------------------------------------------
1 | 13
2 | 24
3 | 27
4 | 37
5 | 83
6 | 95
7 | 104
8 | 106
9 | 154
10 | 167
11 | 178
12 | 199
13 | 215
14 | 234
15 | 272
16 | 311
17 | 347
18 | 368
19 | 405
20 | 434
21 | 446
22 | 470
23 | 480
24 | 549
25 | 568
26 | 571
27 | 591
28 | 610
29 | 641
30 | 642
31 | 659
32 | 677
33 | 681
34 | 685
35 | 719
36 | 761
37 | 768
38 | 785
39 | 787
40 | 793
41 | 848
42 | 864
43 | 891
44 | 921
45 | 953
46 | 990
47 | 1034
48 | 1060
49 | 1067
50 | 1094
51 | 1102
52 | 1105
53 | 1124
54 | 1146
55 | 1152
56 | 1165
57 | 1167
58 | 1210
59 | 1219
60 | 1244
61 | 1249
62 | 1254
63 | 1260
64 | 1299
65 | 1318
66 | 1320
67 | 1335
68 | 1351
69 | 1377
70 | 1424
71 | 1444
72 | 1446
73 | 1448
74 | 1453
75 | 1455
76 | 1456
77 |
--------------------------------------------------------------------------------
/fast-reid/datasets/cuhk03_np/detected/few_ids/used_ids_0.20.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 5
3 | 13
4 | 24
5 | 27
6 | 37
7 | 59
8 | 67
9 | 83
10 | 87
11 | 95
12 | 97
13 | 104
14 | 106
15 | 108
16 | 116
17 | 117
18 | 124
19 | 137
20 | 154
21 | 161
22 | 167
23 | 178
24 | 199
25 | 203
26 | 208
27 | 215
28 | 234
29 | 245
30 | 272
31 | 273
32 | 290
33 | 302
34 | 311
35 | 347
36 | 355
37 | 368
38 | 386
39 | 387
40 | 403
41 | 405
42 | 414
43 | 434
44 | 444
45 | 446
46 | 470
47 | 480
48 | 508
49 | 516
50 | 526
51 | 531
52 | 539
53 | 549
54 | 568
55 | 571
56 | 589
57 | 591
58 | 605
59 | 608
60 | 610
61 | 619
62 | 621
63 | 641
64 | 642
65 | 657
66 | 659
67 | 677
68 | 679
69 | 681
70 | 685
71 | 688
72 | 719
73 | 735
74 | 753
75 | 761
76 | 768
77 | 775
78 | 777
79 | 785
80 | 787
81 | 793
82 | 808
83 | 845
84 | 848
85 | 864
86 | 867
87 | 878
88 | 891
89 | 897
90 | 908
91 | 921
92 | 936
93 | 953
94 | 990
95 | 1003
96 | 1015
97 | 1034
98 | 1040
99 | 1053
100 | 1057
101 | 1060
102 | 1067
103 | 1072
104 | 1073
105 | 1076
106 | 1084
107 | 1087
108 | 1092
109 | 1094
110 | 1102
111 | 1105
112 | 1109
113 | 1115
114 | 1124
115 | 1146
116 | 1152
117 | 1165
118 | 1167
119 | 1203
120 | 1210
121 | 1219
122 | 1244
123 | 1246
124 | 1249
125 | 1254
126 | 1255
127 | 1260
128 | 1261
129 | 1291
130 | 1299
131 | 1318
132 | 1320
133 | 1327
134 | 1335
135 | 1340
136 | 1351
137 | 1355
138 | 1361
139 | 1363
140 | 1377
141 | 1393
142 | 1409
143 | 1424
144 | 1430
145 | 1444
146 | 1446
147 | 1447
148 | 1448
149 | 1453
150 | 1455
151 | 1456
152 | 1462
153 | 1465
154 |
--------------------------------------------------------------------------------
/fast-reid/datasets/cuhk03_np/detected/few_ids/used_ids_0.30.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 5
3 | 13
4 | 18
5 | 20
6 | 21
7 | 24
8 | 25
9 | 27
10 | 37
11 | 57
12 | 59
13 | 66
14 | 67
15 | 79
16 | 83
17 | 87
18 | 95
19 | 97
20 | 104
21 | 106
22 | 108
23 | 116
24 | 117
25 | 122
26 | 124
27 | 137
28 | 139
29 | 154
30 | 155
31 | 161
32 | 167
33 | 178
34 | 181
35 | 199
36 | 201
37 | 203
38 | 207
39 | 208
40 | 215
41 | 226
42 | 234
43 | 240
44 | 243
45 | 245
46 | 268
47 | 272
48 | 273
49 | 277
50 | 290
51 | 302
52 | 311
53 | 312
54 | 313
55 | 341
56 | 347
57 | 354
58 | 355
59 | 363
60 | 368
61 | 371
62 | 386
63 | 387
64 | 403
65 | 405
66 | 411
67 | 414
68 | 432
69 | 434
70 | 444
71 | 446
72 | 470
73 | 480
74 | 483
75 | 484
76 | 492
77 | 495
78 | 508
79 | 511
80 | 516
81 | 526
82 | 531
83 | 539
84 | 549
85 | 568
86 | 571
87 | 589
88 | 591
89 | 596
90 | 603
91 | 605
92 | 608
93 | 610
94 | 619
95 | 621
96 | 626
97 | 632
98 | 634
99 | 641
100 | 642
101 | 657
102 | 659
103 | 677
104 | 679
105 | 681
106 | 683
107 | 684
108 | 685
109 | 688
110 | 711
111 | 719
112 | 724
113 | 728
114 | 731
115 | 735
116 | 753
117 | 761
118 | 768
119 | 775
120 | 777
121 | 779
122 | 785
123 | 787
124 | 791
125 | 793
126 | 794
127 | 801
128 | 808
129 | 828
130 | 842
131 | 845
132 | 848
133 | 852
134 | 864
135 | 867
136 | 878
137 | 891
138 | 897
139 | 900
140 | 908
141 | 921
142 | 936
143 | 953
144 | 964
145 | 973
146 | 990
147 | 994
148 | 1003
149 | 1014
150 | 1015
151 | 1018
152 | 1034
153 | 1036
154 | 1040
155 | 1053
156 | 1057
157 | 1060
158 | 1067
159 | 1072
160 | 1073
161 | 1074
162 | 1076
163 | 1084
164 | 1087
165 | 1092
166 | 1094
167 | 1102
168 | 1105
169 | 1109
170 | 1115
171 | 1124
172 | 1146
173 | 1152
174 | 1161
175 | 1165
176 | 1167
177 | 1177
178 | 1180
179 | 1196
180 | 1203
181 | 1206
182 | 1210
183 | 1219
184 | 1244
185 | 1245
186 | 1246
187 | 1249
188 | 1252
189 | 1254
190 | 1255
191 | 1260
192 | 1261
193 | 1267
194 | 1278
195 | 1291
196 | 1294
197 | 1299
198 | 1304
199 | 1310
200 | 1318
201 | 1320
202 | 1324
203 | 1325
204 | 1327
205 | 1328
206 | 1335
207 | 1340
208 | 1346
209 | 1351
210 | 1355
211 | 1361
212 | 1363
213 | 1377
214 | 1378
215 | 1380
216 | 1393
217 | 1409
218 | 1424
219 | 1430
220 | 1433
221 | 1444
222 | 1446
223 | 1447
224 | 1448
225 | 1453
226 | 1455
227 | 1456
228 | 1458
229 | 1462
230 | 1465
231 |
--------------------------------------------------------------------------------
/fast-reid/datasets/cuhk03_np/labeled/few_ids/used_ids_0.10.txt:
--------------------------------------------------------------------------------
1 | 13
2 | 24
3 | 27
4 | 37
5 | 83
6 | 95
7 | 104
8 | 106
9 | 154
10 | 167
11 | 178
12 | 199
13 | 215
14 | 234
15 | 272
16 | 311
17 | 347
18 | 368
19 | 405
20 | 434
21 | 446
22 | 470
23 | 480
24 | 549
25 | 568
26 | 571
27 | 591
28 | 610
29 | 641
30 | 642
31 | 659
32 | 677
33 | 681
34 | 685
35 | 719
36 | 761
37 | 768
38 | 785
39 | 787
40 | 793
41 | 848
42 | 864
43 | 891
44 | 921
45 | 953
46 | 990
47 | 1034
48 | 1060
49 | 1067
50 | 1094
51 | 1102
52 | 1105
53 | 1124
54 | 1146
55 | 1152
56 | 1165
57 | 1167
58 | 1208
59 | 1218
60 | 1239
61 | 1247
62 | 1253
63 | 1258
64 | 1297
65 | 1317
66 | 1318
67 | 1334
68 | 1348
69 | 1374
70 | 1424
71 | 1444
72 | 1446
73 | 1448
74 | 1453
75 | 1455
76 | 1456
77 |
--------------------------------------------------------------------------------
/fast-reid/datasets/cuhk03_np/labeled/few_ids/used_ids_0.20.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 5
3 | 13
4 | 24
5 | 27
6 | 37
7 | 59
8 | 67
9 | 83
10 | 87
11 | 95
12 | 97
13 | 104
14 | 106
15 | 108
16 | 116
17 | 117
18 | 124
19 | 137
20 | 154
21 | 161
22 | 167
23 | 178
24 | 199
25 | 203
26 | 208
27 | 215
28 | 234
29 | 245
30 | 272
31 | 273
32 | 290
33 | 302
34 | 311
35 | 347
36 | 355
37 | 368
38 | 386
39 | 387
40 | 403
41 | 405
42 | 414
43 | 434
44 | 444
45 | 446
46 | 470
47 | 480
48 | 508
49 | 516
50 | 526
51 | 531
52 | 539
53 | 549
54 | 568
55 | 571
56 | 589
57 | 591
58 | 605
59 | 608
60 | 610
61 | 619
62 | 621
63 | 641
64 | 642
65 | 657
66 | 659
67 | 677
68 | 679
69 | 681
70 | 685
71 | 688
72 | 719
73 | 735
74 | 753
75 | 761
76 | 768
77 | 775
78 | 777
79 | 785
80 | 787
81 | 793
82 | 808
83 | 845
84 | 848
85 | 864
86 | 867
87 | 878
88 | 891
89 | 897
90 | 908
91 | 921
92 | 936
93 | 953
94 | 990
95 | 1003
96 | 1015
97 | 1034
98 | 1040
99 | 1053
100 | 1057
101 | 1060
102 | 1067
103 | 1072
104 | 1073
105 | 1076
106 | 1084
107 | 1087
108 | 1092
109 | 1094
110 | 1102
111 | 1105
112 | 1109
113 | 1115
114 | 1124
115 | 1146
116 | 1152
117 | 1165
118 | 1167
119 | 1202
120 | 1208
121 | 1218
122 | 1239
123 | 1245
124 | 1247
125 | 1253
126 | 1254
127 | 1258
128 | 1260
129 | 1290
130 | 1297
131 | 1317
132 | 1318
133 | 1325
134 | 1334
135 | 1339
136 | 1348
137 | 1352
138 | 1358
139 | 1362
140 | 1374
141 | 1393
142 | 1409
143 | 1424
144 | 1430
145 | 1444
146 | 1446
147 | 1447
148 | 1448
149 | 1453
150 | 1455
151 | 1456
152 | 1462
153 | 1465
154 |
--------------------------------------------------------------------------------
/fast-reid/datasets/cuhk03_np/labeled/few_ids/used_ids_0.30.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 5
3 | 13
4 | 18
5 | 20
6 | 21
7 | 24
8 | 25
9 | 27
10 | 37
11 | 57
12 | 59
13 | 66
14 | 67
15 | 79
16 | 83
17 | 87
18 | 95
19 | 97
20 | 104
21 | 106
22 | 108
23 | 116
24 | 117
25 | 122
26 | 124
27 | 137
28 | 139
29 | 154
30 | 155
31 | 161
32 | 167
33 | 178
34 | 181
35 | 199
36 | 201
37 | 203
38 | 207
39 | 208
40 | 215
41 | 226
42 | 234
43 | 240
44 | 243
45 | 245
46 | 268
47 | 272
48 | 273
49 | 277
50 | 290
51 | 302
52 | 311
53 | 312
54 | 313
55 | 341
56 | 347
57 | 354
58 | 355
59 | 363
60 | 368
61 | 371
62 | 386
63 | 387
64 | 403
65 | 405
66 | 411
67 | 414
68 | 432
69 | 434
70 | 444
71 | 446
72 | 470
73 | 480
74 | 483
75 | 484
76 | 492
77 | 495
78 | 508
79 | 511
80 | 516
81 | 526
82 | 531
83 | 539
84 | 549
85 | 568
86 | 571
87 | 589
88 | 591
89 | 596
90 | 603
91 | 605
92 | 608
93 | 610
94 | 619
95 | 621
96 | 626
97 | 632
98 | 634
99 | 641
100 | 642
101 | 657
102 | 659
103 | 677
104 | 679
105 | 681
106 | 683
107 | 684
108 | 685
109 | 688
110 | 711
111 | 719
112 | 724
113 | 728
114 | 731
115 | 735
116 | 753
117 | 761
118 | 768
119 | 775
120 | 777
121 | 779
122 | 785
123 | 787
124 | 791
125 | 793
126 | 794
127 | 801
128 | 808
129 | 828
130 | 842
131 | 845
132 | 848
133 | 852
134 | 864
135 | 867
136 | 878
137 | 891
138 | 897
139 | 900
140 | 908
141 | 921
142 | 936
143 | 953
144 | 964
145 | 973
146 | 990
147 | 994
148 | 1003
149 | 1014
150 | 1015
151 | 1018
152 | 1034
153 | 1036
154 | 1040
155 | 1053
156 | 1057
157 | 1060
158 | 1067
159 | 1072
160 | 1073
161 | 1074
162 | 1076
163 | 1084
164 | 1087
165 | 1092
166 | 1094
167 | 1102
168 | 1105
169 | 1109
170 | 1115
171 | 1124
172 | 1146
173 | 1152
174 | 1161
175 | 1165
176 | 1167
177 | 1177
178 | 1180
179 | 1196
180 | 1202
181 | 1203
182 | 1208
183 | 1218
184 | 1239
185 | 1244
186 | 1245
187 | 1247
188 | 1250
189 | 1253
190 | 1254
191 | 1258
192 | 1260
193 | 1262
194 | 1277
195 | 1290
196 | 1292
197 | 1297
198 | 1303
199 | 1309
200 | 1317
201 | 1318
202 | 1323
203 | 1324
204 | 1325
205 | 1327
206 | 1334
207 | 1339
208 | 1345
209 | 1348
210 | 1352
211 | 1358
212 | 1362
213 | 1374
214 | 1377
215 | 1379
216 | 1393
217 | 1409
218 | 1424
219 | 1430
220 | 1433
221 | 1444
222 | 1446
223 | 1447
224 | 1448
225 | 1453
226 | 1455
227 | 1456
228 | 1458
229 | 1462
230 | 1465
231 |
--------------------------------------------------------------------------------
/fast-reid/datasets/duke/few_ids/used_ids_0.10.txt:
--------------------------------------------------------------------------------
1 | 14
2 | 32
3 | 48
4 | 57
5 | 64
6 | 73
7 | 74
8 | 81
9 | 82
10 | 94
11 | 110
12 | 139
13 | 154
14 | 161
15 | 165
16 | 202
17 | 242
18 | 258
19 | 265
20 | 278
21 | 308
22 | 328
23 | 448
24 | 450
25 | 454
26 | 464
27 | 489
28 | 491
29 | 493
30 | 536
31 | 548
32 | 550
33 | 556
34 | 564
35 | 566
36 | 573
37 | 575
38 | 582
39 | 585
40 | 650
41 | 668
42 | 725
43 | 730
44 | 764
45 | 780
46 | 815
47 | 819
48 | 860
49 | 1248
50 | 1333
51 | 1438
52 | 1524
53 | 1954
54 | 1996
55 | 2421
56 | 2558
57 | 3716
58 | 4064
59 | 4120
60 | 4184
61 | 4238
62 | 4276
63 | 4336
64 | 4391
65 | 4415
66 | 4520
67 | 4683
68 | 4690
69 | 4721
70 | 4728
71 |
--------------------------------------------------------------------------------
/fast-reid/datasets/duke/few_ids/used_ids_0.20.txt:
--------------------------------------------------------------------------------
1 | 14
2 | 22
3 | 32
4 | 48
5 | 57
6 | 64
7 | 67
8 | 73
9 | 74
10 | 81
11 | 82
12 | 84
13 | 93
14 | 94
15 | 102
16 | 104
17 | 110
18 | 113
19 | 139
20 | 148
21 | 154
22 | 161
23 | 165
24 | 190
25 | 202
26 | 226
27 | 242
28 | 255
29 | 258
30 | 265
31 | 278
32 | 308
33 | 317
34 | 327
35 | 328
36 | 348
37 | 385
38 | 430
39 | 437
40 | 448
41 | 450
42 | 454
43 | 458
44 | 464
45 | 489
46 | 491
47 | 493
48 | 505
49 | 519
50 | 522
51 | 536
52 | 545
53 | 548
54 | 550
55 | 556
56 | 562
57 | 564
58 | 566
59 | 573
60 | 575
61 | 582
62 | 585
63 | 630
64 | 650
65 | 668
66 | 669
67 | 670
68 | 673
69 | 675
70 | 677
71 | 689
72 | 715
73 | 721
74 | 725
75 | 730
76 | 751
77 | 762
78 | 764
79 | 780
80 | 782
81 | 783
82 | 789
83 | 815
84 | 819
85 | 860
86 | 1242
87 | 1246
88 | 1248
89 | 1333
90 | 1438
91 | 1524
92 | 1631
93 | 1767
94 | 1874
95 | 1954
96 | 1996
97 | 2036
98 | 2408
99 | 2421
100 | 2436
101 | 2520
102 | 2542
103 | 2558
104 | 3370
105 | 3520
106 | 3621
107 | 3716
108 | 4064
109 | 4068
110 | 4096
111 | 4108
112 | 4120
113 | 4140
114 | 4184
115 | 4186
116 | 4206
117 | 4209
118 | 4216
119 | 4238
120 | 4258
121 | 4260
122 | 4276
123 | 4277
124 | 4307
125 | 4336
126 | 4365
127 | 4391
128 | 4415
129 | 4484
130 | 4520
131 | 4527
132 | 4548
133 | 4629
134 | 4683
135 | 4685
136 | 4690
137 | 4721
138 | 4728
139 | 4741
140 | 4810
141 |
--------------------------------------------------------------------------------
/fast-reid/datasets/duke/few_ids/used_ids_0.30.txt:
--------------------------------------------------------------------------------
1 | 14
2 | 17
3 | 22
4 | 32
5 | 41
6 | 48
7 | 57
8 | 62
9 | 64
10 | 67
11 | 73
12 | 74
13 | 81
14 | 82
15 | 84
16 | 85
17 | 93
18 | 94
19 | 102
20 | 104
21 | 110
22 | 113
23 | 120
24 | 130
25 | 139
26 | 148
27 | 154
28 | 160
29 | 161
30 | 165
31 | 166
32 | 190
33 | 198
34 | 202
35 | 224
36 | 225
37 | 226
38 | 242
39 | 255
40 | 258
41 | 265
42 | 278
43 | 308
44 | 317
45 | 327
46 | 328
47 | 348
48 | 349
49 | 385
50 | 402
51 | 403
52 | 423
53 | 425
54 | 430
55 | 437
56 | 448
57 | 450
58 | 452
59 | 454
60 | 458
61 | 464
62 | 472
63 | 474
64 | 483
65 | 489
66 | 491
67 | 493
68 | 505
69 | 519
70 | 522
71 | 528
72 | 534
73 | 536
74 | 545
75 | 548
76 | 550
77 | 556
78 | 558
79 | 562
80 | 564
81 | 566
82 | 573
83 | 575
84 | 582
85 | 585
86 | 610
87 | 613
88 | 623
89 | 630
90 | 650
91 | 664
92 | 665
93 | 666
94 | 668
95 | 669
96 | 670
97 | 673
98 | 675
99 | 677
100 | 679
101 | 684
102 | 689
103 | 697
104 | 715
105 | 721
106 | 725
107 | 728
108 | 730
109 | 745
110 | 751
111 | 762
112 | 764
113 | 767
114 | 774
115 | 780
116 | 782
117 | 783
118 | 784
119 | 789
120 | 805
121 | 815
122 | 819
123 | 821
124 | 825
125 | 837
126 | 848
127 | 860
128 | 1242
129 | 1246
130 | 1248
131 | 1333
132 | 1438
133 | 1524
134 | 1526
135 | 1565
136 | 1631
137 | 1767
138 | 1830
139 | 1874
140 | 1953
141 | 1954
142 | 1996
143 | 2036
144 | 2408
145 | 2421
146 | 2422
147 | 2436
148 | 2515
149 | 2520
150 | 2529
151 | 2542
152 | 2558
153 | 2748
154 | 3370
155 | 3520
156 | 3546
157 | 3621
158 | 3716
159 | 3765
160 | 4064
161 | 4068
162 | 4096
163 | 4108
164 | 4115
165 | 4120
166 | 4135
167 | 4140
168 | 4160
169 | 4184
170 | 4186
171 | 4206
172 | 4209
173 | 4212
174 | 4216
175 | 4238
176 | 4243
177 | 4258
178 | 4260
179 | 4276
180 | 4277
181 | 4278
182 | 4307
183 | 4336
184 | 4365
185 | 4391
186 | 4415
187 | 4430
188 | 4451
189 | 4463
190 | 4481
191 | 4484
192 | 4520
193 | 4527
194 | 4548
195 | 4567
196 | 4602
197 | 4629
198 | 4631
199 | 4683
200 | 4685
201 | 4689
202 | 4690
203 | 4721
204 | 4728
205 | 4741
206 | 4791
207 | 4810
208 | 5258
209 | 5388
210 | 7136
211 |
--------------------------------------------------------------------------------
/fast-reid/datasets/market1501/few_ids/used_ids_0.10.txt:
--------------------------------------------------------------------------------
1 | 27
2 | 52
3 | 59
4 | 106
5 | 118
6 | 123
7 | 125
8 | 141
9 | 166
10 | 172
11 | 173
12 | 179
13 | 202
14 | 222
15 | 241
16 | 301
17 | 313
18 | 348
19 | 357
20 | 392
21 | 399
22 | 410
23 | 508
24 | 552
25 | 554
26 | 599
27 | 605
28 | 633
29 | 640
30 | 683
31 | 685
32 | 709
33 | 711
34 | 718
35 | 738
36 | 781
37 | 810
38 | 826
39 | 832
40 | 850
41 | 855
42 | 901
43 | 926
44 | 936
45 | 946
46 | 975
47 | 991
48 | 994
49 | 995
50 | 999
51 | 1017
52 | 1025
53 | 1031
54 | 1052
55 | 1075
56 | 1152
57 | 1157
58 | 1159
59 | 1162
60 | 1176
61 | 1220
62 | 1237
63 | 1289
64 | 1292
65 | 1335
66 | 1343
67 | 1350
68 | 1368
69 | 1373
70 | 1430
71 | 1433
72 | 1453
73 | 1464
74 | 1469
75 | 1470
76 |
--------------------------------------------------------------------------------
/fast-reid/datasets/market1501/few_ids/used_ids_0.20.txt:
--------------------------------------------------------------------------------
1 | 2
2 | 11
3 | 27
4 | 37
5 | 46
6 | 52
7 | 59
8 | 84
9 | 97
10 | 106
11 | 110
12 | 118
13 | 121
14 | 123
15 | 125
16 | 127
17 | 135
18 | 136
19 | 141
20 | 150
21 | 166
22 | 172
23 | 173
24 | 179
25 | 181
26 | 202
27 | 208
28 | 214
29 | 222
30 | 236
31 | 241
32 | 268
33 | 301
34 | 313
35 | 323
36 | 325
37 | 348
38 | 357
39 | 358
40 | 368
41 | 380
42 | 390
43 | 392
44 | 399
45 | 410
46 | 442
47 | 459
48 | 472
49 | 475
50 | 486
51 | 494
52 | 508
53 | 528
54 | 529
55 | 552
56 | 554
57 | 557
58 | 589
59 | 597
60 | 599
61 | 605
62 | 615
63 | 620
64 | 633
65 | 640
66 | 657
67 | 674
68 | 681
69 | 683
70 | 685
71 | 689
72 | 704
73 | 709
74 | 711
75 | 718
76 | 730
77 | 738
78 | 761
79 | 762
80 | 781
81 | 785
82 | 810
83 | 820
84 | 826
85 | 828
86 | 832
87 | 833
88 | 850
89 | 851
90 | 855
91 | 879
92 | 887
93 | 901
94 | 914
95 | 917
96 | 926
97 | 936
98 | 942
99 | 946
100 | 948
101 | 975
102 | 991
103 | 994
104 | 995
105 | 999
106 | 1017
107 | 1023
108 | 1025
109 | 1031
110 | 1048
111 | 1052
112 | 1056
113 | 1075
114 | 1107
115 | 1113
116 | 1116
117 | 1126
118 | 1152
119 | 1157
120 | 1159
121 | 1162
122 | 1165
123 | 1173
124 | 1176
125 | 1220
126 | 1230
127 | 1237
128 | 1289
129 | 1292
130 | 1320
131 | 1332
132 | 1335
133 | 1343
134 | 1344
135 | 1350
136 | 1358
137 | 1363
138 | 1368
139 | 1373
140 | 1385
141 | 1402
142 | 1428
143 | 1430
144 | 1433
145 | 1453
146 | 1464
147 | 1469
148 | 1470
149 | 1471
150 | 1495
151 |
--------------------------------------------------------------------------------
/fast-reid/datasets/market1501/few_ids/used_ids_0.30.txt:
--------------------------------------------------------------------------------
1 | 2
2 | 11
3 | 27
4 | 32
5 | 37
6 | 46
7 | 47
8 | 52
9 | 59
10 | 82
11 | 84
12 | 95
13 | 97
14 | 104
15 | 106
16 | 110
17 | 118
18 | 121
19 | 123
20 | 125
21 | 127
22 | 135
23 | 136
24 | 140
25 | 141
26 | 150
27 | 158
28 | 166
29 | 167
30 | 172
31 | 173
32 | 177
33 | 179
34 | 181
35 | 202
36 | 206
37 | 208
38 | 212
39 | 214
40 | 222
41 | 236
42 | 237
43 | 239
44 | 241
45 | 242
46 | 264
47 | 268
48 | 277
49 | 299
50 | 301
51 | 313
52 | 323
53 | 325
54 | 341
55 | 344
56 | 348
57 | 357
58 | 358
59 | 368
60 | 370
61 | 374
62 | 380
63 | 382
64 | 390
65 | 392
66 | 399
67 | 410
68 | 413
69 | 415
70 | 424
71 | 427
72 | 442
73 | 457
74 | 459
75 | 468
76 | 472
77 | 475
78 | 486
79 | 494
80 | 508
81 | 528
82 | 529
83 | 552
84 | 554
85 | 557
86 | 575
87 | 581
88 | 589
89 | 593
90 | 597
91 | 599
92 | 605
93 | 615
94 | 620
95 | 633
96 | 639
97 | 640
98 | 641
99 | 657
100 | 662
101 | 665
102 | 666
103 | 669
104 | 674
105 | 681
106 | 683
107 | 685
108 | 689
109 | 697
110 | 702
111 | 703
112 | 704
113 | 705
114 | 709
115 | 711
116 | 718
117 | 724
118 | 730
119 | 738
120 | 761
121 | 762
122 | 765
123 | 773
124 | 781
125 | 785
126 | 810
127 | 820
128 | 826
129 | 828
130 | 832
131 | 833
132 | 850
133 | 851
134 | 855
135 | 879
136 | 887
137 | 900
138 | 901
139 | 914
140 | 917
141 | 926
142 | 936
143 | 942
144 | 946
145 | 948
146 | 953
147 | 958
148 | 969
149 | 975
150 | 987
151 | 991
152 | 994
153 | 995
154 | 999
155 | 1000
156 | 1001
157 | 1002
158 | 1017
159 | 1018
160 | 1023
161 | 1025
162 | 1031
163 | 1048
164 | 1052
165 | 1056
166 | 1075
167 | 1094
168 | 1107
169 | 1113
170 | 1116
171 | 1126
172 | 1135
173 | 1140
174 | 1142
175 | 1152
176 | 1157
177 | 1159
178 | 1162
179 | 1165
180 | 1167
181 | 1173
182 | 1176
183 | 1204
184 | 1206
185 | 1219
186 | 1220
187 | 1227
188 | 1230
189 | 1232
190 | 1237
191 | 1243
192 | 1289
193 | 1292
194 | 1295
195 | 1297
196 | 1303
197 | 1320
198 | 1330
199 | 1332
200 | 1335
201 | 1343
202 | 1344
203 | 1350
204 | 1358
205 | 1363
206 | 1368
207 | 1373
208 | 1381
209 | 1385
210 | 1391
211 | 1402
212 | 1411
213 | 1421
214 | 1428
215 | 1430
216 | 1433
217 | 1453
218 | 1463
219 | 1464
220 | 1469
221 | 1470
222 | 1471
223 | 1474
224 | 1480
225 | 1495
226 |
--------------------------------------------------------------------------------
/fast-reid/datasets/msmt17/few_ids/used_ids_0.10.txt:
--------------------------------------------------------------------------------
1 | 6
2 | 17
3 | 27
4 | 34
5 | 35
6 | 41
7 | 49
8 | 60
9 | 65
10 | 78
11 | 80
12 | 85
13 | 94
14 | 99
15 | 101
16 | 104
17 | 108
18 | 119
19 | 120
20 | 135
21 | 148
22 | 154
23 | 156
24 | 165
25 | 191
26 | 195
27 | 200
28 | 201
29 | 207
30 | 236
31 | 238
32 | 242
33 | 259
34 | 281
35 | 301
36 | 310
37 | 311
38 | 314
39 | 329
40 | 341
41 | 347
42 | 349
43 | 366
44 | 374
45 | 386
46 | 415
47 | 429
48 | 432
49 | 452
50 | 453
51 | 480
52 | 507
53 | 509
54 | 512
55 | 525
56 | 553
57 | 577
58 | 584
59 | 589
60 | 593
61 | 598
62 | 602
63 | 619
64 | 632
65 | 635
66 | 636
67 | 641
68 | 645
69 | 658
70 | 669
71 | 674
72 | 677
73 | 688
74 | 692
75 | 711
76 | 716
77 | 724
78 | 741
79 | 743
80 | 747
81 | 756
82 | 767
83 | 781
84 | 786
85 | 808
86 | 822
87 | 831
88 | 836
89 | 855
90 | 875
91 | 893
92 | 906
93 | 920
94 | 922
95 | 931
96 | 940
97 | 950
98 | 961
99 | 980
100 | 1009
101 | 1012
102 | 1022
103 | 1028
104 | 1033
105 |
--------------------------------------------------------------------------------
/fast-reid/datasets/msmt17/few_ids/used_ids_0.20.txt:
--------------------------------------------------------------------------------
1 | 2
2 | 3
3 | 5
4 | 6
5 | 8
6 | 13
7 | 17
8 | 27
9 | 34
10 | 35
11 | 41
12 | 49
13 | 56
14 | 59
15 | 60
16 | 65
17 | 72
18 | 73
19 | 78
20 | 80
21 | 81
22 | 84
23 | 85
24 | 90
25 | 94
26 | 99
27 | 101
28 | 104
29 | 108
30 | 111
31 | 117
32 | 119
33 | 120
34 | 125
35 | 133
36 | 135
37 | 142
38 | 148
39 | 154
40 | 156
41 | 159
42 | 165
43 | 175
44 | 177
45 | 180
46 | 181
47 | 186
48 | 189
49 | 191
50 | 194
51 | 195
52 | 200
53 | 201
54 | 202
55 | 207
56 | 223
57 | 228
58 | 236
59 | 238
60 | 241
61 | 242
62 | 244
63 | 248
64 | 258
65 | 259
66 | 262
67 | 267
68 | 281
69 | 301
70 | 309
71 | 310
72 | 311
73 | 314
74 | 329
75 | 331
76 | 339
77 | 341
78 | 345
79 | 347
80 | 349
81 | 358
82 | 364
83 | 366
84 | 374
85 | 382
86 | 386
87 | 390
88 | 403
89 | 414
90 | 415
91 | 419
92 | 429
93 | 430
94 | 432
95 | 434
96 | 437
97 | 447
98 | 452
99 | 453
100 | 464
101 | 474
102 | 480
103 | 494
104 | 502
105 | 507
106 | 509
107 | 512
108 | 516
109 | 525
110 | 537
111 | 553
112 | 560
113 | 574
114 | 577
115 | 584
116 | 589
117 | 590
118 | 593
119 | 598
120 | 602
121 | 604
122 | 612
123 | 614
124 | 619
125 | 622
126 | 623
127 | 632
128 | 635
129 | 636
130 | 641
131 | 645
132 | 650
133 | 658
134 | 669
135 | 671
136 | 674
137 | 675
138 | 677
139 | 679
140 | 683
141 | 688
142 | 692
143 | 702
144 | 711
145 | 716
146 | 719
147 | 724
148 | 727
149 | 736
150 | 741
151 | 742
152 | 743
153 | 747
154 | 756
155 | 761
156 | 765
157 | 767
158 | 769
159 | 779
160 | 781
161 | 786
162 | 788
163 | 808
164 | 810
165 | 822
166 | 824
167 | 831
168 | 832
169 | 835
170 | 836
171 | 844
172 | 855
173 | 861
174 | 874
175 | 875
176 | 881
177 | 893
178 | 904
179 | 906
180 | 916
181 | 920
182 | 922
183 | 931
184 | 932
185 | 936
186 | 940
187 | 950
188 | 955
189 | 961
190 | 962
191 | 967
192 | 971
193 | 980
194 | 993
195 | 996
196 | 1000
197 | 1002
198 | 1003
199 | 1006
200 | 1008
201 | 1009
202 | 1012
203 | 1017
204 | 1022
205 | 1023
206 | 1028
207 | 1033
208 | 1034
209 |
--------------------------------------------------------------------------------
/fast-reid/demo/README.md:
--------------------------------------------------------------------------------
1 | # FastReID Demo
2 |
3 | We provide a command line tool to run a simple demo of builtin models.
4 |
5 | You can run this command to get cosine similarites between different images
6 |
7 | ```bash
8 | cd demo/
9 | sh run_demo.sh
10 | ```
--------------------------------------------------------------------------------
/fast-reid/demo/plot_roc_with_pickle.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: xingyu liao
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | import matplotlib.pyplot as plt
8 | import sys
9 |
10 | sys.path.append('.')
11 | from fastreid.utils.visualizer import Visualizer
12 |
13 | if __name__ == "__main__":
14 | baseline_res = Visualizer.load_roc_info("logs/duke_vis/roc_info.pickle")
15 | mgn_res = Visualizer.load_roc_info("logs/mgn_duke_vis/roc_info.pickle")
16 |
17 | fig = Visualizer.plot_roc_curve(baseline_res['fpr'], baseline_res['tpr'], name='baseline')
18 | Visualizer.plot_roc_curve(mgn_res['fpr'], mgn_res['tpr'], name='mgn', fig=fig)
19 | plt.savefig('roc.jpg')
20 |
21 | fig = Visualizer.plot_distribution(baseline_res['pos'], baseline_res['neg'], name='baseline')
22 | Visualizer.plot_distribution(mgn_res['pos'], mgn_res['neg'], name='mgn', fig=fig)
23 | plt.savefig('dist.jpg')
24 |
--------------------------------------------------------------------------------
/fast-reid/docs/GETTING_STARTED.md:
--------------------------------------------------------------------------------
1 | # Getting Started with Fastreid
2 |
3 | ## Prepare pretrained model
4 |
5 | If you use backbones supported by fastreid, you do not need to do anything. It will automatically download the pre-train models.
6 | But if your network is not connected, you can download pre-train models manually and put it in `~/.cache/torch/checkpoints`.
7 |
8 | If you want to use other pre-train models, such as MoCo pre-train, you can download by yourself and set the pre-train model path in `configs/Base-bagtricks.yml`.
9 |
10 | ## Compile with cython to accelerate evalution
11 |
12 | ```bash
13 | cd fastreid/evaluation/rank_cylib; make all
14 | ```
15 |
16 | ## Training & Evaluation in Command Line
17 |
18 | We provide a script in "tools/train_net.py", that is made to train all the configs provided in fastreid.
19 | You may want to use it as a reference to write your own training script.
20 |
21 | To train a model with "train_net.py", first setup up the corresponding datasets following [datasets/README.md](https://github.com/JDAI-CV/fast-reid/tree/master/datasets), then run:
22 |
23 | ```bash
24 | ./tools/train_net.py --config-file ./configs/Market1501/bagtricks_R50.yml MODEL.DEVICE "cuda:0"
25 | ```
26 |
27 | The configs are made for 1-GPU training.
28 |
29 | If you want to train model with 4 GPUs, you can run:
30 |
31 | ```bash
32 | python tools/train_net.py --config-file ./configs/Market1501/bagtricks_R50.yml --num-gpus 4
33 | ```
34 |
35 | To evaluate a model's performance, use
36 |
37 | ```bash
38 | python tools/train_net.py --config-file ./configs/Market1501/bagtricks_R50.yml --eval-only \
39 | MODEL.WEIGHTS /path/to/checkpoint_file MODEL.DEVICE "cuda:0"
40 | ```
41 |
42 | For more options, see `./tools/train_net.py -h`.
43 |
--------------------------------------------------------------------------------
/fast-reid/docs/INSTALL.md:
--------------------------------------------------------------------------------
1 | # Installation
2 |
3 | ## Requirements
4 |
5 | - Linux or macOS with python ≥ 3.6
6 | - PyTorch ≥ 1.6
7 | - torchvision that matches the Pytorch installation. You can install them together at [pytorch.org](https://pytorch.org/) to make sure of this.
8 | - [yacs](https://github.com/rbgirshick/yacs)
9 | - Cython (optional to compile evaluation code)
10 | - tensorboard (needed for visualization): `pip install tensorboard`
11 | - gdown (for automatically downloading pre-train model)
12 | - sklearn
13 | - termcolor
14 | - tabulate
15 | - [faiss](https://github.com/facebookresearch/faiss) `pip install faiss-cpu`
16 |
17 |
18 |
19 | # Set up with Conda
20 | ```shell script
21 | conda create -n fastreid python=3.7
22 | conda activate fastreid
23 | conda install pytorch==1.6.0 torchvision tensorboard -c pytorch
24 | pip install -r requirements
25 | ```
26 |
27 | # Set up with Dockder
28 | comming soon
29 |
--------------------------------------------------------------------------------
/fast-reid/docs/requirements:
--------------------------------------------------------------------------------
1 | matplotlib
2 | scipy
3 | Pillow
4 | numpy
5 | prettytable
6 | easydict
7 | scikit-learn
8 | pyyaml
9 | yacs
10 | termcolor
11 | tabulate
12 | tensorboard
13 | opencv-python
14 | pyyaml
15 | yacs
16 | termcolor
17 | scikit-learn
18 | tabulate
19 | gdown
20 | faiss-cpu
--------------------------------------------------------------------------------
/fast-reid/fastreid/__init__.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: liaoxingyu
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 |
8 | __version__ = "0.1.0"
--------------------------------------------------------------------------------
/fast-reid/fastreid/config/__init__.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: l1aoxingyu
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | from .config import CfgNode, get_cfg
8 | from .defaults import _C as cfg
9 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/data/__init__.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: sherlock
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | from .build import build_reid_train_loader, build_reid_test_loader
8 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/data/data_utils.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: liaoxingyu
4 | @contact: sherlockliao01@gmail.com
5 | """
6 | import numpy as np
7 | from PIL import Image, ImageOps
8 |
9 | from fastreid.utils.file_io import PathManager
10 |
11 |
12 | def read_image(file_name, format=None):
13 | """
14 | Read an image into the given format.
15 | Will apply rotation and flipping if the image has such exif information.
16 | Args:
17 | file_name (str): image file path
18 | format (str): one of the supported image modes in PIL, or "BGR"
19 | Returns:
20 | image (np.ndarray): an HWC image
21 | """
22 | with PathManager.open(file_name, "rb") as f:
23 | image = Image.open(f)
24 |
25 | # capture and ignore this bug: https://github.com/python-pillow/Pillow/issues/3973
26 | try:
27 | image = ImageOps.exif_transpose(image)
28 | except Exception:
29 | pass
30 |
31 | if format is not None:
32 | # PIL only supports RGB, so convert to RGB and flip channels over below
33 | conversion_format = format
34 | if format == "BGR":
35 | conversion_format = "RGB"
36 | image = image.convert(conversion_format)
37 | image = np.asarray(image)
38 | if format == "BGR":
39 | # flip channels if needed
40 | image = image[:, :, ::-1]
41 | # PIL squeezes out the channel dimension for "L", so make it HWC
42 | if format == "L":
43 | image = np.expand_dims(image, -1)
44 | image = Image.fromarray(image)
45 | return image
46 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/data/datasets/AirportALERT.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: xingyu liao
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | import os
8 |
9 | from fastreid.data.datasets import DATASET_REGISTRY
10 | from fastreid.data.datasets.bases import ImageDataset
11 |
12 | __all__ = ['AirportALERT', ]
13 |
14 |
15 | @DATASET_REGISTRY.register()
16 | class AirportALERT(ImageDataset):
17 | dataset_dir = "AirportALERT"
18 | dataset_name = "airport"
19 |
20 | def __init__(self, root='datasets', **kwargs):
21 | self.root = root
22 | self.train_path = os.path.join(self.root, self.dataset_dir)
23 | self.train_file = os.path.join(self.root, self.dataset_dir, 'filepath.txt')
24 |
25 | required_files = [self.train_file, self.train_path]
26 | self.check_before_run(required_files)
27 |
28 | train = self.process_train(self.train_path, self.train_file)
29 |
30 | super().__init__(train, [], [], **kwargs)
31 |
32 | def process_train(self, dir_path, train_file):
33 | data = []
34 | with open(train_file, "r") as f:
35 | img_paths = [line.strip('\n') for line in f.readlines()]
36 |
37 | for path in img_paths:
38 | split_path = path.split('\\')
39 | img_path = '/'.join(split_path)
40 | camid = self.dataset_name + "_" + split_path[0]
41 | pid = self.dataset_name + "_" + split_path[1]
42 | img_path = os.path.join(dir_path, img_path)
43 | if 11001 <= int(split_path[1]) <= 401999:
44 | data.append([img_path, pid, camid])
45 |
46 | return data
47 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/data/datasets/__init__.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: liaoxingyu
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | from ...utils.registry import Registry
8 |
9 | DATASET_REGISTRY = Registry("DATASET")
10 | DATASET_REGISTRY.__doc__ = """
11 | Registry for datasets
12 | It must returns an instance of :class:`Backbone`.
13 | """
14 |
15 | # Person re-id datasets
16 | from .cuhk03 import CUHK03
17 | from .dukemtmcreid import DukeMTMC
18 | from .market1501 import Market1501
19 | from .msmt17 import MSMT17
20 | from .AirportALERT import AirportALERT
21 | from .iLIDS import iLIDS
22 | from .pku import PKU
23 | from .prai import PRAI
24 | from .sensereid import SenseReID
25 | from .sysu_mm import SYSU_mm
26 | from .thermalworld import Thermalworld
27 | from .pes3d import PeS3D
28 | from .caviara import CAVIARa
29 | from .viper import VIPeR
30 | from .lpw import LPW
31 | from .shinpuhkan import Shinpuhkan
32 | from .wildtracker import WildTrackCrop
33 | from .cuhk_sysu import cuhkSYSU
34 | from .cmdm import CMDM
35 | from .lup import LUP
36 |
37 | # Vehicle re-id datasets
38 | from .veri import VeRi
39 | from .vehicleid import VehicleID, SmallVehicleID, MediumVehicleID, LargeVehicleID
40 | from .veriwild import VeRiWild, SmallVeRiWild, MediumVeRiWild, LargeVeRiWild
41 |
42 |
43 | __all__ = [k for k in globals().keys() if "builtin" not in k and not k.startswith("_")]
44 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/data/datasets/caviara.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: xingyu liao
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | import os
8 | from scipy.io import loadmat
9 | from glob import glob
10 |
11 | from fastreid.data.datasets import DATASET_REGISTRY
12 | from fastreid.data.datasets.bases import ImageDataset
13 | import pdb
14 | import random
15 | import numpy as np
16 |
17 | __all__ = ['CAVIARa',]
18 |
19 |
20 | @DATASET_REGISTRY.register()
21 | class CAVIARa(ImageDataset):
22 | dataset_dir = "CAVIARa"
23 | dataset_name = "caviara"
24 |
25 | def __init__(self, root='datasets', **kwargs):
26 | self.root = root
27 | self.train_path = os.path.join(self.root, self.dataset_dir)
28 |
29 | required_files = [self.train_path]
30 | self.check_before_run(required_files)
31 |
32 | train = self.process_train(self.train_path)
33 |
34 | super().__init__(train, [], [], **kwargs)
35 |
36 | def process_train(self, train_path):
37 | data = []
38 |
39 | img_list = glob(os.path.join(train_path, "*.jpg"))
40 | for img_path in img_list:
41 | img_name = img_path.split('/')[-1]
42 | pid = self.dataset_name + "_" + img_name[:4]
43 | camid = self.dataset_name + "_cam0"
44 | data.append([img_path, pid, camid])
45 |
46 | return data
47 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/data/datasets/cuhk_sysu.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: xingyu liao
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | import glob
8 | import os.path as osp
9 | import re
10 | import warnings
11 |
12 | from .bases import ImageDataset
13 | from ..datasets import DATASET_REGISTRY
14 |
15 |
16 | @DATASET_REGISTRY.register()
17 | class cuhkSYSU(ImageDataset):
18 | r"""CUHK SYSU datasets.
19 |
20 | The dataset is collected from two sources: street snap and movie.
21 | In street snap, 12,490 images and 6,057 query persons were collected
22 | with movable cameras across hundreds of scenes while 5,694 images and
23 | 2,375 query persons were selected from movies and TV dramas.
24 |
25 | Dataset statistics:
26 | - identities: xxx.
27 | - images: 12936 (train).
28 | """
29 | dataset_dir = 'cuhk_sysu'
30 | dataset_name = "cuhksysu"
31 |
32 | def __init__(self, root='datasets', **kwargs):
33 | self.root = root
34 | self.dataset_dir = osp.join(self.root, self.dataset_dir)
35 |
36 | self.data_dir = osp.join(self.dataset_dir, "cropped_images")
37 |
38 | required_files = [self.data_dir]
39 | self.check_before_run(required_files)
40 |
41 | train = self.process_dir(self.data_dir)
42 | query = []
43 | gallery = []
44 |
45 | super(cuhkSYSU, self).__init__(train, query, gallery, **kwargs)
46 |
47 | def process_dir(self, dir_path):
48 | img_paths = glob.glob(osp.join(dir_path, '*.jpg'))
49 | pattern = re.compile(r'p([-\d]+)_s(\d)')
50 |
51 | data = []
52 | for img_path in img_paths:
53 | pid, _ = map(int, pattern.search(img_path).groups())
54 | pid = self.dataset_name + "_" + str(pid)
55 | camid = self.dataset_name + "_0"
56 | data.append((img_path, pid, camid))
57 |
58 | return data
59 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/data/datasets/iLIDS.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: xingyu liao
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | import os
8 | from glob import glob
9 |
10 | from fastreid.data.datasets import DATASET_REGISTRY
11 | from fastreid.data.datasets.bases import ImageDataset
12 |
13 | __all__ = ['iLIDS', ]
14 |
15 |
16 | @DATASET_REGISTRY.register()
17 | class iLIDS(ImageDataset):
18 | dataset_dir = "iLIDS"
19 | dataset_name = "ilids"
20 |
21 | def __init__(self, root='datasets', **kwargs):
22 | self.root = root
23 | self.train_path = os.path.join(self.root, self.dataset_dir)
24 |
25 | required_files = [self.train_path]
26 | self.check_before_run(required_files)
27 |
28 | train = self.process_train(self.train_path)
29 |
30 | super().__init__(train, [], [], **kwargs)
31 |
32 | def process_train(self, train_path):
33 | data = []
34 | file_path = os.listdir(train_path)
35 | for pid_dir in file_path:
36 | img_file = os.path.join(train_path, pid_dir)
37 | img_paths = glob(os.path.join(img_file, "*.png"))
38 | for img_path in img_paths:
39 | split_path = img_path.split('/')
40 | pid = self.dataset_name + "_" + split_path[-2]
41 | camid = self.dataset_name + "_" + split_path[-1].split('_')[0]
42 | data.append([img_path, pid, camid])
43 | return data
44 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/data/datasets/lpw.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: xingyu liao
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | import os
8 | from glob import glob
9 |
10 | from fastreid.data.datasets import DATASET_REGISTRY
11 | from fastreid.data.datasets.bases import ImageDataset
12 |
13 | __all__ = ['LPW', ]
14 |
15 |
16 | @DATASET_REGISTRY.register()
17 | class LPW(ImageDataset):
18 | dataset_dir = "pep_256x128"
19 | dataset_name = "lpw"
20 |
21 | def __init__(self, root='datasets', **kwargs):
22 | self.root = root
23 | self.train_path = os.path.join(self.root, self.dataset_dir)
24 |
25 | required_files = [self.train_path]
26 | self.check_before_run(required_files)
27 |
28 | train = self.process_train(self.train_path)
29 |
30 | super().__init__(train, [], [], **kwargs)
31 |
32 | def process_train(self, train_path):
33 | data = []
34 |
35 | file_path_list = ['scen1', 'scen2', 'scen3']
36 |
37 | for scene in file_path_list:
38 | cam_list = os.listdir(os.path.join(train_path, scene))
39 | for cam in cam_list:
40 | camid = self.dataset_name + "_" + cam
41 | pid_list = os.listdir(os.path.join(train_path, scene, cam))
42 | for pid_dir in pid_list:
43 | img_paths = glob(os.path.join(train_path, scene, cam, pid_dir, "*.jpg"))
44 | for img_path in img_paths:
45 | pid = self.dataset_name + "_" + scene + "-" + pid_dir
46 | data.append([img_path, pid, camid])
47 | return data
48 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/data/datasets/lup.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding: utf-8 -*-
3 | # @Date : 2021-01-12 17:08:58
4 | # @Author : Dengpan Fu (t-defu@microsoft.com)
5 |
6 | import os
7 | import numpy as np
8 | import pickle, lmdb
9 |
10 | from .bases import ImageDataset
11 | from ..datasets import DATASET_REGISTRY
12 |
13 |
14 | @DATASET_REGISTRY.register()
15 | class LUP(ImageDataset):
16 | """ Dataset class for Large Scale Unlabeled data in LMDB format
17 | """
18 | dir_name = 'lup'
19 | def __init__(self, root='datasets', sub_name='lmdb_300_30', **kwargs):
20 | self.base_root = root
21 | self.sub_name = sub_name
22 | self.data_root = os.path.join(self.base_root, self.dir_name, self.sub_name)
23 | self.lmdb_path = os.path.join(self.data_root, 'lmdb')
24 | self.key_path = os.path.join(self.data_root, 'keys.pkl')
25 |
26 | required_files = [self.data_root, self.lmdb_path, self.key_path]
27 | self.check_before_run(required_files)
28 |
29 | with open(self.key_path, 'rb') as f:
30 | data = pickle.load(f)
31 |
32 | self.train = []
33 | self.pids = set()
34 | for key, pid in zip(data['keys'], data['pids']):
35 | self.train.append([key, pid, 0])
36 | self.pids.add(pid)
37 | self.pids = sorted(list(self.pids))
38 |
39 | super(LUP, self).__init__(self.train, [], [], **kwargs)
40 |
41 |
42 | def get_num_pids(self, data):
43 | return len(self.pids)
44 |
45 | def get_num_cams(self, data):
46 | return 1
47 |
48 | def parse_data(self, data):
49 | return len(self.pids), 1
50 |
51 | def show_test(self):
52 | raise Exception('LUPerson dataset has no test split currently.')
--------------------------------------------------------------------------------
/fast-reid/fastreid/data/datasets/pes3d.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: xingyu liao
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | import os
8 | from scipy.io import loadmat
9 | from glob import glob
10 |
11 | from fastreid.data.datasets import DATASET_REGISTRY
12 | from fastreid.data.datasets.bases import ImageDataset
13 | import pdb
14 | import random
15 | import numpy as np
16 |
17 | __all__ = ['PeS3D',]
18 |
19 |
20 | @DATASET_REGISTRY.register()
21 | class PeS3D(ImageDataset):
22 | dataset_dir = "3DPeS"
23 | dataset_name = "pes3d"
24 |
25 | def __init__(self, root='datasets', **kwargs):
26 | self.root = root
27 | self.train_path = os.path.join(self.root, self.dataset_dir)
28 |
29 | required_files = [self.train_path]
30 | self.check_before_run(required_files)
31 |
32 | train = self.process_train(self.train_path)
33 |
34 | super().__init__(train, [], [], **kwargs)
35 |
36 | def process_train(self, train_path):
37 | data = []
38 |
39 | pid_list = os.listdir(train_path)
40 | for pid_dir in pid_list:
41 | pid = self.dataset_name + "_" + pid_dir
42 | img_list = glob(os.path.join(train_path, pid_dir, "*.bmp"))
43 | for img_path in img_list:
44 | camid = self.dataset_name + "_cam0"
45 | data.append([img_path, pid, camid])
46 | return data
47 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/data/datasets/pku.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: xingyu liao
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | import os
8 | from glob import glob
9 |
10 | from fastreid.data.datasets import DATASET_REGISTRY
11 | from fastreid.data.datasets.bases import ImageDataset
12 |
13 | __all__ = ['PKU', ]
14 |
15 |
16 | @DATASET_REGISTRY.register()
17 | class PKU(ImageDataset):
18 | dataset_dir = "PKUv1a_128x48"
19 | dataset_name = 'pku'
20 |
21 | def __init__(self, root='datasets', **kwargs):
22 | self.root = root
23 | self.train_path = os.path.join(self.root, self.dataset_dir)
24 |
25 | required_files = [self.train_path]
26 | self.check_before_run(required_files)
27 |
28 | train = self.process_train(self.train_path)
29 |
30 | super().__init__(train, [], [], **kwargs)
31 |
32 | def process_train(self, train_path):
33 | data = []
34 | img_paths = glob(os.path.join(train_path, "*.png"))
35 |
36 | for img_path in img_paths:
37 | split_path = img_path.split('/')
38 | img_info = split_path[-1].split('_')
39 | pid = self.dataset_name + "_" + img_info[0]
40 | camid = self.dataset_name + "_" + img_info[1]
41 | data.append([img_path, pid, camid])
42 | return data
43 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/data/datasets/prai.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: xingyu liao
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | import os
8 | from scipy.io import loadmat
9 | from glob import glob
10 |
11 | from fastreid.data.datasets import DATASET_REGISTRY
12 | from fastreid.data.datasets.bases import ImageDataset
13 | import pdb
14 |
15 | __all__ = ['PRAI',]
16 |
17 |
18 | @DATASET_REGISTRY.register()
19 | class PRAI(ImageDataset):
20 | dataset_dir = "PRAI-1581"
21 | dataset_name = 'prai'
22 |
23 | def __init__(self, root='datasets', **kwargs):
24 | self.root = root
25 | self.train_path = os.path.join(self.root, self.dataset_dir, 'images')
26 |
27 | required_files = [self.train_path]
28 | self.check_before_run(required_files)
29 |
30 | train = self.process_train(self.train_path)
31 |
32 | super().__init__(train, [], [], **kwargs)
33 |
34 | def process_train(self, train_path):
35 | data = []
36 | img_paths = glob(os.path.join(train_path, "*.jpg"))
37 | for img_path in img_paths:
38 | split_path = img_path.split('/')
39 | img_info = split_path[-1].split('_')
40 | pid = self.dataset_name + "_" + img_info[0]
41 | camid = self.dataset_name + "_" + img_info[1]
42 | data.append([img_path, pid, camid])
43 | return data
44 |
45 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/data/datasets/sensereid.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: xingyu liao
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | import os
8 | from glob import glob
9 |
10 | from fastreid.data.datasets import DATASET_REGISTRY
11 | from fastreid.data.datasets.bases import ImageDataset
12 |
13 | __all__ = ['SenseReID', ]
14 |
15 |
16 | @DATASET_REGISTRY.register()
17 | class SenseReID(ImageDataset):
18 | dataset_dir = "SenseReID"
19 | dataset_name = "senseid"
20 |
21 | def __init__(self, root='datasets', **kwargs):
22 | self.root = root
23 | self.train_path = os.path.join(self.root, self.dataset_dir)
24 |
25 | required_files = [self.train_path]
26 | self.check_before_run(required_files)
27 |
28 | train = self.process_train(self.train_path)
29 |
30 | super().__init__(train, [], [], **kwargs)
31 |
32 | def process_train(self, train_path):
33 | data = []
34 | file_path_list = ['test_gallery', 'test_prob']
35 |
36 | for file_path in file_path_list:
37 | sub_file = os.path.join(train_path, file_path)
38 | img_name = glob(os.path.join(sub_file, "*.jpg"))
39 | for img_path in img_name:
40 | img_name = img_path.split('/')[-1]
41 | img_info = img_name.split('_')
42 | pid = self.dataset_name + "_" + img_info[0]
43 | camid = self.dataset_name + "_" + img_info[1].split('.')[0]
44 | data.append([img_path, pid, camid])
45 | return data
46 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/data/datasets/shinpuhkan.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: xingyu liao
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | import os
8 |
9 | from fastreid.data.datasets import DATASET_REGISTRY
10 | from fastreid.data.datasets.bases import ImageDataset
11 |
12 | __all__ = ['Shinpuhkan', ]
13 |
14 |
15 | @DATASET_REGISTRY.register()
16 | class Shinpuhkan(ImageDataset):
17 | dataset_dir = "shinpuhkan"
18 | dataset_name = 'shinpuhkan'
19 |
20 | def __init__(self, root='datasets', **kwargs):
21 | self.root = root
22 | self.train_path = os.path.join(self.root, self.dataset_dir)
23 |
24 | required_files = [self.train_path]
25 | self.check_before_run(required_files)
26 |
27 | train = self.process_train(self.train_path)
28 |
29 | super().__init__(train, [], [], **kwargs)
30 |
31 | def process_train(self, train_path):
32 | data = []
33 |
34 | for root, dirs, files in os.walk(train_path):
35 | img_names = list(filter(lambda x: x.endswith(".jpg"), files))
36 | # fmt: off
37 | if len(img_names) == 0: continue
38 | # fmt: on
39 | for img_name in img_names:
40 | img_path = os.path.join(root, img_name)
41 | split_path = img_name.split('_')
42 | pid = self.dataset_name + "_" + split_path[0]
43 | camid = self.dataset_name + "_" + split_path[2]
44 | data.append((img_path, pid, camid))
45 |
46 | return data
47 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/data/datasets/sysu_mm.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: xingyu liao
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | import os
8 | from scipy.io import loadmat
9 | from glob import glob
10 |
11 | from fastreid.data.datasets import DATASET_REGISTRY
12 | from fastreid.data.datasets.bases import ImageDataset
13 | import pdb
14 |
15 | __all__ = ['SYSU_mm', ]
16 |
17 |
18 | @DATASET_REGISTRY.register()
19 | class SYSU_mm(ImageDataset):
20 | dataset_dir = "SYSU-MM01"
21 | dataset_name = "sysumm01"
22 |
23 | def __init__(self, root='datasets', **kwargs):
24 | self.root = root
25 | self.train_path = os.path.join(self.root, self.dataset_dir)
26 |
27 | required_files = [self.train_path]
28 | self.check_before_run(required_files)
29 |
30 | train = self.process_train(self.train_path)
31 |
32 | super().__init__(train, [], [], **kwargs)
33 |
34 | def process_train(self, train_path):
35 | data = []
36 |
37 | file_path_list = ['cam1', 'cam2', 'cam4', 'cam5']
38 |
39 | for file_path in file_path_list:
40 | camid = self.dataset_name + "_" + file_path
41 | pid_list = os.listdir(os.path.join(train_path, file_path))
42 | for pid_dir in pid_list:
43 | pid = self.dataset_name + "_" + pid_dir
44 | img_list = glob(os.path.join(train_path, file_path, pid_dir, "*.jpg"))
45 | for img_path in img_list:
46 | data.append([img_path, pid, camid])
47 | return data
48 |
49 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/data/datasets/thermalworld.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: xingyu liao
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | import os
8 | from scipy.io import loadmat
9 | from glob import glob
10 |
11 | from fastreid.data.datasets import DATASET_REGISTRY
12 | from fastreid.data.datasets.bases import ImageDataset
13 | import pdb
14 | import random
15 | import numpy as np
16 |
17 | __all__ = ['Thermalworld',]
18 |
19 |
20 | @DATASET_REGISTRY.register()
21 | class Thermalworld(ImageDataset):
22 | dataset_dir = "thermalworld_rgb"
23 | dataset_name = "thermalworld"
24 |
25 | def __init__(self, root='datasets', **kwargs):
26 | self.root = root
27 | self.train_path = os.path.join(self.root, self.dataset_dir)
28 |
29 | required_files = [self.train_path]
30 | self.check_before_run(required_files)
31 |
32 | train = self.process_train(self.train_path)
33 |
34 | super().__init__(train, [], [], **kwargs)
35 |
36 | def process_train(self, train_path):
37 | data = []
38 | pid_list = os.listdir(train_path)
39 | for pid_dir in pid_list:
40 | pid = self.dataset_name + "_" + pid_dir
41 | img_list = glob(os.path.join(train_path, pid_dir, "*.jpg"))
42 | for img_path in img_list:
43 | camid = self.dataset_name + "_cam0"
44 | data.append([img_path, pid, camid])
45 | return data
46 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/data/datasets/veri.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: Jinkai Zheng
4 | @contact: 1315673509@qq.com
5 | """
6 |
7 | import glob
8 | import os.path as osp
9 | import re
10 |
11 | from .bases import ImageDataset
12 | from ..datasets import DATASET_REGISTRY
13 |
14 |
15 | @DATASET_REGISTRY.register()
16 | class VeRi(ImageDataset):
17 | """VeRi.
18 |
19 | Reference:
20 | Liu et al. A Deep Learning based Approach for Progressive Vehicle Re-Identification. ECCV 2016.
21 |
22 | URL: ``_
23 |
24 | Dataset statistics:
25 | - identities: 775.
26 | - images: 37778 (train) + 1678 (query) + 11579 (gallery).
27 | """
28 | dataset_dir = "veri"
29 | dataset_name = "veri"
30 |
31 | def __init__(self, root='datasets', **kwargs):
32 | self.dataset_dir = osp.join(root, self.dataset_dir)
33 |
34 | self.train_dir = osp.join(self.dataset_dir, 'image_train')
35 | self.query_dir = osp.join(self.dataset_dir, 'image_query')
36 | self.gallery_dir = osp.join(self.dataset_dir, 'image_test')
37 |
38 | required_files = [
39 | self.dataset_dir,
40 | self.train_dir,
41 | self.query_dir,
42 | self.gallery_dir,
43 | ]
44 | self.check_before_run(required_files)
45 |
46 | train = self.process_dir(self.train_dir)
47 | query = self.process_dir(self.query_dir, is_train=False)
48 | gallery = self.process_dir(self.gallery_dir, is_train=False)
49 |
50 | super(VeRi, self).__init__(train, query, gallery, **kwargs)
51 |
52 | def process_dir(self, dir_path, is_train=True):
53 | img_paths = glob.glob(osp.join(dir_path, '*.jpg'))
54 | pattern = re.compile(r'([\d]+)_c(\d\d\d)')
55 |
56 | data = []
57 | for img_path in img_paths:
58 | pid, camid = map(int, pattern.search(img_path).groups())
59 | if pid == -1: continue # junk images are just ignored
60 | assert 1 <= pid <= 776
61 | assert 1 <= camid <= 20
62 | camid -= 1 # index starts from 0
63 | if is_train:
64 | pid = self.dataset_name + "_" + str(pid)
65 | camid = self.dataset_name + "_" + str(camid)
66 | data.append((img_path, pid, camid))
67 |
68 | return data
69 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/data/datasets/viper.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: xingyu liao
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | import os
8 | from glob import glob
9 |
10 | from fastreid.data.datasets import DATASET_REGISTRY
11 | from fastreid.data.datasets.bases import ImageDataset
12 |
13 | __all__ = ['VIPeR', ]
14 |
15 |
16 | @DATASET_REGISTRY.register()
17 | class VIPeR(ImageDataset):
18 | dataset_dir = "VIPeR"
19 | dataset_name = "viper"
20 |
21 | def __init__(self, root='datasets', **kwargs):
22 | self.root = root
23 | self.train_path = os.path.join(self.root, self.dataset_dir)
24 |
25 | required_files = [self.train_path]
26 | self.check_before_run(required_files)
27 |
28 | train = self.process_train(self.train_path)
29 |
30 | super().__init__(train, [], [], **kwargs)
31 |
32 | def process_train(self, train_path):
33 | data = []
34 |
35 | file_path_list = ['cam_a', 'cam_b']
36 |
37 | for file_path in file_path_list:
38 | camid = self.dataset_name + "_" + file_path
39 | img_list = glob(os.path.join(train_path, file_path, "*.bmp"))
40 | for img_path in img_list:
41 | img_name = img_path.split('/')[-1]
42 | pid = self.dataset_name + "_" + img_name.split('_')[0]
43 | data.append([img_path, pid, camid])
44 |
45 | return data
46 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/data/datasets/wildtracker.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: wangguanan
4 | @contact: guan.wang0706@gmail.com
5 | """
6 |
7 | import glob
8 | import os
9 |
10 | from .bases import ImageDataset
11 | from ..datasets import DATASET_REGISTRY
12 |
13 |
14 | @DATASET_REGISTRY.register()
15 | class WildTrackCrop(ImageDataset):
16 | """WildTrack.
17 | Reference:
18 | WILDTRACK: A Multi-camera HD Dataset for Dense Unscripted Pedestrian Detection
19 | T. Chavdarova; P. Baqué; A. Maksai; S. Bouquet; C. Jose et al.
20 | URL: ``_
21 | Dataset statistics:
22 | - identities: 313
23 | - images: 33979 (train only)
24 | - cameras: 7
25 | Args:
26 | data_path(str): path to WildTrackCrop dataset
27 | combineall(bool): combine train and test sets as train set if True
28 | """
29 | dataset_url = None
30 | dataset_dir = 'Wildtrack_crop_dataset'
31 | dataset_name = 'wildtrack'
32 |
33 | def __init__(self, root='datasets', **kwargs):
34 | self.root = root
35 | self.dataset_dir = os.path.join(self.root, self.dataset_dir)
36 |
37 | self.train_dir = os.path.join(self.dataset_dir, "crop")
38 |
39 | train = self.process_dir(self.train_dir)
40 | query = []
41 | gallery = []
42 |
43 | super(WildTrackCrop, self).__init__(train, query, gallery, **kwargs)
44 |
45 | def process_dir(self, dir_path):
46 | r"""
47 | :param dir_path: directory path saving images
48 | Returns
49 | data(list) = [img_path, pid, camid]
50 | """
51 | data = []
52 | for dir_name in os.listdir(dir_path):
53 | img_lists = glob.glob(os.path.join(dir_path, dir_name, "*.png"))
54 | for img_path in img_lists:
55 | pid = self.dataset_name + "_" + dir_name
56 | camid = img_path.split('/')[-1].split('_')[0]
57 | camid = self.dataset_name + "_" + camid
58 | data.append([img_path, pid, camid])
59 | return data
60 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/data/samplers/__init__.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: liaoxingyu
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | from .triplet_sampler import BalancedIdentitySampler, NaiveIdentitySampler
8 | from .data_sampler import TrainingSampler, InferenceSampler
9 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/data/transforms/__init__.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: sherlock
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 |
8 | from .build import build_transforms
9 | from .transforms import *
10 | from .autoaugment import *
11 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/data/transforms/build.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: liaoxingyu
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | import torchvision.transforms as T
8 |
9 | from .transforms import *
10 | from .autoaugment import AutoAugment
11 |
12 |
13 | def build_transforms(cfg, is_train=True):
14 | res = []
15 |
16 | if is_train:
17 | size_train = cfg.INPUT.SIZE_TRAIN
18 |
19 | # augmix augmentation
20 | do_augmix = cfg.INPUT.DO_AUGMIX
21 |
22 | # auto augmentation
23 | do_autoaug = cfg.INPUT.DO_AUTOAUG
24 | total_iter = cfg.SOLVER.MAX_ITER
25 |
26 | # horizontal filp
27 | do_flip = cfg.INPUT.DO_FLIP
28 | flip_prob = cfg.INPUT.FLIP_PROB
29 |
30 | # padding
31 | do_pad = cfg.INPUT.DO_PAD
32 | padding = cfg.INPUT.PADDING
33 | padding_mode = cfg.INPUT.PADDING_MODE
34 |
35 | # color jitter
36 | do_cj = cfg.INPUT.CJ.ENABLED
37 | cj_prob = cfg.INPUT.CJ.PROB
38 | cj_brightness = cfg.INPUT.CJ.BRIGHTNESS
39 | cj_contrast = cfg.INPUT.CJ.CONTRAST
40 | cj_saturation = cfg.INPUT.CJ.SATURATION
41 | cj_hue = cfg.INPUT.CJ.HUE
42 |
43 | # random erasing
44 | do_rea = cfg.INPUT.REA.ENABLED
45 | rea_prob = cfg.INPUT.REA.PROB
46 | rea_mean = cfg.INPUT.REA.MEAN
47 | # random patch
48 | do_rpt = cfg.INPUT.RPT.ENABLED
49 | rpt_prob = cfg.INPUT.RPT.PROB
50 |
51 | if do_autoaug:
52 | res.append(AutoAugment(total_iter))
53 | res.append(T.Resize(size_train, interpolation=3))
54 | if do_flip:
55 | res.append(T.RandomHorizontalFlip(p=flip_prob))
56 | if do_pad:
57 | res.extend([T.Pad(padding, padding_mode=padding_mode),
58 | T.RandomCrop(size_train)])
59 | if do_cj:
60 | res.append(T.RandomApply([T.ColorJitter(cj_brightness, cj_contrast, cj_saturation, cj_hue)], p=cj_prob))
61 | if do_augmix:
62 | res.append(AugMix())
63 | if do_rea:
64 | res.append(RandomErasing(probability=rea_prob, mean=rea_mean))
65 | if do_rpt:
66 | res.append(RandomPatch(prob_happen=rpt_prob))
67 | else:
68 | size_test = cfg.INPUT.SIZE_TEST
69 | res.append(T.Resize(size_test, interpolation=3))
70 | res.append(ToTensor())
71 | return T.Compose(res)
72 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/engine/__init__.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: liaoxingyu
4 | @contact: sherlockliao01@gmail.com
5 | """
6 | from .train_loop import *
7 |
8 | __all__ = [k for k in globals().keys() if not k.startswith("_")]
9 |
10 |
11 | # prefer to let hooks and defaults live in separate namespaces (therefore not in __all__)
12 | # but still make them available here
13 | from .hooks import *
14 | from .defaults import *
15 | from .launch import *
16 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/evaluation/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
2 | from .evaluator import DatasetEvaluator, inference_context, inference_on_dataset
3 | from .rank import evaluate_rank
4 | from .roc import evaluate_roc
5 | from .reid_evaluation import ReidEvaluator
6 | from .testing import print_csv_format, verify_results
7 |
8 | __all__ = [k for k in globals().keys() if not k.startswith("_")]
9 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/evaluation/query_expansion.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: xingyu liao
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | # based on
8 | # https://github.com/PyRetri/PyRetri/blob/master/pyretri/index/re_ranker/re_ranker_impl/query_expansion.py
9 |
10 | import numpy as np
11 | import torch
12 | import torch.nn.functional as F
13 |
14 |
15 | def aqe(query_feat: torch.tensor, gallery_feat: torch.tensor,
16 | qe_times: int = 1, qe_k: int = 10, alpha: float = 3.0):
17 | """
18 | Combining the retrieved topk nearest neighbors with the original query and doing another retrieval.
19 | c.f. https://www.robots.ox.ac.uk/~vgg/publications/papers/chum07b.pdf
20 | Args :
21 | query_feat (torch.tensor):
22 | gallery_feat (torch.tensor):
23 | qe_times (int): number of query expansion times.
24 | qe_k (int): number of the neighbors to be combined.
25 | alpha (float):
26 | """
27 | num_query = query_feat.shape[0]
28 | all_feat = torch.cat((query_feat, gallery_feat), dim=0)
29 | norm_feat = F.normalize(all_feat, p=2, dim=1)
30 |
31 | all_feat = all_feat.numpy()
32 | for i in range(qe_times):
33 | all_feat_list = []
34 | sims = torch.mm(norm_feat, norm_feat.t())
35 | sims = sims.data.cpu().numpy()
36 | for sim in sims:
37 | init_rank = np.argpartition(-sim, range(1, qe_k + 1))
38 | weights = sim[init_rank[:qe_k]].reshape((-1, 1))
39 | weights = np.power(weights, alpha)
40 | all_feat_list.append(np.mean(all_feat[init_rank[:qe_k], :] * weights, axis=0))
41 | all_feat = np.stack(all_feat_list, axis=0)
42 | norm_feat = F.normalize(torch.from_numpy(all_feat), p=2, dim=1)
43 |
44 | query_feat = torch.from_numpy(all_feat[:num_query])
45 | gallery_feat = torch.from_numpy(all_feat[num_query:])
46 | return query_feat, gallery_feat
47 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/evaluation/rank_cylib/Makefile:
--------------------------------------------------------------------------------
1 | all:
2 | python3 setup.py build_ext --inplace
3 | rm -rf build
4 | python3 test_cython.py
5 | clean:
6 | rm -rf build
7 | rm -f rank_cy.c *.so
8 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/evaluation/rank_cylib/__init__.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: liaoxingyu
4 | @contact: sherlockliao01@gmail.com
5 | """
--------------------------------------------------------------------------------
/fast-reid/fastreid/evaluation/rank_cylib/setup.py:
--------------------------------------------------------------------------------
1 | from distutils.core import setup
2 | from distutils.extension import Extension
3 |
4 | import numpy as np
5 | from Cython.Build import cythonize
6 |
7 |
8 | def numpy_include():
9 | try:
10 | numpy_include = np.get_include()
11 | except AttributeError:
12 | numpy_include = np.get_numpy_include()
13 | return numpy_include
14 |
15 |
16 | ext_modules = [
17 | Extension(
18 | 'rank_cy',
19 | ['rank_cy.pyx'],
20 | include_dirs=[numpy_include()],
21 | ),
22 | Extension(
23 | 'roc_cy',
24 | ['roc_cy.pyx'],
25 | include_dirs=[numpy_include()],
26 | )
27 | ]
28 |
29 | setup(
30 | name='Cython-based reid evaluation code',
31 | ext_modules=cythonize(ext_modules)
32 | )
33 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/layers/__init__.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: liaoxingyu
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | from .activation import *
8 | from .arc_softmax import ArcSoftmax
9 | from .circle_softmax import CircleSoftmax
10 | from .am_softmax import AMSoftmax
11 | from .batch_drop import BatchDrop
12 | from .batch_norm import *
13 | from .context_block import ContextBlock
14 | from .frn import FRN, TLU
15 | from .non_local import Non_local
16 | from .pooling import *
17 | from .se_layer import SELayer
18 | from .splat import SplAtConv2d
19 | from .gather_layer import GatherLayer
20 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/layers/activation.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: xingyu liao
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | import math
8 |
9 | import torch
10 | import torch.nn as nn
11 | import torch.nn.functional as F
12 |
13 | __all__ = [
14 | 'Mish',
15 | 'Swish',
16 | 'MemoryEfficientSwish',
17 | 'GELU']
18 |
19 |
20 | class Mish(nn.Module):
21 | def __init__(self):
22 | super().__init__()
23 |
24 | def forward(self, x):
25 | # inlining this saves 1 second per epoch (V100 GPU) vs having a temp x and then returning x(!)
26 | return x * (torch.tanh(F.softplus(x)))
27 |
28 |
29 | class Swish(nn.Module):
30 | def forward(self, x):
31 | return x * torch.sigmoid(x)
32 |
33 |
34 | class SwishImplementation(torch.autograd.Function):
35 | @staticmethod
36 | def forward(ctx, i):
37 | result = i * torch.sigmoid(i)
38 | ctx.save_for_backward(i)
39 | return result
40 |
41 | @staticmethod
42 | def backward(ctx, grad_output):
43 | i = ctx.saved_variables[0]
44 | sigmoid_i = torch.sigmoid(i)
45 | return grad_output * (sigmoid_i * (1 + i * (1 - sigmoid_i)))
46 |
47 |
48 | class MemoryEfficientSwish(nn.Module):
49 | def forward(self, x):
50 | return SwishImplementation.apply(x)
51 |
52 |
53 | class GELU(nn.Module):
54 | """
55 | Paper Section 3.4, last paragraph notice that BERT used the GELU instead of RELU
56 | """
57 |
58 | def forward(self, x):
59 | return 0.5 * x * (1 + torch.tanh(math.sqrt(2 / math.pi) * (x + 0.044715 * torch.pow(x, 3))))
60 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/layers/am_softmax.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: xingyu liao
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | import torch
8 | from torch import nn
9 | import torch.nn.functional as F
10 | from torch.nn import Parameter
11 |
12 |
13 | class AMSoftmax(nn.Module):
14 | r"""Implement of large margin cosine distance:
15 | Args:
16 | in_feat: size of each input sample
17 | num_classes: size of each output sample
18 | """
19 |
20 | def __init__(self, cfg, in_feat, num_classes):
21 | super().__init__()
22 | self.in_features = in_feat
23 | self._num_classes = num_classes
24 | self.s = cfg.MODEL.HEADS.SCALE
25 | self.m = cfg.MODEL.HEADS.MARGIN
26 | self.weight = Parameter(torch.Tensor(num_classes, in_feat))
27 | nn.init.xavier_uniform_(self.weight)
28 |
29 | def forward(self, features, targets):
30 | # --------------------------- cos(theta) & phi(theta) ---------------------------
31 | cosine = F.linear(F.normalize(features), F.normalize(self.weight))
32 | phi = cosine - self.m
33 | # --------------------------- convert label to one-hot ---------------------------
34 | targets = F.one_hot(targets, num_classes=self._num_classes)
35 | output = (targets * phi) + ((1.0 - targets) * cosine)
36 | output *= self.s
37 |
38 | return output
39 |
40 | def extra_repr(self):
41 | return 'in_features={}, num_classes={}, scale={}, margin={}'.format(
42 | self.in_feat, self._num_classes, self.s, self.m
43 | )
44 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/layers/arc_softmax.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: liaoxingyu
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | import math
8 |
9 | import torch
10 | import torch.nn as nn
11 | import torch.nn.functional as F
12 | from torch.nn import Parameter
13 |
14 |
15 | class ArcSoftmax(nn.Module):
16 | def __init__(self, cfg, in_feat, num_classes):
17 | super().__init__()
18 | self.in_feat = in_feat
19 | self._num_classes = num_classes
20 | self.s = cfg.MODEL.HEADS.SCALE
21 | self.m = cfg.MODEL.HEADS.MARGIN
22 |
23 | self.cos_m = math.cos(self.m)
24 | self.sin_m = math.sin(self.m)
25 | self.threshold = math.cos(math.pi - self.m)
26 | self.mm = math.sin(math.pi - self.m) * self.m
27 |
28 | self.weight = Parameter(torch.Tensor(num_classes, in_feat))
29 | nn.init.xavier_uniform_(self.weight)
30 | self.register_buffer('t', torch.zeros(1))
31 |
32 | def forward(self, features, targets):
33 | # get cos(theta)
34 | cos_theta = F.linear(F.normalize(features), F.normalize(self.weight))
35 | cos_theta = cos_theta.clamp(-1, 1) # for numerical stability
36 |
37 | target_logit = cos_theta[torch.arange(0, features.size(0)), targets].view(-1, 1)
38 |
39 | sin_theta = torch.sqrt(1.0 - torch.pow(target_logit, 2))
40 | cos_theta_m = target_logit * self.cos_m - sin_theta * self.sin_m # cos(target+margin)
41 | mask = cos_theta > cos_theta_m
42 | final_target_logit = torch.where(target_logit > self.threshold, cos_theta_m, target_logit - self.mm)
43 |
44 | hard_example = cos_theta[mask]
45 | with torch.no_grad():
46 | self.t = target_logit.mean() * 0.01 + (1 - 0.01) * self.t
47 | cos_theta[mask] = hard_example * (self.t + hard_example)
48 | cos_theta.scatter_(1, targets.view(-1, 1).long(), final_target_logit)
49 | pred_class_logits = cos_theta * self.s
50 | return pred_class_logits
51 |
52 | def extra_repr(self):
53 | return 'in_features={}, num_classes={}, scale={}, margin={}'.format(
54 | self.in_feat, self._num_classes, self.s, self.m
55 | )
56 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/layers/batch_drop.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: liaoxingyu
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | import random
8 |
9 | from torch import nn
10 |
11 |
12 | class BatchDrop(nn.Module):
13 | """ref: https://github.com/daizuozhuo/batch-dropblock-network/blob/master/models/networks.py
14 | batch drop mask
15 | """
16 |
17 | def __init__(self, h_ratio, w_ratio):
18 | super(BatchDrop, self).__init__()
19 | self.h_ratio = h_ratio
20 | self.w_ratio = w_ratio
21 |
22 | def forward(self, x):
23 | if self.training:
24 | h, w = x.size()[-2:]
25 | rh = round(self.h_ratio * h)
26 | rw = round(self.w_ratio * w)
27 | sx = random.randint(0, h - rh)
28 | sy = random.randint(0, w - rw)
29 | mask = x.new_ones(x.size())
30 | mask[:, :, sx:sx + rh, sy:sy + rw] = 0
31 | x = x * mask
32 | return x
33 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/layers/circle_softmax.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: liaoxingyu
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | import math
8 |
9 | import torch
10 | import torch.nn as nn
11 | import torch.nn.functional as F
12 | from torch.nn import Parameter
13 |
14 |
15 | class CircleSoftmax(nn.Module):
16 | def __init__(self, cfg, in_feat, num_classes):
17 | super().__init__()
18 | self.in_feat = in_feat
19 | self._num_classes = num_classes
20 | self.s = cfg.MODEL.HEADS.SCALE
21 | self.m = cfg.MODEL.HEADS.MARGIN
22 |
23 | self.weight = Parameter(torch.Tensor(num_classes, in_feat))
24 | nn.init.kaiming_uniform_(self.weight, a=math.sqrt(5))
25 |
26 | def forward(self, features, targets):
27 | sim_mat = F.linear(F.normalize(features), F.normalize(self.weight))
28 | alpha_p = torch.clamp_min(-sim_mat.detach() + 1 + self.m, min=0.)
29 | alpha_n = torch.clamp_min(sim_mat.detach() + self.m, min=0.)
30 | delta_p = 1 - self.m
31 | delta_n = self.m
32 |
33 | s_p = self.s * alpha_p * (sim_mat - delta_p)
34 | s_n = self.s * alpha_n * (sim_mat - delta_n)
35 |
36 | targets = F.one_hot(targets, num_classes=self._num_classes)
37 |
38 | pred_class_logits = targets * s_p + (1.0 - targets) * s_n
39 |
40 | return pred_class_logits
41 |
42 | def extra_repr(self):
43 | return 'in_features={}, num_classes={}, scale={}, margin={}'.format(
44 | self.in_feat, self._num_classes, self.s, self.m
45 | )
46 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/layers/gather_layer.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: xingyu liao
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | # based on: https://github.com/open-mmlab/OpenSelfSup/blob/master/openselfsup/models/utils/gather_layer.py
8 |
9 | import torch
10 | import torch.distributed as dist
11 |
12 |
13 | class GatherLayer(torch.autograd.Function):
14 | """Gather tensors from all process, supporting backward propagation.
15 | """
16 |
17 | @staticmethod
18 | def forward(ctx, input):
19 | ctx.save_for_backward(input)
20 | output = [torch.zeros_like(input) \
21 | for _ in range(dist.get_world_size())]
22 | dist.all_gather(output, input)
23 | return tuple(output)
24 |
25 | @staticmethod
26 | def backward(ctx, *grads):
27 | input, = ctx.saved_tensors
28 | grad_out = torch.zeros_like(input)
29 | grad_out[:] = grads[dist.get_rank()]
30 | return grad_out
31 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/layers/non_local.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 |
4 | import torch
5 | from torch import nn
6 | from .batch_norm import get_norm
7 |
8 |
9 | class Non_local(nn.Module):
10 | def __init__(self, in_channels, bn_norm, reduc_ratio=2):
11 | super(Non_local, self).__init__()
12 |
13 | self.in_channels = in_channels
14 | self.inter_channels = in_channels // reduc_ratio
15 |
16 | self.g = nn.Conv2d(in_channels=self.in_channels, out_channels=self.inter_channels,
17 | kernel_size=1, stride=1, padding=0)
18 |
19 | self.W = nn.Sequential(
20 | nn.Conv2d(in_channels=self.inter_channels, out_channels=self.in_channels,
21 | kernel_size=1, stride=1, padding=0),
22 | get_norm(bn_norm, self.in_channels),
23 | )
24 | nn.init.constant_(self.W[1].weight, 0.0)
25 | nn.init.constant_(self.W[1].bias, 0.0)
26 |
27 | self.theta = nn.Conv2d(in_channels=self.in_channels, out_channels=self.inter_channels,
28 | kernel_size=1, stride=1, padding=0)
29 |
30 | self.phi = nn.Conv2d(in_channels=self.in_channels, out_channels=self.inter_channels,
31 | kernel_size=1, stride=1, padding=0)
32 |
33 | def forward(self, x):
34 | """
35 | :param x: (b, t, h, w)
36 | :return x: (b, t, h, w)
37 | """
38 | batch_size = x.size(0)
39 | g_x = self.g(x).view(batch_size, self.inter_channels, -1)
40 | g_x = g_x.permute(0, 2, 1)
41 |
42 | theta_x = self.theta(x).view(batch_size, self.inter_channels, -1)
43 | theta_x = theta_x.permute(0, 2, 1)
44 | phi_x = self.phi(x).view(batch_size, self.inter_channels, -1)
45 | f = torch.matmul(theta_x, phi_x)
46 | N = f.size(-1)
47 | f_div_C = f / N
48 |
49 | y = torch.matmul(f_div_C, g_x)
50 | y = y.permute(0, 2, 1).contiguous()
51 | y = y.view(batch_size, self.inter_channels, *x.size()[2:])
52 | W_y = self.W(y)
53 | z = W_y + x
54 | return z
55 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/layers/se_layer.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: liaoxingyu
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | from torch import nn
8 |
9 |
10 | class SELayer(nn.Module):
11 | def __init__(self, channel, reduction=16):
12 | super(SELayer, self).__init__()
13 | self.avg_pool = nn.AdaptiveAvgPool2d(1)
14 | self.fc = nn.Sequential(
15 | nn.Linear(channel, int(channel / reduction), bias=False),
16 | nn.ReLU(inplace=True),
17 | nn.Linear(int(channel / reduction), channel, bias=False),
18 | nn.Sigmoid()
19 | )
20 |
21 | def forward(self, x):
22 | b, c, _, _ = x.size()
23 | y = self.avg_pool(x).view(b, c)
24 | y = self.fc(y).view(b, c, 1, 1)
25 | return x * y.expand_as(x)
26 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/__init__.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: sherlock
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | from .meta_arch import build_model
8 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/backbones/__init__.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: liaoxingyu
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | from .build import build_backbone, BACKBONE_REGISTRY
8 |
9 | from .resnet import build_resnet_backbone
10 | from .osnet import build_osnet_backbone
11 | from .resnest import build_resnest_backbone
12 | from .resnext import build_resnext_backbone
13 | from .regnet import build_regnet_backbone, build_effnet_backbone
14 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/backbones/build.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: liaoxingyu
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | from ...utils.registry import Registry
8 |
9 | BACKBONE_REGISTRY = Registry("BACKBONE")
10 | BACKBONE_REGISTRY.__doc__ = """
11 | Registry for backbones, which extract feature maps from images
12 | The registered object must be a callable that accepts two arguments:
13 | 1. A :class:`detectron2.config.CfgNode`
14 | 2. A :class:`detectron2.layers.ShapeSpec`, which contains the input shape specification.
15 | It must returns an instance of :class:`Backbone`.
16 | """
17 |
18 |
19 | def build_backbone(cfg):
20 | """
21 | Build a backbone from `cfg.MODEL.BACKBONE.NAME`.
22 | Returns:
23 | an instance of :class:`Backbone`
24 | """
25 |
26 | backbone_name = cfg.MODEL.BACKBONE.NAME
27 | backbone = BACKBONE_REGISTRY.get(backbone_name)(cfg)
28 | return backbone
29 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/backbones/regnet/__init__.py:
--------------------------------------------------------------------------------
1 |
2 |
3 | from .regnet import build_regnet_backbone
4 | from .effnet import build_effnet_backbone
5 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B0_dds_8gpu.yaml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | TYPE: effnet
3 | NUM_CLASSES: 1000
4 | EN:
5 | STEM_W: 32
6 | STRIDES: [1, 2, 2, 2, 1, 2, 1]
7 | DEPTHS: [1, 2, 2, 3, 3, 4, 1]
8 | WIDTHS: [16, 24, 40, 80, 112, 192, 320]
9 | EXP_RATIOS: [1, 6, 6, 6, 6, 6, 6]
10 | KERNELS: [3, 3, 5, 3, 5, 5, 3]
11 | HEAD_W: 1280
12 | OPTIM:
13 | LR_POLICY: cos
14 | BASE_LR: 0.4
15 | MAX_EPOCH: 100
16 | MOMENTUM: 0.9
17 | WEIGHT_DECAY: 1e-5
18 | TRAIN:
19 | DATASET: imagenet
20 | IM_SIZE: 224
21 | BATCH_SIZE: 256
22 | TEST:
23 | DATASET: imagenet
24 | IM_SIZE: 256
25 | BATCH_SIZE: 200
26 | NUM_GPUS: 8
27 | OUT_DIR: .
28 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B1_dds_8gpu.yaml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | TYPE: effnet
3 | NUM_CLASSES: 1000
4 | EN:
5 | STEM_W: 32
6 | STRIDES: [1, 2, 2, 2, 1, 2, 1]
7 | DEPTHS: [2, 3, 3, 4, 4, 5, 2]
8 | WIDTHS: [16, 24, 40, 80, 112, 192, 320]
9 | EXP_RATIOS: [1, 6, 6, 6, 6, 6, 6]
10 | KERNELS: [3, 3, 5, 3, 5, 5, 3]
11 | HEAD_W: 1280
12 | OPTIM:
13 | LR_POLICY: cos
14 | BASE_LR: 0.4
15 | MAX_EPOCH: 100
16 | MOMENTUM: 0.9
17 | WEIGHT_DECAY: 1e-5
18 | TRAIN:
19 | DATASET: imagenet
20 | IM_SIZE: 240
21 | BATCH_SIZE: 256
22 | TEST:
23 | DATASET: imagenet
24 | IM_SIZE: 274
25 | BATCH_SIZE: 200
26 | NUM_GPUS: 8
27 | OUT_DIR: .
28 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B2_dds_8gpu.yaml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | TYPE: effnet
3 | NUM_CLASSES: 1000
4 | EN:
5 | STEM_W: 32
6 | STRIDES: [1, 2, 2, 2, 1, 2, 1]
7 | DEPTHS: [2, 3, 3, 4, 4, 5, 2]
8 | WIDTHS: [16, 24, 48, 88, 120, 208, 352]
9 | EXP_RATIOS: [1, 6, 6, 6, 6, 6, 6]
10 | KERNELS: [3, 3, 5, 3, 5, 5, 3]
11 | HEAD_W: 1408
12 | OPTIM:
13 | LR_POLICY: cos
14 | BASE_LR: 0.4
15 | MAX_EPOCH: 100
16 | MOMENTUM: 0.9
17 | WEIGHT_DECAY: 1e-5
18 | TRAIN:
19 | DATASET: imagenet
20 | IM_SIZE: 260
21 | BATCH_SIZE: 256
22 | TEST:
23 | DATASET: imagenet
24 | IM_SIZE: 298
25 | BATCH_SIZE: 200
26 | NUM_GPUS: 8
27 | OUT_DIR: .
28 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B3_dds_8gpu.yaml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | TYPE: effnet
3 | NUM_CLASSES: 1000
4 | EN:
5 | STEM_W: 40
6 | STRIDES: [1, 2, 2, 2, 1, 2, 1]
7 | DEPTHS: [2, 3, 3, 5, 5, 6, 2]
8 | WIDTHS: [24, 32, 48, 96, 136, 232, 384]
9 | EXP_RATIOS: [1, 6, 6, 6, 6, 6, 6]
10 | KERNELS: [3, 3, 5, 3, 5, 5, 3]
11 | HEAD_W: 1536
12 | OPTIM:
13 | LR_POLICY: cos
14 | BASE_LR: 0.4
15 | MAX_EPOCH: 100
16 | MOMENTUM: 0.9
17 | WEIGHT_DECAY: 1e-5
18 | TRAIN:
19 | DATASET: imagenet
20 | IM_SIZE: 300
21 | BATCH_SIZE: 256
22 | TEST:
23 | DATASET: imagenet
24 | IM_SIZE: 342
25 | BATCH_SIZE: 200
26 | NUM_GPUS: 8
27 | OUT_DIR: .
28 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B4_dds_8gpu.yaml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | TYPE: effnet
3 | NUM_CLASSES: 1000
4 | EN:
5 | STEM_W: 48
6 | STRIDES: [1, 2, 2, 2, 1, 2, 1]
7 | DEPTHS: [2, 4, 4, 6, 6, 8, 2]
8 | WIDTHS: [24, 32, 56, 112, 160, 272, 448]
9 | EXP_RATIOS: [1, 6, 6, 6, 6, 6, 6]
10 | KERNELS: [3, 3, 5, 3, 5, 5, 3]
11 | HEAD_W: 1792
12 | OPTIM:
13 | LR_POLICY: cos
14 | BASE_LR: 0.2
15 | MAX_EPOCH: 100
16 | MOMENTUM: 0.9
17 | WEIGHT_DECAY: 1e-5
18 | TRAIN:
19 | DATASET: imagenet
20 | IM_SIZE: 380
21 | BATCH_SIZE: 128
22 | TEST:
23 | DATASET: imagenet
24 | IM_SIZE: 434
25 | BATCH_SIZE: 104
26 | NUM_GPUS: 8
27 | OUT_DIR: .
28 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B5_dds_8gpu.yaml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | TYPE: effnet
3 | NUM_CLASSES: 1000
4 | EN:
5 | STEM_W: 48
6 | STRIDES: [1, 2, 2, 2, 1, 2, 1]
7 | DEPTHS: [3, 5, 5, 7, 7, 9, 3]
8 | WIDTHS: [24, 40, 64, 128, 176, 304, 512]
9 | EXP_RATIOS: [1, 6, 6, 6, 6, 6, 6]
10 | KERNELS: [3, 3, 5, 3, 5, 5, 3]
11 | HEAD_W: 2048
12 | OPTIM:
13 | LR_POLICY: cos
14 | BASE_LR: 0.1
15 | MAX_EPOCH: 100
16 | MOMENTUM: 0.9
17 | WEIGHT_DECAY: 1e-5
18 | TRAIN:
19 | DATASET: imagenet
20 | IM_SIZE: 456
21 | BATCH_SIZE: 64
22 | TEST:
23 | DATASET: imagenet
24 | IM_SIZE: 522
25 | BATCH_SIZE: 48
26 | NUM_GPUS: 8
27 | OUT_DIR: .
28 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-1.6GF_dds_8gpu.yaml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | TYPE: regnet
3 | NUM_CLASSES: 1000
4 | REGNET:
5 | DEPTH: 18
6 | W0: 80
7 | WA: 34.01
8 | WM: 2.25
9 | GROUP_W: 24
10 | OPTIM:
11 | LR_POLICY: cos
12 | BASE_LR: 0.8
13 | MAX_EPOCH: 100
14 | MOMENTUM: 0.9
15 | WEIGHT_DECAY: 5e-5
16 | WARMUP_EPOCHS: 5
17 | TRAIN:
18 | DATASET: imagenet
19 | IM_SIZE: 224
20 | BATCH_SIZE: 1024
21 | TEST:
22 | DATASET: imagenet
23 | IM_SIZE: 256
24 | BATCH_SIZE: 800
25 | NUM_GPUS: 8
26 | OUT_DIR: .
27 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-12GF_dds_8gpu.yaml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | TYPE: regnet
3 | NUM_CLASSES: 1000
4 | REGNET:
5 | DEPTH: 19
6 | W0: 168
7 | WA: 73.36
8 | WM: 2.37
9 | GROUP_W: 112
10 | OPTIM:
11 | LR_POLICY: cos
12 | BASE_LR: 0.4
13 | MAX_EPOCH: 100
14 | MOMENTUM: 0.9
15 | WEIGHT_DECAY: 5e-5
16 | WARMUP_EPOCHS: 5
17 | TRAIN:
18 | DATASET: imagenet
19 | IM_SIZE: 224
20 | BATCH_SIZE: 512
21 | TEST:
22 | DATASET: imagenet
23 | IM_SIZE: 256
24 | BATCH_SIZE: 400
25 | NUM_GPUS: 8
26 | OUT_DIR: .
27 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-16GF_dds_8gpu.yaml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | TYPE: regnet
3 | NUM_CLASSES: 1000
4 | REGNET:
5 | DEPTH: 22
6 | W0: 216
7 | WA: 55.59
8 | WM: 2.1
9 | GROUP_W: 128
10 | OPTIM:
11 | LR_POLICY: cos
12 | BASE_LR: 0.4
13 | MAX_EPOCH: 100
14 | MOMENTUM: 0.9
15 | WEIGHT_DECAY: 5e-5
16 | WARMUP_EPOCHS: 5
17 | TRAIN:
18 | DATASET: imagenet
19 | IM_SIZE: 224
20 | BATCH_SIZE: 512
21 | TEST:
22 | DATASET: imagenet
23 | IM_SIZE: 256
24 | BATCH_SIZE: 400
25 | NUM_GPUS: 8
26 | OUT_DIR: .
27 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-200MF_dds_8gpu.yaml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | TYPE: regnet
3 | NUM_CLASSES: 1000
4 | REGNET:
5 | DEPTH: 13
6 | W0: 24
7 | WA: 36.44
8 | WM: 2.49
9 | GROUP_W: 8
10 | OPTIM:
11 | LR_POLICY: cos
12 | BASE_LR: 0.8
13 | MAX_EPOCH: 100
14 | MOMENTUM: 0.9
15 | WEIGHT_DECAY: 5e-5
16 | WARMUP_EPOCHS: 5
17 | TRAIN:
18 | DATASET: imagenet
19 | IM_SIZE: 224
20 | BATCH_SIZE: 1024
21 | TEST:
22 | DATASET: imagenet
23 | IM_SIZE: 256
24 | BATCH_SIZE: 800
25 | NUM_GPUS: 8
26 | OUT_DIR: .
27 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-3.2GF_dds_8gpu.yaml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | TYPE: regnet
3 | NUM_CLASSES: 1000
4 | REGNET:
5 | DEPTH: 25
6 | W0: 88
7 | WA: 26.31
8 | WM: 2.25
9 | GROUP_W: 48
10 | OPTIM:
11 | LR_POLICY: cos
12 | BASE_LR: 0.4
13 | MAX_EPOCH: 100
14 | MOMENTUM: 0.9
15 | WEIGHT_DECAY: 5e-5
16 | WARMUP_EPOCHS: 5
17 | TRAIN:
18 | DATASET: imagenet
19 | IM_SIZE: 224
20 | BATCH_SIZE: 512
21 | TEST:
22 | DATASET: imagenet
23 | IM_SIZE: 256
24 | BATCH_SIZE: 400
25 | NUM_GPUS: 8
26 | OUT_DIR: .
27 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-32GF_dds_8gpu.yaml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | TYPE: regnet
3 | NUM_CLASSES: 1000
4 | REGNET:
5 | DEPTH: 23
6 | W0: 320
7 | WA: 69.86
8 | WM: 2.0
9 | GROUP_W: 168
10 | OPTIM:
11 | LR_POLICY: cos
12 | BASE_LR: 0.2
13 | MAX_EPOCH: 100
14 | MOMENTUM: 0.9
15 | WEIGHT_DECAY: 5e-5
16 | WARMUP_EPOCHS: 5
17 | TRAIN:
18 | DATASET: imagenet
19 | IM_SIZE: 224
20 | BATCH_SIZE: 256
21 | TEST:
22 | DATASET: imagenet
23 | IM_SIZE: 256
24 | BATCH_SIZE: 200
25 | NUM_GPUS: 8
26 | OUT_DIR: .
27 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-4.0GF_dds_8gpu.yaml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | TYPE: regnet
3 | NUM_CLASSES: 1000
4 | REGNET:
5 | DEPTH: 23
6 | W0: 96
7 | WA: 38.65
8 | WM: 2.43
9 | GROUP_W: 40
10 | OPTIM:
11 | LR_POLICY: cos
12 | BASE_LR: 0.4
13 | MAX_EPOCH: 100
14 | MOMENTUM: 0.9
15 | WEIGHT_DECAY: 5e-5
16 | WARMUP_EPOCHS: 5
17 | TRAIN:
18 | DATASET: imagenet
19 | IM_SIZE: 224
20 | BATCH_SIZE: 512
21 | TEST:
22 | DATASET: imagenet
23 | IM_SIZE: 256
24 | BATCH_SIZE: 400
25 | NUM_GPUS: 8
26 | OUT_DIR: .
27 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-400MF_dds_8gpu.yaml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | TYPE: regnet
3 | NUM_CLASSES: 1000
4 | REGNET:
5 | DEPTH: 22
6 | W0: 24
7 | WA: 24.48
8 | WM: 2.54
9 | GROUP_W: 16
10 | OPTIM:
11 | LR_POLICY: cos
12 | BASE_LR: 0.8
13 | MAX_EPOCH: 100
14 | MOMENTUM: 0.9
15 | WEIGHT_DECAY: 5e-5
16 | WARMUP_EPOCHS: 5
17 | TRAIN:
18 | DATASET: imagenet
19 | IM_SIZE: 224
20 | BATCH_SIZE: 1024
21 | TEST:
22 | DATASET: imagenet
23 | IM_SIZE: 256
24 | BATCH_SIZE: 800
25 | NUM_GPUS: 8
26 | OUT_DIR: .
27 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-6.4GF_dds_8gpu.yaml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | TYPE: regnet
3 | NUM_CLASSES: 1000
4 | REGNET:
5 | DEPTH: 17
6 | W0: 184
7 | WA: 60.83
8 | WM: 2.07
9 | GROUP_W: 56
10 | OPTIM:
11 | LR_POLICY: cos
12 | BASE_LR: 0.4
13 | MAX_EPOCH: 100
14 | MOMENTUM: 0.9
15 | WEIGHT_DECAY: 5e-5
16 | WARMUP_EPOCHS: 5
17 | TRAIN:
18 | DATASET: imagenet
19 | IM_SIZE: 224
20 | BATCH_SIZE: 512
21 | TEST:
22 | DATASET: imagenet
23 | IM_SIZE: 256
24 | BATCH_SIZE: 400
25 | NUM_GPUS: 8
26 | OUT_DIR: .
27 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-600MF_dds_8gpu.yaml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | TYPE: regnet
3 | NUM_CLASSES: 1000
4 | REGNET:
5 | DEPTH: 16
6 | W0: 48
7 | WA: 36.97
8 | WM: 2.24
9 | GROUP_W: 24
10 | OPTIM:
11 | LR_POLICY: cos
12 | BASE_LR: 0.8
13 | MAX_EPOCH: 100
14 | MOMENTUM: 0.9
15 | WEIGHT_DECAY: 5e-5
16 | WARMUP_EPOCHS: 5
17 | TRAIN:
18 | DATASET: imagenet
19 | IM_SIZE: 224
20 | BATCH_SIZE: 1024
21 | TEST:
22 | DATASET: imagenet
23 | IM_SIZE: 256
24 | BATCH_SIZE: 800
25 | NUM_GPUS: 8
26 | OUT_DIR: .
27 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-8.0GF_dds_8gpu.yaml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | TYPE: regnet
3 | NUM_CLASSES: 1000
4 | REGNET:
5 | DEPTH: 23
6 | W0: 80
7 | WA: 49.56
8 | WM: 2.88
9 | GROUP_W: 120
10 | OPTIM:
11 | LR_POLICY: cos
12 | BASE_LR: 0.4
13 | MAX_EPOCH: 100
14 | MOMENTUM: 0.9
15 | WEIGHT_DECAY: 5e-5
16 | WARMUP_EPOCHS: 5
17 | TRAIN:
18 | DATASET: imagenet
19 | IM_SIZE: 224
20 | BATCH_SIZE: 512
21 | TEST:
22 | DATASET: imagenet
23 | IM_SIZE: 256
24 | BATCH_SIZE: 400
25 | NUM_GPUS: 8
26 | OUT_DIR: .
27 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-800MF_dds_8gpu.yaml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | TYPE: regnet
3 | NUM_CLASSES: 1000
4 | REGNET:
5 | DEPTH: 16
6 | W0: 56
7 | WA: 35.73
8 | WM: 2.28
9 | GROUP_W: 16
10 | OPTIM:
11 | LR_POLICY: cos
12 | BASE_LR: 0.8
13 | MAX_EPOCH: 100
14 | MOMENTUM: 0.9
15 | WEIGHT_DECAY: 5e-5
16 | WARMUP_EPOCHS: 5
17 | TRAIN:
18 | DATASET: imagenet
19 | IM_SIZE: 224
20 | BATCH_SIZE: 1024
21 | TEST:
22 | DATASET: imagenet
23 | IM_SIZE: 256
24 | BATCH_SIZE: 800
25 | NUM_GPUS: 8
26 | OUT_DIR: .
27 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-1.6GF_dds_8gpu.yaml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | TYPE: regnet
3 | NUM_CLASSES: 1000
4 | REGNET:
5 | SE_ON: True
6 | DEPTH: 27
7 | W0: 48
8 | WA: 20.71
9 | WM: 2.65
10 | GROUP_W: 24
11 | OPTIM:
12 | LR_POLICY: cos
13 | BASE_LR: 0.8
14 | MAX_EPOCH: 100
15 | MOMENTUM: 0.9
16 | WEIGHT_DECAY: 5e-5
17 | WARMUP_EPOCHS: 5
18 | TRAIN:
19 | DATASET: imagenet
20 | IM_SIZE: 224
21 | BATCH_SIZE: 1024
22 | TEST:
23 | DATASET: imagenet
24 | IM_SIZE: 256
25 | BATCH_SIZE: 800
26 | NUM_GPUS: 8
27 | OUT_DIR: .
28 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-12GF_dds_8gpu.yaml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | TYPE: regnet
3 | NUM_CLASSES: 1000
4 | REGNET:
5 | SE_ON: True
6 | DEPTH: 19
7 | W0: 168
8 | WA: 73.36
9 | WM: 2.37
10 | GROUP_W: 112
11 | OPTIM:
12 | LR_POLICY: cos
13 | BASE_LR: 0.4
14 | MAX_EPOCH: 100
15 | MOMENTUM: 0.9
16 | WEIGHT_DECAY: 5e-5
17 | WARMUP_EPOCHS: 5
18 | TRAIN:
19 | DATASET: imagenet
20 | IM_SIZE: 224
21 | BATCH_SIZE: 512
22 | TEST:
23 | DATASET: imagenet
24 | IM_SIZE: 256
25 | BATCH_SIZE: 400
26 | NUM_GPUS: 8
27 | OUT_DIR: .
28 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-16GF_dds_8gpu.yaml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | TYPE: regnet
3 | NUM_CLASSES: 1000
4 | REGNET:
5 | SE_ON: True
6 | DEPTH: 18
7 | W0: 200
8 | WA: 106.23
9 | WM: 2.48
10 | GROUP_W: 112
11 | OPTIM:
12 | LR_POLICY: cos
13 | BASE_LR: 0.2
14 | MAX_EPOCH: 100
15 | MOMENTUM: 0.9
16 | WEIGHT_DECAY: 5e-5
17 | WARMUP_EPOCHS: 5
18 | TRAIN:
19 | DATASET: imagenet
20 | IM_SIZE: 224
21 | BATCH_SIZE: 256
22 | TEST:
23 | DATASET: imagenet
24 | IM_SIZE: 256
25 | BATCH_SIZE: 200
26 | NUM_GPUS: 8
27 | OUT_DIR: .
28 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-200MF_dds_8gpu.yaml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | TYPE: regnet
3 | NUM_CLASSES: 1000
4 | REGNET:
5 | SE_ON: True
6 | DEPTH: 13
7 | W0: 24
8 | WA: 36.44
9 | WM: 2.49
10 | GROUP_W: 8
11 | OPTIM:
12 | LR_POLICY: cos
13 | BASE_LR: 0.8
14 | MAX_EPOCH: 100
15 | MOMENTUM: 0.9
16 | WEIGHT_DECAY: 5e-5
17 | WARMUP_EPOCHS: 5
18 | TRAIN:
19 | DATASET: imagenet
20 | IM_SIZE: 224
21 | BATCH_SIZE: 1024
22 | TEST:
23 | DATASET: imagenet
24 | IM_SIZE: 256
25 | BATCH_SIZE: 800
26 | NUM_GPUS: 8
27 | OUT_DIR: .
28 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-3.2GF_dds_8gpu.yaml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | TYPE: regnet
3 | NUM_CLASSES: 1000
4 | REGNET:
5 | SE_ON: True
6 | DEPTH: 21
7 | W0: 80
8 | WA: 42.63
9 | WM: 2.66
10 | GROUP_W: 24
11 | OPTIM:
12 | LR_POLICY: cos
13 | BASE_LR: 0.4
14 | MAX_EPOCH: 100
15 | MOMENTUM: 0.9
16 | WEIGHT_DECAY: 5e-5
17 | WARMUP_EPOCHS: 5
18 | TRAIN:
19 | DATASET: imagenet
20 | IM_SIZE: 224
21 | BATCH_SIZE: 512
22 | TEST:
23 | DATASET: imagenet
24 | IM_SIZE: 256
25 | BATCH_SIZE: 400
26 | NUM_GPUS: 8
27 | OUT_DIR: .
28 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-32GF_dds_8gpu.yaml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | TYPE: regnet
3 | NUM_CLASSES: 1000
4 | REGNET:
5 | SE_ON: True
6 | DEPTH: 20
7 | W0: 232
8 | WA: 115.89
9 | WM: 2.53
10 | GROUP_W: 232
11 | OPTIM:
12 | LR_POLICY: cos
13 | BASE_LR: 0.2
14 | MAX_EPOCH: 100
15 | MOMENTUM: 0.9
16 | WEIGHT_DECAY: 5e-5
17 | WARMUP_EPOCHS: 5
18 | TRAIN:
19 | DATASET: imagenet
20 | IM_SIZE: 224
21 | BATCH_SIZE: 256
22 | TEST:
23 | DATASET: imagenet
24 | IM_SIZE: 256
25 | BATCH_SIZE: 200
26 | NUM_GPUS: 8
27 | OUT_DIR: .
28 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-4.0GF_dds_8gpu.yaml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | TYPE: regnet
3 | NUM_CLASSES: 1000
4 | REGNET:
5 | SE_ON: True
6 | DEPTH: 22
7 | W0: 96
8 | WA: 31.41
9 | WM: 2.24
10 | GROUP_W: 64
11 | OPTIM:
12 | LR_POLICY: cos
13 | BASE_LR: 0.4
14 | MAX_EPOCH: 100
15 | MOMENTUM: 0.9
16 | WEIGHT_DECAY: 5e-5
17 | WARMUP_EPOCHS: 5
18 | TRAIN:
19 | DATASET: imagenet
20 | IM_SIZE: 224
21 | BATCH_SIZE: 512
22 | TEST:
23 | DATASET: imagenet
24 | IM_SIZE: 256
25 | BATCH_SIZE: 400
26 | NUM_GPUS: 8
27 | OUT_DIR: .
28 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-400MF_dds_8gpu.yaml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | TYPE: regnet
3 | NUM_CLASSES: 1000
4 | REGNET:
5 | SE_ON: True
6 | DEPTH: 16
7 | W0: 48
8 | WA: 27.89
9 | WM: 2.09
10 | GROUP_W: 8
11 | OPTIM:
12 | LR_POLICY: cos
13 | BASE_LR: 0.8
14 | MAX_EPOCH: 100
15 | MOMENTUM: 0.9
16 | WEIGHT_DECAY: 5e-5
17 | WARMUP_EPOCHS: 5
18 | TRAIN:
19 | DATASET: imagenet
20 | IM_SIZE: 224
21 | BATCH_SIZE: 1024
22 | TEST:
23 | DATASET: imagenet
24 | IM_SIZE: 256
25 | BATCH_SIZE: 800
26 | NUM_GPUS: 8
27 | OUT_DIR: .
28 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-6.4GF_dds_8gpu.yaml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | TYPE: regnet
3 | NUM_CLASSES: 1000
4 | REGNET:
5 | SE_ON: True
6 | DEPTH: 25
7 | W0: 112
8 | WA: 33.22
9 | WM: 2.27
10 | GROUP_W: 72
11 | OPTIM:
12 | LR_POLICY: cos
13 | BASE_LR: 0.4
14 | MAX_EPOCH: 100
15 | MOMENTUM: 0.9
16 | WEIGHT_DECAY: 5e-5
17 | WARMUP_EPOCHS: 5
18 | TRAIN:
19 | DATASET: imagenet
20 | IM_SIZE: 224
21 | BATCH_SIZE: 512
22 | TEST:
23 | DATASET: imagenet
24 | IM_SIZE: 256
25 | BATCH_SIZE: 400
26 | NUM_GPUS: 8
27 | OUT_DIR: .
28 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-600MF_dds_8gpu.yaml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | TYPE: regnet
3 | NUM_CLASSES: 1000
4 | REGNET:
5 | SE_ON: True
6 | DEPTH: 15
7 | W0: 48
8 | WA: 32.54
9 | WM: 2.32
10 | GROUP_W: 16
11 | OPTIM:
12 | LR_POLICY: cos
13 | BASE_LR: 0.8
14 | MAX_EPOCH: 100
15 | MOMENTUM: 0.9
16 | WEIGHT_DECAY: 5e-5
17 | WARMUP_EPOCHS: 5
18 | TRAIN:
19 | DATASET: imagenet
20 | IM_SIZE: 224
21 | BATCH_SIZE: 1024
22 | TEST:
23 | DATASET: imagenet
24 | IM_SIZE: 256
25 | BATCH_SIZE: 800
26 | NUM_GPUS: 8
27 | OUT_DIR: .
28 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-8.0GF_dds_8gpu.yaml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | TYPE: regnet
3 | NUM_CLASSES: 1000
4 | REGNET:
5 | SE_ON: true
6 | DEPTH: 17
7 | W0: 192
8 | WA: 76.82
9 | WM: 2.19
10 | GROUP_W: 56
11 | OPTIM:
12 | LR_POLICY: cos
13 | BASE_LR: 0.4
14 | MAX_EPOCH: 100
15 | MOMENTUM: 0.9
16 | WEIGHT_DECAY: 5e-5
17 | WARMUP_EPOCHS: 5
18 | TRAIN:
19 | DATASET: imagenet
20 | IM_SIZE: 224
21 | BATCH_SIZE: 512
22 | TEST:
23 | DATASET: imagenet
24 | IM_SIZE: 256
25 | BATCH_SIZE: 400
26 | NUM_GPUS: 8
27 | OUT_DIR: .
28 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-800MF_dds_8gpu.yaml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | TYPE: regnet
3 | NUM_CLASSES: 1000
4 | REGNET:
5 | SE_ON: True
6 | DEPTH: 14
7 | W0: 56
8 | WA: 38.84
9 | WM: 2.4
10 | GROUP_W: 16
11 | OPTIM:
12 | LR_POLICY: cos
13 | BASE_LR: 0.8
14 | MAX_EPOCH: 100
15 | MOMENTUM: 0.9
16 | WEIGHT_DECAY: 5e-5
17 | WARMUP_EPOCHS: 5
18 | TRAIN:
19 | DATASET: imagenet
20 | IM_SIZE: 224
21 | BATCH_SIZE: 1024
22 | TEST:
23 | DATASET: imagenet
24 | IM_SIZE: 256
25 | BATCH_SIZE: 800
26 | NUM_GPUS: 8
27 | OUT_DIR: .
28 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/heads/__init__.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: liaoxingyu
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | from .build import REID_HEADS_REGISTRY, build_heads
8 |
9 | # import all the meta_arch, so they will be registered
10 | from .embedding_head import EmbeddingHead
11 | from .attr_head import AttrHead
12 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/heads/build.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: liaoxingyu
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | from ...utils.registry import Registry
8 |
9 | REID_HEADS_REGISTRY = Registry("HEADS")
10 | REID_HEADS_REGISTRY.__doc__ = """
11 | Registry for ROI heads in a generalized R-CNN model.
12 | ROIHeads take feature maps and region proposals, and
13 | perform per-region computation.
14 | The registered object will be called with `obj(cfg, input_shape)`.
15 | The call is expected to return an :class:`ROIHeads`.
16 | """
17 |
18 |
19 | def build_heads(cfg):
20 | """
21 | Build REIDHeads defined by `cfg.MODEL.REID_HEADS.NAME`.
22 | """
23 | head = cfg.MODEL.HEADS.NAME
24 | return REID_HEADS_REGISTRY.get(head)(cfg)
25 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/losses/__init__.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: l1aoxingyu
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | from .cross_entroy_loss import cross_entropy_loss, log_accuracy
8 | from .focal_loss import focal_loss
9 | from .triplet_loss import triplet_loss
10 | from .circle_loss import circle_loss
11 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/losses/circle_loss.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: xingyu liao
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | import torch
8 | import torch.nn.functional as F
9 | from torch import nn
10 |
11 | from fastreid.utils import comm
12 | from .utils import concat_all_gather
13 |
14 |
15 | def circle_loss(
16 | embedding: torch.Tensor,
17 | targets: torch.Tensor,
18 | margin: float,
19 | alpha: float,) -> torch.Tensor:
20 | embedding = nn.functional.normalize(embedding, dim=1)
21 |
22 | if comm.get_world_size() > 1:
23 | all_embedding = concat_all_gather(embedding)
24 | all_targets = concat_all_gather(targets)
25 | else:
26 | all_embedding = embedding
27 | all_targets = targets
28 |
29 | dist_mat = torch.matmul(all_embedding, all_embedding.t())
30 |
31 | N = dist_mat.size(0)
32 | is_pos = all_targets.view(N, 1).expand(N, N).eq(all_targets.view(N, 1).expand(N, N).t()).float()
33 |
34 | # Compute the mask which ignores the relevance score of the query to itself
35 | is_pos = is_pos - torch.eye(N, N, device=is_pos.device)
36 |
37 | is_neg = all_targets.view(N, 1).expand(N, N).ne(all_targets.view(N, 1).expand(N, N).t())
38 |
39 | s_p = dist_mat * is_pos
40 | s_n = dist_mat * is_neg
41 |
42 | alpha_p = torch.clamp_min(-s_p.detach() + 1 + margin, min=0.)
43 | alpha_n = torch.clamp_min(s_n.detach() + margin, min=0.)
44 | delta_p = 1 - margin
45 | delta_n = margin
46 |
47 | logit_p = - alpha * alpha_p * (s_p - delta_p)
48 | logit_n = alpha * alpha_n * (s_n - delta_n)
49 |
50 | loss = nn.functional.softplus(torch.logsumexp(logit_p, dim=1) + torch.logsumexp(logit_n, dim=1)).mean()
51 |
52 | return loss
53 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/losses/cross_entroy_loss.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: l1aoxingyu
4 | @contact: sherlockliao01@gmail.com
5 | """
6 | import torch
7 | import torch.nn.functional as F
8 |
9 | from fastreid.utils.events import get_event_storage
10 |
11 |
12 | def log_accuracy(pred_class_logits, gt_classes, topk=(1,)):
13 | """
14 | Log the accuracy metrics to EventStorage.
15 | """
16 | bsz = pred_class_logits.size(0)
17 | maxk = max(topk)
18 | _, pred_class = pred_class_logits.topk(maxk, 1, True, True)
19 | pred_class = pred_class.t()
20 | correct = pred_class.eq(gt_classes.view(1, -1).expand_as(pred_class))
21 |
22 | ret = []
23 | for k in topk:
24 | correct_k = correct[:k].view(-1).float().sum(dim=0, keepdim=True)
25 | ret.append(correct_k.mul_(1. / bsz))
26 |
27 | storage = get_event_storage()
28 | storage.put_scalar("cls_accuracy", ret[0])
29 |
30 |
31 | def cross_entropy_loss(pred_class_logits, gt_classes, eps, alpha=0.2):
32 | num_classes = pred_class_logits.size(1)
33 |
34 | if eps >= 0:
35 | smooth_param = eps
36 | else:
37 | # Adaptive label smooth regularization
38 | soft_label = F.softmax(pred_class_logits, dim=1)
39 | smooth_param = alpha * soft_label[torch.arange(soft_label.size(0)), gt_classes].unsqueeze(1)
40 |
41 | log_probs = F.log_softmax(pred_class_logits, dim=1)
42 | with torch.no_grad():
43 | targets = torch.ones_like(log_probs)
44 | targets *= smooth_param / (num_classes - 1)
45 | targets.scatter_(1, gt_classes.data.unsqueeze(1), (1 - smooth_param))
46 |
47 | loss = (-targets * log_probs).sum(dim=1)
48 |
49 | """
50 | # confidence penalty
51 | conf_penalty = 0.3
52 | probs = F.softmax(pred_class_logits, dim=1)
53 | entropy = torch.sum(-probs * log_probs, dim=1)
54 | loss = torch.clamp_min(loss - conf_penalty * entropy, min=0.)
55 | """
56 |
57 | with torch.no_grad():
58 | non_zero_cnt = max(loss.nonzero(as_tuple=False).size(0), 1)
59 |
60 | loss = loss.sum() / non_zero_cnt
61 |
62 | return loss
63 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/losses/utils.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: xingyu liao
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | import torch
8 |
9 |
10 | def concat_all_gather(tensor):
11 | """
12 | Performs all_gather operation on the provided tensors.
13 | *** Warning ***: torch.distributed.all_gather has no gradient.
14 | """
15 | tensors_gather = [torch.ones_like(tensor)
16 | for _ in range(torch.distributed.get_world_size())]
17 | torch.distributed.all_gather(tensors_gather, tensor, async_op=False)
18 |
19 | output = torch.cat(tensors_gather, dim=0)
20 | return output
21 |
22 |
23 | def normalize(x, axis=-1):
24 | """Normalizing to unit length along the specified dimension.
25 | Args:
26 | x: pytorch Variable
27 | Returns:
28 | x: pytorch Variable, same shape as input
29 | """
30 | x = 1. * x / (torch.norm(x, 2, axis, keepdim=True).expand_as(x) + 1e-12)
31 | return x
32 |
33 |
34 | def euclidean_dist(x, y):
35 | m, n = x.size(0), y.size(0)
36 | xx = torch.pow(x, 2).sum(1, keepdim=True).expand(m, n)
37 | yy = torch.pow(y, 2).sum(1, keepdim=True).expand(n, m).t()
38 | dist = xx + yy - 2 * torch.matmul(x, y.t())
39 | dist = dist.clamp(min=1e-12).sqrt() # for numerical stability
40 | return dist
41 |
42 |
43 | def cosine_dist(x, y):
44 | bs1, bs2 = x.size(0), y.size(0)
45 | frac_up = torch.matmul(x, y.transpose(0, 1))
46 | frac_down = (torch.sqrt(torch.sum(torch.pow(x, 2), 1))).view(bs1, 1).repeat(1, bs2) * \
47 | (torch.sqrt(torch.sum(torch.pow(y, 2), 1))).view(1, bs2).repeat(bs1, 1)
48 | cosine = frac_up / frac_down
49 | return 1 - cosine
50 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/meta_arch/__init__.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: liaoxingyu
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | from .build import META_ARCH_REGISTRY, build_model
8 |
9 |
10 | # import all the meta_arch, so they will be registered
11 | from .baseline import Baseline
12 | from .mgn import MGN
13 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/modeling/meta_arch/build.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: liaoxingyu
4 | @contact: sherlockliao01@gmail.com
5 | """
6 | import torch
7 |
8 | from fastreid.utils.registry import Registry
9 |
10 | META_ARCH_REGISTRY = Registry("META_ARCH") # noqa F401 isort:skip
11 | META_ARCH_REGISTRY.__doc__ = """
12 | Registry for meta-architectures, i.e. the whole model.
13 | The registered object will be called with `obj(cfg)`
14 | and expected to return a `nn.Module` object.
15 | """
16 |
17 |
18 | def build_model(cfg):
19 | """
20 | Build the whole model architecture, defined by ``cfg.MODEL.META_ARCHITECTURE``.
21 | Note that it does not load any weights from ``cfg``.
22 | """
23 | meta_arch = cfg.MODEL.META_ARCHITECTURE
24 | model = META_ARCH_REGISTRY.get(meta_arch)(cfg)
25 | model.to(torch.device(cfg.MODEL.DEVICE))
26 | return model
27 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/solver/__init__.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: liaoxingyu
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 |
8 | from .build import build_lr_scheduler, build_optimizer
--------------------------------------------------------------------------------
/fast-reid/fastreid/solver/build.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: liaoxingyu
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | from . import lr_scheduler
8 | from . import optim
9 | from torch import nn
10 |
11 | def build_optimizer(cfg, model):
12 | params = []
13 | for key, value in model.named_parameters():
14 | if not value.requires_grad: continue
15 |
16 | lr = cfg.SOLVER.BASE_LR
17 | weight_decay = cfg.SOLVER.WEIGHT_DECAY
18 | if "heads" in key: # for projection head, they may have larger LR
19 | lr *= cfg.SOLVER.HEADS_LR_FACTOR
20 | else: # for backbone, they may have different for convs and bns
21 | if 'bn' in key or 'downsample.1' in key:
22 | lr *= cfg.SOLVER.BACKBONE_BN_LR_FACTOR
23 | elif 'backbone.1' in key and isinstance(model.backbone[1], nn.BatchNorm2d):
24 | lr *= cfg.SOLVER.BACKBONE_BN_LR_FACTOR
25 | if "bias" in key:
26 | lr *= cfg.SOLVER.BIAS_LR_FACTOR
27 | weight_decay = cfg.SOLVER.WEIGHT_DECAY_BIAS
28 | params += [{"name": key, "params": [value], "lr": lr,
29 | "weight_decay": weight_decay, "freeze": False}]
30 |
31 | solver_opt = cfg.SOLVER.OPT
32 | # fmt: off
33 | if solver_opt == "SGD": opt_fns = getattr(optim, solver_opt)(params, momentum=cfg.SOLVER.MOMENTUM)
34 | else: opt_fns = getattr(optim, solver_opt)(params)
35 | # fmt: on
36 | return opt_fns
37 |
38 |
39 | def build_lr_scheduler(cfg, optimizer):
40 | scheduler_args = {
41 | "optimizer": optimizer,
42 |
43 | # warmup options
44 | "warmup_factor": cfg.SOLVER.WARMUP_FACTOR,
45 | "warmup_iters": cfg.SOLVER.WARMUP_ITERS,
46 | "warmup_method": cfg.SOLVER.WARMUP_METHOD,
47 |
48 | # multi-step lr scheduler options
49 | "milestones": cfg.SOLVER.STEPS,
50 | "gamma": cfg.SOLVER.GAMMA,
51 |
52 | # cosine annealing lr scheduler options
53 | "max_iters": cfg.SOLVER.MAX_ITER,
54 | "delay_iters": cfg.SOLVER.DELAY_ITERS,
55 | "eta_min_lr": cfg.SOLVER.ETA_MIN_LR,
56 |
57 | }
58 | return getattr(lr_scheduler, cfg.SOLVER.SCHED)(**scheduler_args)
59 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/solver/optim/__init__.py:
--------------------------------------------------------------------------------
1 | from .lamb import Lamb
2 | from .swa import SWA
3 | from .adam import Adam
4 | from .sgd import SGD
5 |
6 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/utils/__init__.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: sherlock
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/utils/history_buffer.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
3 |
4 | import numpy as np
5 | from typing import List, Tuple
6 |
7 |
8 | class HistoryBuffer:
9 | """
10 | Track a series of scalar values and provide access to smoothed values over a
11 | window or the global average of the series.
12 | """
13 |
14 | def __init__(self, max_length: int = 1000000):
15 | """
16 | Args:
17 | max_length: maximal number of values that can be stored in the
18 | buffer. When the capacity of the buffer is exhausted, old
19 | values will be removed.
20 | """
21 | self._max_length: int = max_length
22 | self._data: List[Tuple[float, float]] = [] # (value, iteration) pairs
23 | self._count: int = 0
24 | self._global_avg: float = 0
25 |
26 | def update(self, value: float, iteration: float = None):
27 | """
28 | Add a new scalar value produced at certain iteration. If the length
29 | of the buffer exceeds self._max_length, the oldest element will be
30 | removed from the buffer.
31 | """
32 | if iteration is None:
33 | iteration = self._count
34 | if len(self._data) == self._max_length:
35 | self._data.pop(0)
36 | self._data.append((value, iteration))
37 |
38 | self._count += 1
39 | self._global_avg += (value - self._global_avg) / self._count
40 |
41 | def latest(self):
42 | """
43 | Return the latest scalar value added to the buffer.
44 | """
45 | return self._data[-1][0]
46 |
47 | def median(self, window_size: int):
48 | """
49 | Return the median of the latest `window_size` values in the buffer.
50 | """
51 | return np.median([x[0] for x in self._data[-window_size:]])
52 |
53 | def avg(self, window_size: int):
54 | """
55 | Return the mean of the latest `window_size` values in the buffer.
56 | """
57 | return np.mean([x[0] for x in self._data[-window_size:]])
58 |
59 | def global_avg(self):
60 | """
61 | Return the mean of all the elements in the buffer. Note that this
62 | includes those getting removed due to limited buffer storage.
63 | """
64 | return self._global_avg
65 |
66 | def values(self):
67 | """
68 | Returns:
69 | list[(number, iteration)]: content of the current buffer.
70 | """
71 | return self._data
72 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/utils/registry.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
3 |
4 | from typing import Dict, Optional
5 |
6 |
7 | class Registry(object):
8 | """
9 | The registry that provides name -> object mapping, to support third-party
10 | users' custom modules.
11 | To create a registry (e.g. a backbone registry):
12 | .. code-block:: python
13 | BACKBONE_REGISTRY = Registry('BACKBONE')
14 | To register an object:
15 | .. code-block:: python
16 | @BACKBONE_REGISTRY.register()
17 | class MyBackbone():
18 | ...
19 | Or:
20 | .. code-block:: python
21 | BACKBONE_REGISTRY.register(MyBackbone)
22 | """
23 |
24 | def __init__(self, name: str) -> None:
25 | """
26 | Args:
27 | name (str): the name of this registry
28 | """
29 | self._name: str = name
30 | self._obj_map: Dict[str, object] = {}
31 |
32 | def _do_register(self, name: str, obj: object) -> None:
33 | assert (
34 | name not in self._obj_map
35 | ), "An object named '{}' was already registered in '{}' registry!".format(
36 | name, self._name
37 | )
38 | self._obj_map[name] = obj
39 |
40 | def register(self, obj: object = None) -> Optional[object]:
41 | """
42 | Register the given object under the the name `obj.__name__`.
43 | Can be used as either a decorator or not. See docstring of this class for usage.
44 | """
45 | if obj is None:
46 | # used as a decorator
47 | def deco(func_or_class: object) -> object:
48 | name = func_or_class.__name__ # pyre-ignore
49 | self._do_register(name, func_or_class)
50 | return func_or_class
51 |
52 | return deco
53 |
54 | # used as a function call
55 | name = obj.__name__ # pyre-ignore
56 | self._do_register(name, obj)
57 |
58 | def get(self, name: str) -> object:
59 | ret = self._obj_map.get(name)
60 | if ret is None:
61 | raise KeyError(
62 | "No object named '{}' found in '{}' registry!".format(
63 | name, self._name
64 | )
65 | )
66 | return ret
67 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/utils/timer.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
2 | # -*- coding: utf-8 -*-
3 |
4 | from time import perf_counter
5 | from typing import Optional
6 |
7 |
8 | class Timer:
9 | """
10 | A timer which computes the time elapsed since the start/reset of the timer.
11 | """
12 |
13 | def __init__(self):
14 | self.reset()
15 |
16 | def reset(self):
17 | """
18 | Reset the timer.
19 | """
20 | self._start = perf_counter()
21 | self._paused: Optional[float] = None
22 | self._total_paused = 0
23 | self._count_start = 1
24 |
25 | def pause(self):
26 | """
27 | Pause the timer.
28 | """
29 | if self._paused is not None:
30 | raise ValueError("Trying to pause a Timer that is already paused!")
31 | self._paused = perf_counter()
32 |
33 | def is_paused(self) -> bool:
34 | """
35 | Returns:
36 | bool: whether the timer is currently paused
37 | """
38 | return self._paused is not None
39 |
40 | def resume(self):
41 | """
42 | Resume the timer.
43 | """
44 | if self._paused is None:
45 | raise ValueError("Trying to resume a Timer that is not paused!")
46 | self._total_paused += perf_counter() - self._paused
47 | self._paused = None
48 | self._count_start += 1
49 |
50 | def seconds(self) -> float:
51 | """
52 | Returns:
53 | (float): the total number of seconds since the start/reset of the
54 | timer, excluding the time when the timer is paused.
55 | """
56 | if self._paused is not None:
57 | end_time: float = self._paused # type: ignore
58 | else:
59 | end_time = perf_counter()
60 | return end_time - self._start - self._total_paused
61 |
62 | def avg_seconds(self) -> float:
63 | """
64 | Returns:
65 | (float): the average number of seconds between every start/reset and
66 | pause.
67 | """
68 | return self.seconds() / self._count_start
69 |
--------------------------------------------------------------------------------
/fast-reid/fastreid/utils/weight_init.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: xingyu liao
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | import math
8 | from torch import nn
9 |
10 | __all__ = [
11 | 'weights_init_classifier',
12 | 'weights_init_kaiming',
13 | ]
14 |
15 |
16 | def weights_init_kaiming(m):
17 | classname = m.__class__.__name__
18 | if classname.find('Linear') != -1:
19 | nn.init.normal_(m.weight, 0, 0.01)
20 | if m.bias is not None:
21 | nn.init.constant_(m.bias, 0.0)
22 | elif classname.find('Conv') != -1:
23 | nn.init.kaiming_normal_(m.weight, mode='fan_out', nonlinearity='relu')
24 | if m.bias is not None:
25 | nn.init.constant_(m.bias, 0.0)
26 | elif classname.find('BatchNorm') != -1:
27 | if m.affine:
28 | nn.init.normal_(m.weight, 1.0, 0.02)
29 | nn.init.constant_(m.bias, 0.0)
30 |
31 |
32 | def weights_init_classifier(m):
33 | classname = m.__class__.__name__
34 | if classname.find('Linear') != -1:
35 | nn.init.normal_(m.weight, std=0.001)
36 | if m.bias is not None:
37 | nn.init.constant_(m.bias, 0.0)
38 |
--------------------------------------------------------------------------------
/fast-reid/projects/DistillReID/configs/Base-bot-kd.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../../../configs/Base-bagtricks.yml"
2 |
3 | MODEL_TEACHER:
4 | META_ARCHITECTURE: "Baseline"
5 |
6 | BACKBONE:
7 | NAME: "build_resnet_backbone"
8 | NORM: "BN"
9 | DEPTH: "101x"
10 | FEAT_DIM: 2048
11 | LAST_STRIDE: 1
12 | WITH_IBN: True
13 | PRETRAIN: True
14 |
15 | HEADS:
16 | NAME: "EmbeddingHead"
17 | NORM: "BN"
18 | POOL_LAYER: "avgpool"
19 | NECK_FEAT: "before"
20 | CLS_LAYER: "linear"
21 |
22 | MODEL:
23 | BACKBONE:
24 | NAME: "build_resnet_backbone"
25 | DEPTH: "50x"
26 | FEAT_DIM: 2048
27 | WITH_IBN: True
28 |
29 | STUDENT_WEIGHTS: ""
30 | TEACHER_WEIGHTS: "logs/dukemtmc/bagtricks_R34-ibn/model_final.pth"
--------------------------------------------------------------------------------
/fast-reid/projects/DistillReID/configs/Base-sbs-kd.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../../../configs/Base-Strongerbaseline.yml"
2 |
3 | MODEL_TEACHER:
4 | META_ARCHITECTURE: "Baseline"
5 |
6 | BACKBONE:
7 | NAME: "build_resnet_backbone"
8 | NORM: "BN"
9 | DEPTH: "101x"
10 | FEAT_DIM: 2048
11 | LAST_STRIDE: 1
12 | WITH_NL: False
13 | WITH_IBN: True
14 | PRETRAIN: True
15 |
16 | HEADS:
17 | NAME: "EmbeddingHead"
18 | NORM: "BN"
19 | NECK_FEAT: "after"
20 | POOL_LAYER: "gempoolP"
21 | CLS_LAYER: "circleSoftmax"
22 | SCALE: 64
23 | MARGIN: 0.35
24 |
25 | MODEL:
26 | BACKBONE:
27 | NAME: "build_resnet_backbone"
28 | DEPTH: "50x"
29 | FEAT_DIM: 2048
30 | WITH_IBN: True
31 |
32 | STUDENT_WEIGHTS: ""
33 | TEACHER_WEIGHTS: "logs/dukemtmc/bagtricks_R34-ibn/model_final.pth"
34 |
35 | INPUT:
36 | SIZE_TRAIN: [ 256, 128 ]
37 | SIZE_TEST: [ 256, 128 ]
38 |
--------------------------------------------------------------------------------
/fast-reid/projects/DistillReID/configs/DukeMTMC/KD-bot101ibn-bot18ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-bot-kd.yml"
2 |
3 | MODEL_TEACHER:
4 | BACKBONE:
5 | DEPTH: "101x"
6 | FEAT_DIM: 2048
7 |
8 | MODEL:
9 | BACKBONE:
10 | DEPTH: "18x"
11 | FEAT_DIM: 512
12 |
13 | STUDENT_WEIGHTS: ""
14 | TEACHER_WEIGHTS: "projects/DistillReID/logs/dukemtmc/bagtricks_R101-ibn"
15 |
16 | DATASETS:
17 | NAMES: ("DukeMTMC",)
18 | TESTS: ("DukeMTMC",)
19 |
20 | OUTPUT_DIR: "projects/DistillReID/logs/dukemtmc/bot101ibn-kd-bot18ibn"
--------------------------------------------------------------------------------
/fast-reid/projects/DistillReID/configs/DukeMTMC/KD-bot101ibn-bot50ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-bot-kd.yml"
2 |
3 | MODEL_TEACHER:
4 | BACKBONE:
5 | DEPTH: "101x"
6 | FEAT_DIM: 2048
7 |
8 | MODEL:
9 | BACKBONE:
10 | DEPTH: "50x"
11 | FEAT_DIM: 2048
12 |
13 | STUDENT_WEIGHTS: ""
14 | TEACHER_WEIGHTS: "projects/DistillReID/logs/dukemtmc/bagtricks_R101-ibn"
15 |
16 | DATASETS:
17 | NAMES: ("DukeMTMC",)
18 | TESTS: ("DukeMTMC",)
19 |
20 | OUTPUT_DIR: "projects/DistillReID/logs/dukemtmc/dukemtmc/bot101ibn-kd-bot50ibn"
--------------------------------------------------------------------------------
/fast-reid/projects/DistillReID/configs/DukeMTMC/KD-bot50ibn-bot18ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-bot-kd.yml"
2 |
3 | MODEL_TEACHER:
4 | BACKBONE:
5 | DEPTH: "50x"
6 | FEAT_DIM: 2048
7 |
8 | MODEL:
9 | BACKBONE:
10 | DEPTH: "18x"
11 | FEAT_DIM: 512
12 |
13 | STUDENT_WEIGHTS: ""
14 | TEACHER_WEIGHTS: "projects/DistillReID/logs/dukemtmc/bagtricks_R50-ibn/model_final.pth"
15 |
16 | DATASETS:
17 | NAMES: ("DukeMTMC",)
18 | TESTS: ("DukeMTMC",)
19 |
20 | OUTPUT_DIR: "projects/DistillReID/logs/dukemtmc/bot50ibn-kd-bot18ibn"
--------------------------------------------------------------------------------
/fast-reid/projects/DistillReID/configs/DukeMTMC/KD-sbs101ibn-sbs18ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-sbs-kd.yml"
2 |
3 | MODEL_TEACHER:
4 | BACKBONE:
5 | DEPTH: "101x"
6 | FEAT_DIM: 2048
7 |
8 | MODEL:
9 | BACKBONE:
10 | DEPTH: "34x"
11 | FEAT_DIM: 512
12 |
13 | STUDENT_WEIGHTS: ""
14 | TEACHER_WEIGHTS: "projects/DistillReID/logs/dukemtmc/sbs_R101-ibn/model_final.pth"
15 |
16 | DATASETS:
17 | NAMES: ("DukeMTMC",)
18 | TESTS: ("DukeMTMC",)
19 |
20 | OUTPUT_DIR: "projects/DistillReID/logs/dukemtmc/sbs101ibn-kd-sbs18ibn"
--------------------------------------------------------------------------------
/fast-reid/projects/DistillReID/configs/DukeMTMC/KD-sbs101ibn-sbs50ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-sbs-kd.yml"
2 |
3 | MODEL_TEACHER:
4 | BACKBONE:
5 | DEPTH: "101x"
6 | FEAT_DIM: 2048
7 |
8 | MODEL:
9 | BACKBONE:
10 | DEPTH: "50x"
11 | FEAT_DIM: 2048
12 |
13 | STUDENT_WEIGHTS: ""
14 | TEACHER_WEIGHTS: "projects/DistillReID/logs/dukemtmc/sbs_R101-ibn/model_final.pth"
15 |
16 | DATASETS:
17 | NAMES: ("DukeMTMC",)
18 | TESTS: ("DukeMTMC",)
19 |
20 | OUTPUT_DIR: "projects/DistillReID/logs/dukemtmc/sbs101ibn-kd-sbs50ibn"
--------------------------------------------------------------------------------
/fast-reid/projects/DistillReID/configs/DukeMTMC/KD-sbs50ibn-sbs18ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../Base-sbs-kd.yml"
2 |
3 | MODEL_TEACHER:
4 | BACKBONE:
5 | DEPTH: "50x"
6 | FEAT_DIM: 2048
7 |
8 | MODEL:
9 | BACKBONE:
10 | DEPTH: "18x"
11 | FEAT_DIM: 512
12 |
13 | STUDENT_WEIGHTS: ""
14 | TEACHER_WEIGHTS: "projects/DistillReID/logs/dukemtmc/sbs_R50-ibn/model_final.pth"
15 |
16 | DATASETS:
17 | NAMES: ("DukeMTMC",)
18 | TESTS: ("DukeMTMC",)
19 |
20 | OUTPUT_DIR: "projects/DistillReID/logs/dukemtmc/sbs50ibn-kd-sbs18ibn"
--------------------------------------------------------------------------------
/fast-reid/projects/DistillReID/configs/DukeMTMC/bot101ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../../../../configs/Base-bagtricks.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | DEPTH: "101x"
6 | WITH_IBN: True
7 |
8 | DATASETS:
9 | NAMES: ("DukeMTMC",)
10 | TESTS: ("DukeMTMC",)
11 |
12 | OUTPUT_DIR: "projects/DistillReID/logs/dukemtmc/bagtricks_R101-ibn"
--------------------------------------------------------------------------------
/fast-reid/projects/DistillReID/configs/DukeMTMC/bot18ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../../../../configs/Base-bagtricks.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | DEPTH: "18x"
6 | WITH_IBN: True
7 | FEAT_DIM: 512
8 |
9 | DATASETS:
10 | NAMES: ("DukeMTMC",)
11 | TESTS: ("DukeMTMC",)
12 |
13 | OUTPUT_DIR: "projects/DistillReID/logs/dukemtmc/bagtricks_R18-ibn"
--------------------------------------------------------------------------------
/fast-reid/projects/DistillReID/configs/DukeMTMC/bot50ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../../../../configs/Base-bagtricks.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | DEPTH: "50x"
6 | WITH_IBN: True
7 |
8 | DATASETS:
9 | NAMES: ("DukeMTMC",)
10 | TESTS: ("DukeMTMC",)
11 |
12 | OUTPUT_DIR: "projects/DistillReID/logs/dukemtmc/bagtricks_R50-ibn"
--------------------------------------------------------------------------------
/fast-reid/projects/DistillReID/configs/DukeMTMC/sbs101ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../../../configs/Base-Strongerbaseline.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | DEPTH: "101x"
6 | WITH_IBN: True
7 | FEAT_DIM: 2048
8 |
9 | DATASETS:
10 | NAMES: ("DukeMTMC",)
11 | TESTS: ("DukeMTMC",)
12 |
13 | OUTPUT_DIR: "projects/DistillReID/logs/dukemtmc/sbs_R101-ibn"
--------------------------------------------------------------------------------
/fast-reid/projects/DistillReID/configs/DukeMTMC/sbs18ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../../../configs/Base-Strongerbaseline.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | DEPTH: "18x"
6 | WITH_IBN: True
7 | FEAT_DIM: 512
8 |
9 | DATASETS:
10 | NAMES: ("DukeMTMC",)
11 | TESTS: ("DukeMTMC",)
12 |
13 | OUTPUT_DIR: "projects/DistillReID/logs/dukemtmc/sbs_R18-ibn"
--------------------------------------------------------------------------------
/fast-reid/projects/DistillReID/configs/DukeMTMC/sbs50ibn.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "../../../configs/Base-Strongerbaseline.yml"
2 |
3 | MODEL:
4 | BACKBONE:
5 | DEPTH: "50x"
6 | WITH_IBN: True
7 | FEAT_DIM: 2048
8 |
9 | DATASETS:
10 | NAMES: ("DukeMTMC",)
11 | TESTS: ("DukeMTMC",)
12 |
13 | OUTPUT_DIR: "projects/DistillReID/logs/dukemtmc/sbs_R50-ibn"
--------------------------------------------------------------------------------
/fast-reid/projects/DistillReID/kdreid/__init__.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: l1aoxingyu
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | from .config import add_kdreid_config, add_shufflenet_config
8 | from .kd_trainer import KDTrainer
9 | from .modeling import build_shufflenetv2_backbone
--------------------------------------------------------------------------------
/fast-reid/projects/DistillReID/kdreid/modeling/__init__.py:
--------------------------------------------------------------------------------
1 | from .backbones import build_shufflenetv2_backbone
--------------------------------------------------------------------------------
/fast-reid/projects/DistillReID/kdreid/modeling/backbones/__init__.py:
--------------------------------------------------------------------------------
1 | from .shufflenetv2 import build_shufflenetv2_backbone
--------------------------------------------------------------------------------
/fast-reid/projects/DistillReID/kdreid/modeling/backbones/shufflenetv2/__init__.py:
--------------------------------------------------------------------------------
1 | import torch
2 | import torch.nn as nn
3 | from collections import OrderedDict
4 |
5 | from fastreid.modeling.backbones.build import BACKBONE_REGISTRY
6 | from .network import ShuffleNetV2
7 |
8 |
9 | __all__ = ['build_shufflenetv2_backbone']
10 |
11 |
12 | @BACKBONE_REGISTRY.register()
13 | def build_shufflenetv2_backbone(cfg):
14 |
15 | pretrain = cfg.MODEL.BACKBONE.PRETRAIN
16 | pretrain_path = cfg.MODEL.BACKBONE.PRETRAIN_PATH
17 | model_size = cfg.MODEL.BACKBONE.MODEL_SIZE
18 |
19 | return ShuffleNetV2Backbone(model_size=model_size, pretrained=pretrain, pretrain_path=pretrain_path)
20 |
21 |
22 | class ShuffleNetV2Backbone(nn.Module):
23 |
24 | def __init__(self, model_size, pretrained=False, pretrain_path=''):
25 | super(ShuffleNetV2Backbone, self).__init__()
26 |
27 | model = ShuffleNetV2(model_size=model_size)
28 | if pretrained:
29 | new_state_dict = OrderedDict()
30 | state_dict = torch.load(pretrain_path)['state_dict']
31 | for k, v in state_dict.items():
32 | if k[:7] == 'module.':
33 | k = k[7:]
34 | new_state_dict[k] = v
35 | model.load_state_dict(new_state_dict, strict=True)
36 |
37 | self.backbone = nn.Sequential(
38 | model.first_conv, model.maxpool, model.features, model.conv_last)
39 |
40 | def forward(self, x):
41 | return self.backbone(x)
42 |
43 |
44 |
--------------------------------------------------------------------------------
/fast-reid/projects/DistillReID/train_net.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # encoding: utf-8
3 | """
4 | @author: sherlock, guan'an wang
5 | @contact: sherlockliao01@gmail.com, guan.wang0706@gmail.com
6 | """
7 |
8 | import sys
9 | import torch
10 | from torch import nn
11 |
12 | sys.path.append('.')
13 | from fastreid.config import get_cfg
14 | from fastreid.engine import default_argument_parser, default_setup, DefaultTrainer, launch
15 | from fastreid.utils.checkpoint import Checkpointer
16 |
17 | from kdreid import *
18 |
19 |
20 | def setup(args):
21 | """
22 | Create configs and perform basic setups.
23 | """
24 | cfg = get_cfg()
25 | add_shufflenet_config(cfg)
26 | add_kdreid_config(cfg)
27 | cfg.merge_from_file(args.config_file)
28 | cfg.merge_from_list(args.opts)
29 | cfg.freeze()
30 | default_setup(cfg, args)
31 | return cfg
32 |
33 |
34 | def main(args):
35 | cfg = setup(args)
36 |
37 | if args.eval_only:
38 | model = DefaultTrainer.build_model(cfg)
39 | Checkpointer(model, save_dir=cfg.OUTPUT_DIR).load(cfg.MODEL.WEIGHTS)
40 | res = DefaultTrainer.test(cfg, model)
41 | return res
42 |
43 | if args.kd: trainer = KDTrainer(cfg)
44 | else: trainer = DefaultTrainer(cfg)
45 |
46 | trainer.resume_or_load(resume=args.resume)
47 | return trainer.train()
48 |
49 |
50 | if __name__ == "__main__":
51 | parser = default_argument_parser()
52 | parser.add_argument("--kd", action="store_true", help="kd training with teacher model guided")
53 | args = parser.parse_args()
54 |
55 | print("Command Line Args:", args)
56 | launch(
57 | main,
58 | args.num_gpus,
59 | num_machines=args.num_machines,
60 | machine_rank=args.machine_rank,
61 | dist_url=args.dist_url,
62 | args=(args,),
63 | )
--------------------------------------------------------------------------------
/fast-reid/projects/HAA/Readme.md:
--------------------------------------------------------------------------------
1 | # Black Re-ID: A Head-shoulder Descriptor for the Challenging Problem of Person Re-Identification
2 |
3 | ## Training
4 |
5 | To train a model, run
6 |
7 | ```bash
8 | CUDA_VISIBLE_DEVICES=gpus python train_net.py --config-file
9 | ```
10 |
11 | ## Evaluation
12 |
13 | To evaluate the model in test set, run similarly:
14 |
15 | ```bash
16 | CUDA_VISIBLE_DEVICES=gpus python train_net.py --config-file --eval-only MODEL.WEIGHTS model.pth
17 | ```
18 |
19 | ## Experimental Results
20 |
21 | ### Market1501 dataset
22 |
23 | | Method | Pretrained | Rank@1 | mAP |
24 | | :---: | :---: | :---: |:---: |
25 | | ResNet50 | ImageNet | 93.3% | 84.6% |
26 | | MGN | ImageNet | 95.7% | 86.9% |
27 | | HAA (ResNet50) | ImageNet | 95% | 87.1% |
28 | | HAA (MGN) | ImageNet | 95.8% | 89.5% |
29 |
30 | ### DukeMTMC dataset
31 |
32 | | Method | Pretrained | Rank@1 | mAP |
33 | | :---: | :---: | :---: |:---: |
34 | | ResNet50 | ImageNet | 86.2% | 75.3% |
35 | | MGN | ImageNet | 88.7% | 78.4% |
36 | | HAA (ResNet50) | ImageNet | 87.7% | 75.7% |
37 | | HAA (MGN) | ImageNet | 89% | 80.4% |
38 |
39 | ### Black-reid black group
40 |
41 | | Method | Pretrained | Rank@1 | mAP |
42 | | :---: | :---: | :---: |:---: |
43 | | ResNet50 | ImageNet | 80.9% | 70.8% |
44 | | MGN | ImageNet | 86.7% | 79.1% |
45 | | HAA (ResNet50) | ImageNet | 86.7% | 79% |
46 | | HAA (MGN) | ImageNet | 91.0% | 83.8% |
47 |
48 | ### White-reid white group
49 |
50 | | Method | Pretrained | Rank@1 | mAP |
51 | | :---: | :---: | :---: |:---: |
52 | | ResNet50 | ImageNet | 89.5% | 75.8% |
53 | | MGN | ImageNet | 94.3% | 85.8% |
54 | | HAA (ResNet50) | ImageNet | 93.5% | 84.4% |
55 | | HSE (MGN) | ImageNet | 95.3% | 88.1% |
56 |
57 |
--------------------------------------------------------------------------------
/fast-reid/projects/HPOReID/README.md:
--------------------------------------------------------------------------------
1 | # Hyper-Parameter Optimization in FastReID
2 |
3 | This project includes training reid models with hyper-parameter optimization.
4 |
5 | Install the following
6 |
7 | ```bash
8 | pip install 'ray[tune]'
9 | pip install hpbandster ConfigSpace hyperopt
10 | ```
11 |
12 | ## Example
13 |
14 | This is an example for tuning `batch_size` and `num_instance` automatically.
15 |
16 | To train hyperparameter optimization with BOHB(Bayesian Optimization with HyperBand) search algorithm, run
17 |
18 | ```bash
19 | python3 projects/HPOReID/train_hpo.py --config-file projects/HPOReID/configs/baseline.yml --srch-algo "bohb"
20 | ```
21 |
22 | ## Known issues
23 | todo
--------------------------------------------------------------------------------
/fast-reid/projects/HPOReID/configs/baseline.yml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | META_ARCHITECTURE: "Baseline"
3 |
4 | FREEZE_LAYERS: ["backbone"]
5 |
6 | BACKBONE:
7 | NAME: "build_resnet_backbone"
8 | DEPTH: "34x"
9 | LAST_STRIDE: 1
10 | FEAT_DIM: 512
11 | NORM: "BN"
12 | WITH_NL: False
13 | WITH_IBN: True
14 | PRETRAIN: True
15 | PRETRAIN_PATH: "/export/home/lxy/.cache/torch/checkpoints/resnet34_ibn_a-94bc1577.pth"
16 |
17 | HEADS:
18 | NAME: "EmbeddingHead"
19 | NORM: "BN"
20 | NECK_FEAT: "after"
21 | EMBEDDING_DIM: 0
22 | POOL_LAYER: "gempool"
23 | CLS_LAYER: "circleSoftmax"
24 | SCALE: 64
25 | MARGIN: 0.35
26 |
27 | LOSSES:
28 | NAME: ("CrossEntropyLoss", "TripletLoss",)
29 |
30 | CE:
31 | EPSILON: 0.1
32 | SCALE: 1.
33 |
34 | TRI:
35 | MARGIN: 0.0
36 | HARD_MINING: True
37 | NORM_FEAT: False
38 | SCALE: 1.
39 |
40 | CIRCLE:
41 | MARGIN: 0.25
42 | ALPHA: 96
43 | SCALE: 1.0
44 |
45 | INPUT:
46 | SIZE_TRAIN: [256, 128]
47 | SIZE_TEST: [256, 128]
48 | DO_AUTOAUG: True
49 | REA:
50 | ENABLED: True
51 | CJ:
52 | ENABLED: True
53 | DO_PAD: True
54 |
55 | DATALOADER:
56 | PK_SAMPLER: True
57 | NAIVE_WAY: False
58 | NUM_INSTANCE: 16
59 | NUM_WORKERS: 8
60 |
61 | SOLVER:
62 | AMP_ENABLED: False
63 | OPT: "Adam"
64 | SCHED: "WarmupCosineAnnealingLR"
65 | MAX_ITER: 60
66 | BASE_LR: 0.00035
67 | BIAS_LR_FACTOR: 1.
68 | WEIGHT_DECAY: 0.0005
69 | WEIGHT_DECAY_BIAS: 0.0
70 | IMS_PER_BATCH: 64
71 |
72 | DELAY_ITERS: 30
73 | ETA_MIN_LR: 0.00000077
74 |
75 | FREEZE_ITERS: 5
76 |
77 | WARMUP_FACTOR: 0.01
78 | WARMUP_ITERS: 5
79 |
80 | CHECKPOINT_PERIOD: 100
81 |
82 | TEST:
83 | EVAL_PERIOD: 10
84 | IMS_PER_BATCH: 256
85 |
86 | DATASETS:
87 | NAMES: ("DukeMTMC",)
88 | TESTS: ("DukeMTMC",)
89 | COMBINEALL: False
90 |
91 | CUDNN_BENCHMARK: True
92 |
93 | OUTPUT_DIR: "projects/HPOReID/logs/dukemtmc/r34-ibn_bohb_bsz_num-inst"
94 |
--------------------------------------------------------------------------------
/fast-reid/projects/HPOReID/hporeid/__init__.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: xingyu liao
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | from .tune_hooks import TuneReportHook
8 |
--------------------------------------------------------------------------------
/fast-reid/projects/HPOReID/hporeid/tune_hooks.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: xingyu liao
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | import torch
8 | from ray import tune
9 |
10 | from fastreid.engine.hooks import EvalHook, flatten_results_dict
11 | from fastreid.utils.checkpoint import Checkpointer
12 |
13 |
14 | class TuneReportHook(EvalHook):
15 | def __init__(self, eval_period, eval_function):
16 | super().__init__(eval_period, eval_function)
17 | self.step = 0
18 |
19 | def _do_eval(self):
20 | results = self._func()
21 |
22 | if results:
23 | assert isinstance(
24 | results, dict
25 | ), "Eval function must return a dict. Got {} instead.".format(results)
26 |
27 | flattened_results = flatten_results_dict(results)
28 | for k, v in flattened_results.items():
29 | try:
30 | v = float(v)
31 | except Exception:
32 | raise ValueError(
33 | "[EvalHook] eval_function should return a nested dict of float. "
34 | "Got '{}: {}' instead.".format(k, v)
35 | )
36 |
37 | # Remove extra memory cache of main process due to evaluation
38 | torch.cuda.empty_cache()
39 |
40 | self.step += 1
41 |
42 | # Here we save a checkpoint. It is automatically registered with
43 | # Ray Tune and will potentially be passed as the `checkpoint_dir`
44 | # parameter in future iterations.
45 | with tune.checkpoint_dir(step=self.step) as checkpoint_dir:
46 | additional_state = {"iteration": int(self.trainer.iter)}
47 | Checkpointer(
48 | # Assume you want to save checkpoints together with logs/statistics
49 | self.trainer.model,
50 | checkpoint_dir,
51 | save_to_disk=True,
52 | optimizer=self.trainer.optimizer,
53 | scheduler=self.trainer.scheduler,
54 | ).save(name="checkpoint", **additional_state)
55 |
56 | metrics = dict(r1=results['Rank-1'], map=results['mAP'], score=(results['Rank-1'] + results['mAP']) / 2)
57 | tune.report(**metrics)
58 |
--------------------------------------------------------------------------------
/fast-reid/projects/PartialReID/configs/partial_market.yml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | META_ARCHITECTURE: 'PartialBaseline'
3 |
4 | BACKBONE:
5 | NAME: "build_resnet_backbone"
6 | DEPTH: "50x"
7 | NORM: "BN"
8 | LAST_STRIDE: 1
9 | WITH_IBN: True
10 | PRETRAIN_PATH: "/export/home/lxy/.cache/torch/checkpoints/resnet50_ibn_a-d9d0bb7b.pth"
11 |
12 | HEADS:
13 | NAME: "DSRHead"
14 | NORM: "BN"
15 | POOL_LAYER: "avgpool"
16 | NECK_FEAT: "before"
17 | CLS_LAYER: "linear"
18 |
19 | LOSSES:
20 | NAME: ("CrossEntropyLoss", "TripletLoss")
21 | CE:
22 | EPSILON: 0.1
23 | SCALE: 1.
24 | TRI:
25 | MARGIN: 0.3
26 | HARD_MINING: False
27 | SCALE: 1.
28 |
29 | DATASETS:
30 | NAMES: ("Market1501",)
31 | TESTS: ("PartialREID", "PartialiLIDS","OccludedREID",)
32 |
33 | INPUT:
34 | SIZE_TRAIN: [384, 128]
35 | SIZE_TEST: [384, 128]
36 | REA:
37 | ENABLED: False
38 | DO_PAD: False
39 |
40 | DATALOADER:
41 | PK_SAMPLER: True
42 | NAIVE_WAY: False
43 | NUM_INSTANCE: 4
44 | NUM_WORKERS: 8
45 |
46 | SOLVER:
47 | OPT: "Adam"
48 | MAX_ITER: 30
49 | BASE_LR: 0.00035
50 | BIAS_LR_FACTOR: 2.
51 | WEIGHT_DECAY: 0.0005
52 | WEIGHT_DECAY_BIAS: 0.0
53 | IMS_PER_BATCH: 64
54 |
55 | SCHED: "WarmupMultiStepLR"
56 | STEPS: [15, 25]
57 | GAMMA: 0.1
58 |
59 | WARMUP_FACTOR: 0.01
60 | WARMUP_ITERS: 5
61 |
62 | CHECKPOINT_PERIOD: 10
63 |
64 | TEST:
65 | EVAL_PERIOD: 5
66 | IMS_PER_BATCH: 128
67 |
68 | CUDNN_BENCHMARK: True
69 |
70 | OUTPUT_DIR: "projects/PartialReID/logs/test_partial"
71 |
--------------------------------------------------------------------------------
/fast-reid/projects/PartialReID/partialreid/__init__.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: xingyu liao
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | from .partial_dataset import *
8 | from .partialbaseline import PartialBaseline
9 | from .dsr_head import DSRHead
10 | from .config import add_partialreid_config
11 | from .dsr_evaluation import DsrEvaluator
12 |
--------------------------------------------------------------------------------
/fast-reid/projects/PartialReID/partialreid/config.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: l1aoxingyu
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | from fastreid.config import CfgNode as CN
8 |
9 |
10 | def add_partialreid_config(cfg):
11 | _C = cfg
12 |
13 | _C.TEST.DSR = CN()
14 | _C.TEST.DSR.ENABLED = True
15 |
16 |
--------------------------------------------------------------------------------
/fast-reid/projects/PartialReID/partialreid/dsr_distance.py:
--------------------------------------------------------------------------------
1 | """Numpy version of euclidean distance, etc.
2 | Notice the input/output shape of methods, so that you can better understand
3 | the meaning of these methods."""
4 |
5 | import torch
6 | import numpy as np
7 |
8 |
9 | def normalize(nparray, order=2, axis=0):
10 | """Normalize a N-D numpy array along the specified axis."""
11 | norm = np.linalg.norm(nparray, ord=order, axis=axis, keepdims=True)
12 | return nparray / (norm + np.finfo(np.float32).eps)
13 |
14 |
15 | def compute_dsr_dist(array1, array2, distmat, scores):
16 | """ Compute the sptial feature reconstruction of all pairs
17 | array: [M, N, C] M: the number of query, N: the number of spatial feature, C: the dimension of each spatial feature
18 | array2: [M, N, C] M: the number of gallery
19 | :return:
20 | numpy array with shape [m1, m2]
21 | """
22 | dist = 100 * torch.ones(len(array1), len(array2))
23 | dist = dist.cuda()
24 | kappa = 0.001
25 | index = np.argsort(distmat, axis=1)
26 | T = kappa * torch.eye(110)
27 | T = T.cuda()
28 | M = []
29 | for i in range(0, len(array2)):
30 | g = array2[i]
31 | g = torch.FloatTensor(g)
32 | g = g.view(g.size(0), g.size(1))
33 | g = g.cuda()
34 | Proj_M1 = torch.matmul(torch.inverse(torch.matmul(g.t(), g) + T), g.t())
35 | Proj_M1 = Proj_M1.cpu().numpy()
36 | M.append(Proj_M1)
37 | for i in range(0, len(array1)):
38 | q = torch.FloatTensor(array1[i])
39 | q = q.view(q.size(0), q.size(1))
40 | q = q.cuda()
41 | for j in range(0, 100):
42 | g = array2[index[i, j]]
43 | g = torch.FloatTensor(g)
44 | g = g.view(g.size(0), g.size(1))
45 | g = g.cuda()
46 | Proj_M = torch.FloatTensor(M[index[i, j]])
47 | Proj_M = Proj_M.cuda()
48 | a = torch.matmul(g, torch.matmul(Proj_M, q)) - q
49 | dist[i, index[i, j]] = ((torch.pow(a, 2).sum(0).sqrt()) * scores[i]).sum()
50 | dist = dist.cpu()
51 | dist = dist.numpy()
52 |
53 | return dist
54 |
--------------------------------------------------------------------------------
/fast-reid/projects/PartialReID/partialreid/partial_dataset.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | """
4 | @author: lingxiao he
5 | @contact: helingxiao3@jd.com
6 | """
7 |
8 | import glob
9 | import os
10 | import os.path as osp
11 | import re
12 |
13 | from fastreid.data.datasets import DATASET_REGISTRY
14 | from fastreid.data.datasets.bases import ImageDataset
15 |
16 | __all__ = ['PartialREID', 'PartialiLIDS', 'OccludedREID']
17 |
18 |
19 | def process_test(query_path, gallery_path):
20 | query_img_paths = glob.glob(os.path.join(query_path, '*.jpg'))
21 | gallery_img_paths = glob.glob(os.path.join(gallery_path, '*.jpg'))
22 | query_paths = []
23 | pattern = re.compile(r'([-\d]+)_(\d*)')
24 | for img_path in query_img_paths:
25 | pid, camid = map(int, pattern.search(img_path).groups())
26 | query_paths.append([img_path, pid, camid])
27 | gallery_paths = []
28 | for img_path in gallery_img_paths:
29 | pid, camid = map(int, pattern.search(img_path).groups())
30 | gallery_paths.append([img_path, pid, camid])
31 | return query_paths, gallery_paths
32 |
33 |
34 | @DATASET_REGISTRY.register()
35 | class PartialREID(ImageDataset):
36 |
37 | dataset_name = "partialreid"
38 |
39 | def __init__(self, root='datasets',):
40 | self.root = root
41 |
42 | self.query_dir = osp.join(self.root, 'Partial_REID/partial_body_images')
43 | self.gallery_dir = osp.join(self.root, 'Partial_REID/whole_body_images')
44 | query, gallery = process_test(self.query_dir, self.gallery_dir)
45 |
46 | ImageDataset.__init__(self, [], query, gallery)
47 |
48 |
49 | @DATASET_REGISTRY.register()
50 | class PartialiLIDS(ImageDataset):
51 | dataset_name = "partialilids"
52 |
53 | def __init__(self, root='datasets',):
54 | self.root = root
55 |
56 | self.query_dir = osp.join(self.root, 'PartialiLIDS/query')
57 | self.gallery_dir = osp.join(self.root, 'PartialiLIDS/gallery')
58 | query, gallery = process_test(self.query_dir, self.gallery_dir)
59 |
60 | ImageDataset.__init__(self, [], query, gallery)
61 |
62 |
63 | @DATASET_REGISTRY.register()
64 | class OccludedREID(ImageDataset):
65 | dataset_name = "occludereid"
66 |
67 | def __init__(self, root='datasets',):
68 | self.root = root
69 |
70 | self.query_dir = osp.join(self.root, 'OccludedREID/query')
71 | self.gallery_dir = osp.join(self.root, 'OccludedREID/gallery')
72 | query, gallery = process_test(self.query_dir, self.gallery_dir)
73 |
74 | ImageDataset.__init__(self, [], query, gallery)
75 |
--------------------------------------------------------------------------------
/fast-reid/projects/README.md:
--------------------------------------------------------------------------------
1 |
2 | Here are a few projects that are built on fastreid.
3 | They are examples of how to use fastrei as a library, to make your projects more maintainable.
4 |
5 | # Projects by JDAI
6 |
7 | Note that these are research projects, and therefore may not have the same level of support or stability of fastreid.
8 |
9 | - [Deep Spatial Feature Reconstruction for Partial Person Re-identification](https://github.com/JDAI-CV/fast-reid/tree/master/projects/PartialReID)
10 | - [Distillation Person Re-identification](https://github.com/JDAI-CV/fast-reid/tree/master/projects/DistillReID)
11 | - [Black Re-ID: A Head-shoulder Descriptor for the Challenging Problem of Person Re-Identification](https://github.com/JDAI-CV/fast-reid/tree/master/projects/HAA)
12 | - [Person Attribute Recognition](https://github.com/JDAI-CV/fast-reid/tree/master/projects/attribute_recognition)
13 |
14 | # External Projects
15 |
16 | External projects in the community that use fastreid:
17 |
18 | # Competitions
19 |
20 | - [NAIC20]() coming soon, stay tuned.
--------------------------------------------------------------------------------
/fast-reid/projects/attribute_recognition/README.md:
--------------------------------------------------------------------------------
1 | # Person Attribute Recognition in FastReID
2 |
3 | ## Training and Evaluation
4 |
5 | To train a model, run:
6 |
7 | ```bash
8 | python3 projects/PartialReID/train_net.py --config-file --num-gpus 1
9 | ```
10 |
11 | For example, to train the attribute recognition network with ResNet-50 Backbone in PA100k dataset,
12 | one should execute:
13 |
14 | ```bash
15 | python3 projects/attribute_recognition/train_net.py --config-file projects/attribute_recognition/configs/pa100.yml --num-gpus 4
16 | ```
17 |
18 | ## Results
19 |
20 | ### PA100k
21 |
22 | | Method | mA | Accu | Prec | Recall | F1 |
23 | |:--:|:--:|:--:|:--:|:--:|:--:|
24 | | Strongbaseline | 77.76 | 77.59 | 88.38 | 84.35 | 86.32 |
25 |
26 | More datasets and test results are waiting to add, stay tune!
27 |
--------------------------------------------------------------------------------
/fast-reid/projects/attribute_recognition/attribute_baseline/__init__.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: xingyu liao
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | from .config import add_attr_config
8 | from .datasets import *
9 | from .attr_baseline import AttrBaseline
10 | from .attr_evaluation import AttrEvaluator
11 | from .data_build import build_attr_train_loader, build_attr_test_loader
12 | from .attr_trainer import AttrTrainer
13 |
--------------------------------------------------------------------------------
/fast-reid/projects/attribute_recognition/attribute_baseline/attr_baseline.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: liaoxingyu
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | from fastreid.modeling.meta_arch.baseline import Baseline
8 | from fastreid.modeling.meta_arch.build import META_ARCH_REGISTRY
9 | from .bce_loss import cross_entropy_sigmoid_loss
10 |
11 |
12 | @META_ARCH_REGISTRY.register()
13 | class AttrBaseline(Baseline):
14 |
15 | def losses(self, outs, sample_weight=None):
16 | r"""
17 | Compute loss from modeling's outputs, the loss function input arguments
18 | must be the same as the outputs of the model forwarding.
19 | """
20 | # fmt: off
21 | outputs = outs["outputs"]
22 | gt_labels = outs["targets"]
23 | # model predictions
24 | # pred_class_logits = outputs['pred_class_logits'].detach()
25 | cls_outputs = outputs['cls_outputs']
26 | # fmt: on
27 |
28 | # Log prediction accuracy
29 | # log_accuracy(pred_class_logits, gt_labels)
30 |
31 | loss_dict = {}
32 | loss_names = self._cfg.MODEL.LOSSES.NAME
33 |
34 | if "BinaryCrossEntropyLoss" in loss_names:
35 | loss_dict['loss_bce'] = cross_entropy_sigmoid_loss(
36 | cls_outputs,
37 | gt_labels,
38 | sample_weight,
39 | ) * self._cfg.MODEL.LOSSES.BCE.SCALE
40 |
41 | return loss_dict
42 |
--------------------------------------------------------------------------------
/fast-reid/projects/attribute_recognition/attribute_baseline/bce_loss.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: xingyu liao
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | import torch
8 | import torch.nn.functional as F
9 |
10 |
11 | def ratio2weight(targets, ratio):
12 | pos_weights = targets * (1 - ratio)
13 | neg_weights = (1 - targets) * ratio
14 | weights = torch.exp(neg_weights + pos_weights)
15 |
16 | weights[targets > 1] = 0.0
17 | return weights
18 |
19 |
20 | def cross_entropy_sigmoid_loss(pred_class_logits, gt_classes, sample_weight=None):
21 | loss = F.binary_cross_entropy_with_logits(pred_class_logits, gt_classes, reduction='none')
22 |
23 | if sample_weight is not None:
24 | targets_mask = torch.where(gt_classes.detach() > 0.5,
25 | torch.ones(1, device="cuda"), torch.zeros(1, device="cuda")) # dtype float32
26 | weight = ratio2weight(targets_mask, sample_weight)
27 | loss = loss * weight
28 |
29 | with torch.no_grad():
30 | non_zero_cnt = max(loss.nonzero(as_tuple=False).size(0), 1)
31 |
32 | loss = loss.sum() / non_zero_cnt
33 | return loss
34 |
--------------------------------------------------------------------------------
/fast-reid/projects/attribute_recognition/attribute_baseline/common_attr.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: liaoxingyu
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | import torch
8 | from torch.utils.data import Dataset
9 |
10 | from fastreid.data.data_utils import read_image
11 |
12 |
13 | class AttrDataset(Dataset):
14 | """Image Person Attribute Dataset"""
15 |
16 | def __init__(self, img_items, attr_dict, transform=None):
17 | self.img_items = img_items
18 | self.attr_dict = attr_dict
19 | self.transform = transform
20 |
21 | def __len__(self):
22 | return len(self.img_items)
23 |
24 | def __getitem__(self, index):
25 | img_path, labels = self.img_items[index]
26 | img = read_image(img_path)
27 | if self.transform is not None: img = self.transform(img)
28 |
29 | labels = torch.from_numpy(labels)
30 |
31 | return {
32 | "images": img,
33 | "targets": labels,
34 | "img_paths": img_path,
35 | }
36 |
37 | @property
38 | def num_classes(self):
39 | return len(self.attr_dict)
40 |
41 | @property
42 | def sample_weights(self):
43 | sample_weights = torch.zeros(self.num_classes, dtype=torch.float)
44 | for _, attr in self.img_items:
45 | sample_weights += torch.from_numpy(attr)
46 | sample_weights /= len(self)
47 | return sample_weights
48 |
--------------------------------------------------------------------------------
/fast-reid/projects/attribute_recognition/attribute_baseline/config.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: xingyu liao
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | from fastreid.config import CfgNode as CN
8 |
9 |
10 | def add_attr_config(cfg):
11 | _C = cfg
12 |
13 | _C.MODEL.LOSSES.BCE = CN()
14 | _C.MODEL.LOSSES.BCE.WEIGHT_ENABLED = True
15 | _C.MODEL.LOSSES.BCE.SCALE = 1.
16 |
17 | _C.TEST.THRES = 0.5
18 |
--------------------------------------------------------------------------------
/fast-reid/projects/attribute_recognition/attribute_baseline/datasets/__init__.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: xingyu liao
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | # Attributed datasets
8 | from .pa100k import PA100K
9 |
--------------------------------------------------------------------------------
/fast-reid/projects/attribute_recognition/attribute_baseline/datasets/pa100k.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: xingyu liao
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | import os.path as osp
8 |
9 | import numpy as np
10 | from scipy.io import loadmat
11 |
12 | from fastreid.data.datasets import DATASET_REGISTRY
13 |
14 | from .bases import Dataset
15 |
16 |
17 | @DATASET_REGISTRY.register()
18 | class PA100K(Dataset):
19 | """Pedestrian attribute dataset.
20 | 80k training images + 20k test images.
21 | The folder structure should be:
22 | pa100k/
23 | data/ # images
24 | annotation.mat
25 | """
26 | dataset_dir = 'PA-100K'
27 |
28 | def __init__(self, root='', **kwargs):
29 | self.root = root
30 | self.dataset_dir = osp.join(self.root, self.dataset_dir)
31 | self.data_dir = osp.join(self.dataset_dir, 'data')
32 | self.anno_mat_path = osp.join(
33 | self.dataset_dir, 'annotation.mat'
34 | )
35 |
36 | required_files = [self.data_dir, self.anno_mat_path]
37 | self.check_before_run(required_files)
38 |
39 | train, val, test, attr_dict = self.extract_data()
40 | super(PA100K, self).__init__(train, val, test, attr_dict=attr_dict, **kwargs)
41 |
42 | def extract_data(self):
43 | # anno_mat is a dictionary with keys: ['test_images_name', 'val_images_name',
44 | # 'train_images_name', 'val_label', 'attributes', 'test_label', 'train_label']
45 | anno_mat = loadmat(self.anno_mat_path)
46 |
47 | def _extract(key_name, key_label):
48 | names = anno_mat[key_name]
49 | labels = anno_mat[key_label]
50 | num_imgs = names.shape[0]
51 | data = []
52 | for i in range(num_imgs):
53 | name = names[i, 0][0]
54 | attrs = labels[i, :].astype(np.float32)
55 | img_path = osp.join(self.data_dir, name)
56 | data.append((img_path, attrs))
57 | return data
58 |
59 | train = _extract('train_images_name', 'train_label')
60 | val = _extract('val_images_name', 'val_label')
61 | test = _extract('test_images_name', 'test_label')
62 | attrs = anno_mat['attributes']
63 | attr_dict = {i: str(attr[0][0]) for i, attr in enumerate(attrs)}
64 |
65 | return train, val, test, attr_dict
66 |
--------------------------------------------------------------------------------
/fast-reid/projects/attribute_recognition/configs/Base-attribute.yml:
--------------------------------------------------------------------------------
1 | MODEL:
2 | META_ARCHITECTURE: "AttrBaseline"
3 |
4 | BACKBONE:
5 | NAME: "build_resnet_backbone"
6 | NORM: "BN"
7 | DEPTH: "50x"
8 | LAST_STRIDE: 2
9 | FEAT_DIM: 2048
10 | WITH_IBN: False
11 | PRETRAIN: True
12 | PRETRAIN_PATH: "/export/home/lxy/.cache/torch/checkpoints/resnet50-19c8e357.pth"
13 |
14 | HEADS:
15 | NAME: "AttrHead"
16 | NORM: "BN"
17 | WITH_BNNECK: True
18 | POOL_LAYER: "fastavgpool"
19 | CLS_LAYER: "linear"
20 | NUM_CLASSES: 26
21 |
22 | LOSSES:
23 | NAME: ("BinaryCrossEntropyLoss",)
24 |
25 | BCE:
26 | WEIGHT_ENABLED: True
27 | SCALE: 1.
28 |
29 | INPUT:
30 | SIZE_TRAIN: [256, 128]
31 | SIZE_TEST: [256, 128]
32 | REA:
33 | ENABLED: False
34 | DO_PAD: True
35 |
36 | DATALOADER:
37 | NUM_WORKERS: 8
38 |
39 | SOLVER:
40 | OPT: "SGD"
41 | MAX_ITER: 30
42 | BASE_LR: 0.01
43 | BIAS_LR_FACTOR: 2.
44 | HEADS_LR_FACTOR: 10.
45 | WEIGHT_DECAY: 0.0005
46 | WEIGHT_DECAY_BIAS: 0.0005
47 | IMS_PER_BATCH: 64
48 |
49 | SCHED: "WarmupCosineAnnealingLR"
50 | DELAY_ITERS: 5
51 | ETA_MIN_LR: 0.00001
52 |
53 | WARMUP_FACTOR: 0.01
54 | WARMUP_ITERS: 5
55 |
56 | CHECKPOINT_PERIOD: 10
57 |
58 | TEST:
59 | EVAL_PERIOD: 10
60 | IMS_PER_BATCH: 256
61 |
62 | CUDNN_BENCHMARK: True
63 |
64 |
--------------------------------------------------------------------------------
/fast-reid/projects/attribute_recognition/configs/pa100.yml:
--------------------------------------------------------------------------------
1 | _BASE_: "Base-attribute.yml"
2 |
3 | DATASETS:
4 | NAMES: ("PA100K",)
5 | TESTS: ("PA100K",)
6 |
7 | OUTPUT_DIR: "projects/attribute_recognition/logs/pa100k/strong_baseline"
--------------------------------------------------------------------------------
/fast-reid/projects/attribute_recognition/train_net.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: xingyu liao
4 | @contact: sherlockliao01@gmail.com
5 | """
6 | import sys
7 |
8 | sys.path.append('.')
9 |
10 | from fastreid.config import get_cfg
11 | from fastreid.engine import default_argument_parser, default_setup, launch
12 | from fastreid.utils.checkpoint import Checkpointer
13 |
14 | from attribute_baseline import *
15 |
16 |
17 | def setup(args):
18 | """
19 | Create configs and perform basic setups.
20 | """
21 | cfg = get_cfg()
22 | add_attr_config(cfg)
23 | cfg.merge_from_file(args.config_file)
24 | cfg.merge_from_list(args.opts)
25 | cfg.freeze()
26 | default_setup(cfg, args)
27 | return cfg
28 |
29 |
30 | def main(args):
31 | cfg = setup(args)
32 |
33 | if args.eval_only:
34 | cfg.defrost()
35 | cfg.MODEL.BACKBONE.PRETRAIN = False
36 | model = AttrTrainer.build_model(cfg)
37 |
38 | Checkpointer(model).load(cfg.MODEL.WEIGHTS) # load trained model
39 |
40 | res = AttrTrainer.test(cfg, model)
41 | return res
42 |
43 | trainer = AttrTrainer(cfg)
44 | trainer.resume_or_load(resume=args.resume)
45 | return trainer.train()
46 |
47 |
48 | if __name__ == "__main__":
49 | args = default_argument_parser().parse_args()
50 | print("Command Line Args:", args)
51 | launch(
52 | main,
53 | args.num_gpus,
54 | num_machines=args.num_machines,
55 | machine_rank=args.machine_rank,
56 | dist_url=args.dist_url,
57 | args=(args,),
58 | )
59 |
--------------------------------------------------------------------------------
/fast-reid/tests/__init__.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: sherlock
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
--------------------------------------------------------------------------------
/fast-reid/tests/dataset_test.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: liaoxingyu
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | import sys
8 | sys.path.append('.')
9 | from data import get_dataloader
10 | from config import cfg
11 | import argparse
12 | from data.datasets import init_dataset
13 | # cfg.DATALOADER.SAMPLER = 'triplet'
14 | cfg.DATASETS.NAMES = ("market1501", "dukemtmc", "cuhk03", "msmt17",)
15 |
16 |
17 | if __name__ == '__main__':
18 | parser = argparse.ArgumentParser(description="ReID Baseline Training")
19 | parser.add_argument(
20 | '-cfg', "--config_file",
21 | default="",
22 | metavar="FILE",
23 | help="path to config file",
24 | type=str
25 | )
26 | # parser.add_argument("--local_rank", type=int, default=0)
27 | parser.add_argument("opts", help="Modify config options using the command-line", default=None,
28 | nargs=argparse.REMAINDER)
29 | args = parser.parse_args()
30 | cfg.merge_from_list(args.opts)
31 |
32 | # dataset = init_dataset('msmt17', combineall=True)
33 | get_dataloader(cfg)
34 | # tng_dataloader, val_dataloader, num_classes, num_query = get_dataloader(cfg)
35 | # def get_ex(): return open_image('datasets/beijingStation/query/000245_c10s2_1561732033722.000000.jpg')
36 | # im = get_ex()
37 | # print(data.train_ds[0])
38 | # print(data.test_ds[0])
39 | # a = next(iter(data.train_dl))
40 | # from IPython import embed; embed()
41 | # from ipdb import set_trace; set_trace()
42 | # im.apply_tfms(crop_pad(size=(300, 300)))
43 |
--------------------------------------------------------------------------------
/fast-reid/tests/feature_align.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import numpy as np
3 | import os
4 | from glob import glob
5 |
6 |
7 | class TestFeatureAlign(unittest.TestCase):
8 | def test_caffe_pytorch_feat_align(self):
9 | caffe_feat_path = "/export/home/lxy/cvpalgo-fast-reid/tools/deploy/caffe_R50_output"
10 | pytorch_feat_path = "/export/home/lxy/cvpalgo-fast-reid/demo/logs/R50_256x128_pytorch_feat_output"
11 | feat_filenames = os.listdir(caffe_feat_path)
12 | for feat_name in feat_filenames:
13 | caffe_feat = np.load(os.path.join(caffe_feat_path, feat_name))
14 | pytorch_feat = np.load(os.path.join(pytorch_feat_path, feat_name))
15 | sim = np.dot(caffe_feat, pytorch_feat.transpose())[0][0]
16 | assert sim > 0.97, f"Got similarity {sim} and feature of {feat_name} is not aligned"
17 |
18 | def test_model_performance(self):
19 | caffe_feat_path = "/export/home/lxy/cvpalgo-fast-reid/tools/deploy/caffe_R50_output"
20 | feat_filenames = os.listdir(caffe_feat_path)
21 | feats = []
22 | for feat_name in feat_filenames:
23 | caffe_feat = np.load(os.path.join(caffe_feat_path, feat_name))
24 | feats.append(caffe_feat)
25 | from ipdb import set_trace; set_trace()
26 |
27 |
28 |
29 | if __name__ == '__main__':
30 | unittest.main()
31 |
--------------------------------------------------------------------------------
/fast-reid/tests/interp_test.py:
--------------------------------------------------------------------------------
1 | import torch
2 | from fastai.vision import *
3 | from fastai.basic_data import *
4 | from fastai.layers import *
5 |
6 | import sys
7 | sys.path.append('.')
8 | from engine.interpreter import ReidInterpretation
9 |
10 | from data import get_data_bunch
11 | from modeling import build_model
12 | from config import cfg
13 | cfg.DATASETS.NAMES = ('market1501',)
14 | cfg.DATASETS.TEST_NAMES = 'market1501'
15 | cfg.MODEL.BACKBONE = 'resnet50'
16 |
17 | data_bunch, test_labels, num_query = get_data_bunch(cfg)
18 |
19 | model = build_model(cfg, 10)
20 | model.load_params_wo_fc(torch.load('logs/2019.8.14/market/baseline/models/model_149.pth')['model'])
21 | learn = Learner(data_bunch, model)
22 |
23 | feats, _ = learn.get_preds(DatasetType.Test, activ=Lambda(lambda x: x))
--------------------------------------------------------------------------------
/fast-reid/tests/lr_scheduler_test.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import unittest
3 |
4 | import torch
5 | from torch import nn
6 |
7 | sys.path.append('.')
8 | from solver.lr_scheduler import WarmupMultiStepLR
9 | from solver.build import make_optimizer
10 | from config import cfg
11 |
12 |
13 | class MyTestCase(unittest.TestCase):
14 | def test_something(self):
15 | net = nn.Linear(10, 10)
16 | optimizer = make_optimizer(cfg, net)
17 | lr_scheduler = WarmupMultiStepLR(optimizer, [20, 40], warmup_iters=10)
18 | for i in range(50):
19 | lr_scheduler.step()
20 | for j in range(3):
21 | print(i, lr_scheduler.get_lr()[0])
22 | optimizer.step()
23 |
24 |
25 | if __name__ == '__main__':
26 | unittest.main()
27 |
--------------------------------------------------------------------------------
/fast-reid/tests/model_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 |
3 | import torch
4 |
5 | import sys
6 | sys.path.append('.')
7 | from fastreid.config import cfg
8 | from fastreid.modeling.backbones import build_resnet_backbone
9 | from fastreid.modeling.backbones.resnet_ibn_a import se_resnet101_ibn_a
10 | from torch import nn
11 |
12 |
13 | class MyTestCase(unittest.TestCase):
14 | def test_se_resnet101(self):
15 | cfg.MODEL.BACKBONE.NAME = 'resnet101'
16 | cfg.MODEL.BACKBONE.DEPTH = 101
17 | cfg.MODEL.BACKBONE.WITH_IBN = True
18 | cfg.MODEL.BACKBONE.WITH_SE = True
19 | cfg.MODEL.BACKBONE.PRETRAIN_PATH = '/export/home/lxy/.cache/torch/checkpoints/se_resnet101_ibn_a.pth.tar'
20 |
21 | net1 = build_resnet_backbone(cfg)
22 | net1.cuda()
23 | net2 = nn.DataParallel(se_resnet101_ibn_a())
24 | res = net2.load_state_dict(torch.load(cfg.MODEL.BACKBONE.PRETRAIN_PATH)['state_dict'], strict=False)
25 | net2.cuda()
26 | x = torch.randn(10, 3, 256, 128).cuda()
27 | y1 = net1(x)
28 | y2 = net2(x)
29 | assert y1.sum() == y2.sum(), 'train mode problem'
30 | net1.eval()
31 | net2.eval()
32 | y1 = net1(x)
33 | y2 = net2(x)
34 | assert y1.sum() == y2.sum(), 'eval mode problem'
35 |
36 |
37 | if __name__ == '__main__':
38 | unittest.main()
39 |
--------------------------------------------------------------------------------
/fast-reid/tests/sampler_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import sys
3 | sys.path.append('.')
4 | from fastreid.data.samplers import TrainingSampler
5 |
6 |
7 | class SamplerTestCase(unittest.TestCase):
8 | def test_training_sampler(self):
9 | sampler = TrainingSampler(5)
10 | for i in sampler:
11 | from ipdb import set_trace; set_trace()
12 | print(i)
13 |
14 |
15 | if __name__ == '__main__':
16 | unittest.main()
17 |
--------------------------------------------------------------------------------
/fast-reid/tools/deploy/Caffe/ReadMe.md:
--------------------------------------------------------------------------------
1 | # The Caffe in nn_tools Provides some convenient API
2 | If there are some problem in parse your prototxt or caffemodel, Please replace
3 | the caffe.proto with your own version and compile it with command
4 | `protoc --python_out ./ caffe.proto`
5 |
6 | ## caffe_net.py
7 | Using `from nn_tools.Caffe import caffe_net` to import this model
8 | ### Prototxt
9 | + `net=caffe_net.Prototxt(file_name)` to open a prototxt file
10 | + `net.init_caffemodel(caffe_cmd_path='caffe')` to generate a caffemodel file in the current work directory \
11 | if your `caffe` cmd not in the $PATH, specify your caffe cmd path by the `caffe_cmd_path` kwargs.
12 | ### Caffemodel
13 | + `net=caffe_net.Caffemodel(file_name)` to open a caffemodel
14 | + `net.save_prototxt(path)` to save the caffemodel to a prototxt file (not containing the weight data)
15 | + `net.get_layer_data(layer_name)` return the numpy ndarray data of the layer
16 | + `net.set_layer_date(layer_name, datas)` specify the data of one layer in the caffemodel .`datas` is normally a list of numpy ndarray `[weights,bias]`
17 | + `net.save(path)` save the changed caffemodel
18 | ### Functions for both Prototxt and Caffemodel
19 | + `net.add_layer(layer_params,before='',after='')` add a new layer with `Layer_Param` object
20 | + `net.remove_layer_by_name(layer_name)`
21 | + `net.get_layer_by_name(layer_name)` or `net.layer(layer_name)` get the raw Layer object defined in caffe_pb2
22 |
--------------------------------------------------------------------------------
/fast-reid/tools/deploy/Caffe/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DengpanFu/LUPerson-NL/6b9298e49b3b84d0324a49d1749639580f7af60a/fast-reid/tools/deploy/Caffe/__init__.py
--------------------------------------------------------------------------------
/fast-reid/tools/deploy/Caffe/caffe_lmdb.py:
--------------------------------------------------------------------------------
1 | import lmdb
2 | from Caffe import caffe_pb2 as pb2
3 | import numpy as np
4 |
5 | class Read_Caffe_LMDB():
6 | def __init__(self,path,dtype=np.uint8):
7 |
8 | self.env=lmdb.open(path, readonly=True)
9 | self.dtype=dtype
10 | self.txn=self.env.begin()
11 | self.cursor=self.txn.cursor()
12 |
13 | @staticmethod
14 | def to_numpy(value,dtype=np.uint8):
15 | datum = pb2.Datum()
16 | datum.ParseFromString(value)
17 | flat_x = np.fromstring(datum.data, dtype=dtype)
18 | data = flat_x.reshape(datum.channels, datum.height, datum.width)
19 | label=flat_x = datum.label
20 | return data,label
21 |
22 | def iterator(self):
23 | while True:
24 | key,value=self.cursor.key(),self.cursor.value()
25 | yield self.to_numpy(value,self.dtype)
26 | if not self.cursor.next():
27 | return
28 |
29 | def __iter__(self):
30 | self.cursor.first()
31 | it = self.iterator()
32 | return it
33 |
34 | def __len__(self):
35 | return int(self.env.stat()['entries'])
36 |
--------------------------------------------------------------------------------
/fast-reid/tools/deploy/Caffe/net.py:
--------------------------------------------------------------------------------
1 | raise ImportError,'the nn_tools.Caffe.net is no longer used, please use nn_tools.Caffe.caffe_net'
--------------------------------------------------------------------------------
/fast-reid/tools/deploy/caffe_export.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: xingyu liao
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | import argparse
8 |
9 | import torch
10 | import sys
11 | sys.path.append('../../')
12 |
13 | import pytorch_to_caffe
14 | from fastreid.config import get_cfg
15 | from fastreid.modeling.meta_arch import build_model
16 | from fastreid.utils.file_io import PathManager
17 | from fastreid.utils.checkpoint import Checkpointer
18 | from fastreid.utils.logger import setup_logger
19 |
20 | logger = setup_logger(name='caffe_export')
21 |
22 |
23 | def setup_cfg(args):
24 | cfg = get_cfg()
25 | cfg.merge_from_file(args.config_file)
26 | cfg.merge_from_list(args.opts)
27 | cfg.freeze()
28 | return cfg
29 |
30 |
31 | def get_parser():
32 | parser = argparse.ArgumentParser(description="Convert Pytorch to Caffe model")
33 |
34 | parser.add_argument(
35 | "--config-file",
36 | metavar="FILE",
37 | help="path to config file",
38 | )
39 | parser.add_argument(
40 | "--name",
41 | default="baseline",
42 | help="name for converted model"
43 | )
44 | parser.add_argument(
45 | "--output",
46 | default='caffe_model',
47 | help='path to save converted caffe model'
48 | )
49 | parser.add_argument(
50 | "--opts",
51 | help="Modify config options using the command-line 'KEY VALUE' pairs",
52 | default=[],
53 | nargs=argparse.REMAINDER,
54 | )
55 | return parser
56 |
57 |
58 | if __name__ == '__main__':
59 | args = get_parser().parse_args()
60 | cfg = setup_cfg(args)
61 |
62 | cfg.defrost()
63 | cfg.MODEL.BACKBONE.PRETRAIN = False
64 | cfg.MODEL.HEADS.POOL_LAYER = "identity"
65 | cfg.MODEL.BACKBONE.WITH_NL = False
66 |
67 | model = build_model(cfg)
68 | Checkpointer(model).load(cfg.MODEL.WEIGHTS)
69 | model.eval()
70 | logger.info(model)
71 |
72 | inputs = torch.randn(1, 3, cfg.INPUT.SIZE_TEST[0], cfg.INPUT.SIZE_TEST[1]).to(torch.device(cfg.MODEL.DEVICE))
73 | PathManager.mkdirs(args.output)
74 | pytorch_to_caffe.trans_net(model, inputs, args.name)
75 | pytorch_to_caffe.save_prototxt(f"{args.output}/{args.name}.prototxt")
76 | pytorch_to_caffe.save_caffemodel(f"{args.output}/{args.name}.caffemodel")
77 |
78 | logger.info(f"Export caffe model in {args.output} sucessfully!")
79 |
--------------------------------------------------------------------------------
/fast-reid/tools/deploy/test_data/0022_c6s1_002976_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DengpanFu/LUPerson-NL/6b9298e49b3b84d0324a49d1749639580f7af60a/fast-reid/tools/deploy/test_data/0022_c6s1_002976_01.jpg
--------------------------------------------------------------------------------
/fast-reid/tools/deploy/test_data/0027_c2s2_091032_02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DengpanFu/LUPerson-NL/6b9298e49b3b84d0324a49d1749639580f7af60a/fast-reid/tools/deploy/test_data/0027_c2s2_091032_02.jpg
--------------------------------------------------------------------------------
/fast-reid/tools/deploy/test_data/0032_c6s1_002851_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DengpanFu/LUPerson-NL/6b9298e49b3b84d0324a49d1749639580f7af60a/fast-reid/tools/deploy/test_data/0032_c6s1_002851_01.jpg
--------------------------------------------------------------------------------
/fast-reid/tools/deploy/test_data/0048_c1s1_005351_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DengpanFu/LUPerson-NL/6b9298e49b3b84d0324a49d1749639580f7af60a/fast-reid/tools/deploy/test_data/0048_c1s1_005351_01.jpg
--------------------------------------------------------------------------------
/fast-reid/tools/deploy/test_data/0065_c6s1_009501_02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DengpanFu/LUPerson-NL/6b9298e49b3b84d0324a49d1749639580f7af60a/fast-reid/tools/deploy/test_data/0065_c6s1_009501_02.jpg
--------------------------------------------------------------------------------
/fast-reid/tools/deploy/trt_export.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | """
3 | @author: xingyu liao
4 | @contact: sherlockliao01@gmail.com
5 | """
6 |
7 | import argparse
8 | import os
9 | import numpy as np
10 | import sys
11 |
12 | sys.path.append('../../')
13 | sys.path.append("/export/home/lxy/runtimelib-tensorrt-tiny/build")
14 |
15 | import pytrt
16 | from fastreid.utils.logger import setup_logger
17 | from fastreid.utils.file_io import PathManager
18 |
19 |
20 | logger = setup_logger(name='trt_export')
21 |
22 |
23 | def get_parser():
24 | parser = argparse.ArgumentParser(description="Convert ONNX to TRT model")
25 |
26 | parser.add_argument(
27 | "--name",
28 | default="baseline",
29 | help="name for converted model"
30 | )
31 | parser.add_argument(
32 | "--output",
33 | default='outputs/trt_model',
34 | help='path to save converted trt model'
35 | )
36 | parser.add_argument(
37 | "--onnx-model",
38 | default='outputs/onnx_model/baseline.onnx',
39 | help='path to onnx model'
40 | )
41 | parser.add_argument(
42 | "--height",
43 | type=int,
44 | default=256,
45 | help="height of image"
46 | )
47 | parser.add_argument(
48 | "--width",
49 | type=int,
50 | default=128,
51 | help="width of image"
52 | )
53 | return parser
54 |
55 |
56 | def export_trt_model(onnxModel, engineFile, input_numpy_array):
57 | r"""
58 | Export a model to trt format.
59 | """
60 |
61 | trt = pytrt.Trt()
62 |
63 | customOutput = []
64 | maxBatchSize = 1
65 | calibratorData = []
66 | mode = 2
67 | trt.CreateEngine(onnxModel, engineFile, customOutput, maxBatchSize, mode, calibratorData)
68 | trt.DoInference(input_numpy_array) # slightly different from c++
69 | return 0
70 |
71 |
72 | if __name__ == '__main__':
73 | args = get_parser().parse_args()
74 |
75 | inputs = np.zeros(shape=(32, args.height, args.width, 3))
76 | onnxModel = args.onnx_model
77 | engineFile = os.path.join(args.output, args.name+'.engine')
78 |
79 | PathManager.mkdirs(args.output)
80 | export_trt_model(onnxModel, engineFile, inputs)
81 |
82 | logger.info(f"Export trt model in {args.output} successfully!")
83 |
--------------------------------------------------------------------------------
/fast-reid/tools/train_net.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # encoding: utf-8
3 | """
4 | @author: sherlock
5 | @contact: sherlockliao01@gmail.com
6 | """
7 |
8 | import sys, setuptools
9 |
10 | sys.path.append('.')
11 |
12 | from fastreid.config import get_cfg
13 | from fastreid.engine import DefaultTrainer, default_argument_parser, default_setup, launch
14 | from fastreid.utils.checkpoint import Checkpointer
15 |
16 |
17 | def setup(args):
18 | """
19 | Create configs and perform basic setups.
20 | """
21 | cfg = get_cfg()
22 | cfg.merge_from_file(args.config_file)
23 | cfg.merge_from_list(args.opts)
24 | cfg.freeze()
25 | default_setup(cfg, args)
26 | return cfg
27 |
28 |
29 | def main(args):
30 | cfg = setup(args)
31 |
32 | if args.eval_only:
33 | cfg.defrost()
34 | cfg.MODEL.BACKBONE.PRETRAIN = False
35 | model = DefaultTrainer.build_model(cfg)
36 |
37 | Checkpointer(model).load(cfg.MODEL.WEIGHTS) # load trained model
38 |
39 | res = DefaultTrainer.test(cfg, model)
40 | return res
41 |
42 | trainer = DefaultTrainer(cfg)
43 | # load trained model to funetune
44 | if args.finetune: Checkpointer(trainer.model).load(cfg.MODEL.WEIGHTS)
45 |
46 | trainer.resume_or_load(resume=args.resume)
47 | return trainer.train()
48 |
49 |
50 | if __name__ == "__main__":
51 | args = default_argument_parser().parse_args()
52 | print("Command Line Args:", args)
53 | launch(
54 | main,
55 | args.num_gpus,
56 | num_machines=args.num_machines,
57 | machine_rank=args.machine_rank,
58 | dist_url=args.dist_url,
59 | args=(args,),
60 | )
61 |
--------------------------------------------------------------------------------