• Stars
    star
    186
  • Rank 200,799 (Top 5 %)
  • Language
    Python
  • Created almost 6 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Person re-ID baseline with triplet loss

Person_reID_triplet-loss-baseline

Baseline Code (with bottleneck) for Person-reID (pytorch).

We arrived Rank@1=86.45%, mAP=70.66% with ResNet stride=2. SGD optimizer is used.

Any suggestion is welcomed.

Model Structure

You may learn more from model.py. We use the L2-norm 2048-dim feature as the input.

Tips

  • News: I added the fp16 support.
  • I did not optimize the code. I strongly suggest use fp16 and use with torch.no_grad(). I will update the code later.
  • Larger margin may lead to a worse local minimum. (margin = 0.1-0.3 may provide a better result.)
  • Per-class sampler (Satisfied sampler)is not neccessary.
  • Adam optimizer is not neccessary.

Prerequisites

  • Python 3.6
  • GPU Memory >= 6G
  • Numpy
  • Pytorch 0.3+

(Some reports found that updating numpy can arrive the right accuracy. If you only get 50~80 Top1 Accuracy, just try it.) We have successfully run the code based on numpy 1.12.1 and 1.13.1 .

Getting started

Installation

git clone https://github.com/pytorch/vision
cd vision
python setup.py install

Because pytorch and torchvision are ongoing projects.

Here we noted that our code is tested based on Pytorch 0.3.0/0.4.0 and Torchvision 0.2.0.

Dataset & Preparation

Download Market1501 Dataset

Preparation: Put the images with the same id in one folder. You may use

python prepare.py

Remember to change the dataset path to your own path.

Futhermore, you also can test our code on DukeMTMC-reID Dataset. Our baseline code is not such high on DukeMTMC-reID Rank@1=64.23%, mAP=43.92%. Hyperparameters are need to be tuned.

To save trained model, we make a dir.

mkdir model 

Train

Train a model by

python train_new.py --gpu_ids 0 --name ft_ResNet50 --train_all --batchsize 32  --data_dir your_data_path

--gpu_ids which gpu to run.

--name the name of model.

--data_dir the path of the training data.

--train_all using all images to train.

--batchsize batch size.

--erasing_p random erasing probability.

Train a model with random erasing by

python train_new.py --gpu_ids 0 --name ft_ResNet50 --train_all --batchsize 32  --data_dir your_data_path --erasing_p 0.5

Test

Use trained model to extract feature by

python test.py --gpu_ids 0 --name ft_ResNet50 --test_dir your_data_path  --which_epoch 59

--gpu_ids which gpu to run.

--name the dir name of trained model.

--which_epoch select the i-th model.

--data_dir the path of the testing data.

Evaluation

python evaluate.py

It will output Rank@1, Rank@5, Rank@10 and mAP results. You may also try evaluate_gpu.py to conduct a faster evaluation with GPU.

For mAP calculation, you also can refer to the C++ code for Oxford Building. We use the triangle mAP calculation (consistent with the Market1501 original code).

Related Repos

  1. Pedestrian Alignment Network
  2. 2stream Person re-ID
  3. Pedestrian GAN
  4. Language Person Search

More Repositories

1

Person_reID_baseline_pytorch

โ›น๏ธ Pytorch ReID: A tiny, friendly, strong pytorch implement of person re-id / vehicle re-id baseline. Tutorial ๐Ÿ‘‰https://github.com/layumi/Person_reID_baseline_pytorch/tree/master/tutorial
Python
3,915
star
2

AICIty-reID-2020

๐Ÿš— The 1st Place Submission to AICity Challenge 2020 re-id track (Baidu-UTS submission)
Python
446
star
3

Vehicle_reID-Collection

๐Ÿš— the collection of vehicle re-ID papers, datasets. ๐Ÿš—
431
star
4

University1652-Baseline

ACM Multimedia2020 University-1652: A Multi-view Multi-source Benchmark for Drone-based Geo-localization ๐Ÿš annotates 1652 buildings in 72 universities around the world.
Python
409
star
5

Seg-Uncertainty

IJCAI2020 & IJCV2021 ๐ŸŒ‡ Unsupervised Scene Adaptation with Memory Regularization in vivo
Python
375
star
6

Person-reID_GAN

ICCV2017 Unlabeled Samples Generated by GAN Improve the Person Re-identification Baseline in vitro
Cuda
317
star
7

Image-Text-Embedding

TOMM2020 Dual-Path Convolutional Image-Text Embedding ๐Ÿพ https://arxiv.org/abs/1711.05535
MATLAB
279
star
8

2016_person_re-ID

TOMM2017 A Discriminatively Learned CNN Embedding for Person Re-identification
C
265
star
9

person-reid-3d

TNNLS'22 ๐Ÿ—ฝ Parameter-Efficient Person Re-identification in the 3D Space ๐Ÿ—ฝ
Python
257
star
10

Pedestrian_Alignment

TCSVT2018 Pedestrian Alignment Network for Large-scale Person Re-identification
Cuda
237
star
11

2015_Face_Detection

CVPR2015 Cascade CNNs for Face Detection
HTML
136
star
12

Person-reID-verification

๐Ÿจ (pytorch version) TOMM2017 A Discriminatively Learned CNN Embedding for Person Re-identification ๐Ÿจ
Python
99
star
13

2016_super_resolution

ICCV2015 Image Super-Resolution Using Deep Convolutional Networks
Cuda
86
star
14

Awesome-Fools

๐Ÿ’€ A collection of methods to fool the deep neural network ๐Ÿ’€
76
star
15

3D-Magic-Mirror

๐Ÿ‘—3D Magic Mirror: Clothing Reconstruction from a Single Image via a Causal Perspective๐Ÿ‘— Single-View 3D Reconstruction
Python
65
star
16

U_turn

IJCV22 ๐Ÿ™ˆ Attack your retrieval model via Query! They are not robust as you expected! ๐Ÿ™‰
Python
47
star
17

AdaBoost_Seg

TIP2022 Adaptive Boosting (AdaBoost) for Domain Adaptation ? ๐Ÿคทโ€โ™€๏ธ Why not ! ๐Ÿ™†โ€โ™€๏ธ
Python
44
star
18

visualize_matconvnet

A simple code to visualize net for matconvnet.
MATLAB
35
star
19

2016_GAN_Matlab

Generative Adversarial Nets for Matlab
HTML
35
star
20

2016_Artist_Style

Using CNN to create 'famous painting' with Matlab code
HTML
19
star
21

UTS-Person-reID-Practical

UTS Person-reID Practical By Zhedong Zheng
18
star
22

DukeMTMC-reID_baseline

DukeMTMC-reID_baseline (Matlab)
Cuda
18
star
23

Image-Retrieval-by-Finetuning-CNN

Code for project
Python
17
star
24

HQ-Market

Market-1501 dataset with super-resolution quality
Python
17
star
25

ACMMM2023Workshop

UAVM @ ACM MM2023 Workshop on UAVs in Multimedia: Capturing the World from a New Perspective
16
star
26

NLP-AICity2021

The 1st Place Submission to AICity Track5 - Natural Language-based Vehicle Retrieval.
Python
14
star
27

Person_reID_baseline_matconvnet

Matconvnet implement of Person re-identification baseline. We arrived Rank@1=87.74% mAP=69.46% only with softmax loss.
Cuda
12
star
28

matlab_email_demo

a easy solution for baby sitting program!!! (MATLAB)
M
11
star
29

Awesome-Text2Motion-Generation

Awesome-Text2Motion-Generation
11
star
30

ICME2022SS

ICME2022 Special Session โ€œBeyond Accuracy: Responsible, Responsive, and Robust Multimedia Retrieval โ€
11
star
31

UAVM2023

ACM MM Workshop on UAVs in Multimedia: Capturing the World from a New Perspective (UAVM 2023)
10
star
32

To-Academic-Newcomers

10
star
33

DCGAN-pytorch

Pytorch implement of DCGAN and LSGAN
Python
8
star
34

University1652-triplet-loss

triplet loss with hard negative / soft margin for the University-1652 dataset.
Python
8
star
35

2016_Class_Activation_Mapping

semantic segmentation in MATLAB
HTML
7
star
36

Robust-GPUs

Python
7
star
37

Cifar10-Adaboost

Python
6
star
38

layumi.github.io

UTS Group Seminar http://www.zdzheng.xyz
HTML
6
star
39

market1501_body_point

MATLAB
6
star
40

2016_Center_Loss

Matlab_ECCV16_Center_Loss
HTML
4
star
41

google_scholar_scrapy

extract data from google scholar
Python
4
star
42

Oxford-Paris-Attack

๐Ÿ™ˆ We added our attacking method ODFA (https://arxiv.org/abs/1809.02681). The performance drops from 88.2% to 2.24% on Oxford. ๐Ÿ™‰
Python
4
star
43

visualize_face_detection_net

MATLAB
3
star
44

SOTA-semi

3
star
45

Awesome-Sign-Language

awesome list for sign language
3
star
46

Matlab_TripletLoss

Matlab_TripletLoss
MATLAB
3
star
47

Batch-Normal-For-Caffe

Extend batch normalization layer for caffe
C++
3
star
48

pytorch-mnist

Draw mnist
Python
3
star
49

2015_speech

word audio recognition
HTML
2
star
50

layumi

2
star
51

pkl2mat

a tool for transfer pkl file to mat file
Python
2
star
52

ComputerVisionAwardPapers

1
star
53

2016_FlowNet

Cuda
1
star
54

Zhedong-Zheng-blog

zhedong zheng's blog
CSS
1
star
55

empty

1
star
56

2016_Video_Stabilization

A project @Fudan for 2016 Digital Image Processing
C
1
star
57

Workshop-Proposal-DDL

1
star
58

WordNet_Matlab

a simple api for matlab to search semantic synonym
MATLAB
1
star