Giter Club home page Giter Club logo

gcl's Introduction

Joint Generative and Contrastive Learning for Unsupervised Person Re-identification

This is the official PyTorch implementation of the CVPR 2021 paper Joint Generative and Contrastive Learning for Unsupervised Person Re-identification.

[Video] [Poster]

missing missing

Installation

Install GCL

Requirements

  • Python 3.6
  • Pytorch 1.2.0
git clone https://github.com/chenhao2345/GCL
cd GCL
python setup.py develop

Prepare Datasets

cd examples && mkdir data

Download the raw datasets DukeMTMC-reID, Market-1501, MSMT17, and then unzip them under the directory like

GCL/examples/data
├── dukemtmc-reid
│   └── DukeMTMC-reID
├── market1501
└── msmt17
    └── MSMT17_V1(or MSMT17_V2)

Install HMR for Mesh Estimation

Download our extracted meshes from Google Drive. Unzip them under the directory like

GCL/examples/mesh
├── dukeMTMC
├── market
└── msmt17

Or refer to HMR ro get meshes for ReID datasets.

Train GCL

Only support 1 GPU (GPU memory > 20GB) training for the moment.

Stage 1: Warm up identity encoder

Train a ResNet50 with an unsupervised method, for example, JVTC(or download our trained models from Google Drive) and MLC.

GCL/examples/logs
└── JVTC
    └── market
        └── resnet50_market075_epoch00045.pth
    └── duke
        └── resnet50_duke075_epoch00040.pth

Stage 2: Warm up structure encoder and discriminator

Adjust path for dataset, mesh, pre-trained identity encoder.

sh train_stage2_market.sh

Stage 3: Joint training

sh train_stage3_market.sh

TensorBoard Visualization

Stage 2:

For example,

tensorboard --logdir logs/market_init_JVTC_unsupervised/

Stage 3:

For example,

tensorboard --logdir logs/market_init_JVTC_unsupervised/stage3/

Citation

@InProceedings{Chen_2021_CVPR,
    author    = {Chen, Hao and Wang, Yaohui and Lagadec, Benoit and Dantcheva, Antitza and Bremond, Francois},
    title     = {Joint Generative and Contrastive Learning for Unsupervised Person Re-Identification},
    booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
    month     = {June},
    year      = {2021},
    pages     = {2004-2013}
}

gcl's People

Contributors

chenhao2345 avatar wyhsirius avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gcl's Issues

The fid in Eq(2)

The fid is not described in Fig 2. If it can be decripted, the readability would be improved.

About Generative module and GAN loss

image
The above is the generative module in the paper.

Can I ask why you applied the x'org part in the GAN loss?

Is it because the training generator is hard without using x'org part?

Feature memory initialization issue.

image

Why do you normalize features again when initializing feature memory in stage 3?

image

Even though your ResNet code already F.normalize the feature and outputs it.

when i run the file train_stage3_market.sh,it errors.

Epoch 1 has 10408 labeled samples of 234 ids and 2528 unlabeled samples
Traceback (most recent call last):
File "examples/main.py", line 381, in
main()
File "examples/main.py", line 151, in main
main_worker(args)
File "examples/main.py", line 279, in main_worker
feat_nv2recon, f, f_recon, f_nv, f_nv2recon, pid, index, config, iterations)
File "/home/ly/yx/GCL/gcl/trainer.py", line 112, in gen_update
self.memory_loss_id = self.memory(F.normalize(f), F.normalize(f_nv), index)
File "/home/ly/anaconda3/envs/GCL/lib/python3.7/site-packages/torch/nn/modules/module.py", line 550, in call
result = self.forward(*input, **kwargs)
File "/home/ly/yx/GCL/gcl/models/memory.py", line 66, in forward
negatives = torch.stack(negatives)
RuntimeError: stack expects each tensor to be equal size, but got [8192] at entry 0 and [7833] at entry 3

when i run the file train

Epoch 1 has 10408 labeled samples of 234 ids and 2528 unlabeled samples
Traceback (most recent call last):
File "examples/main.py", line 381, in
main()
File "examples/main.py", line 151, in main
main_worker(args)
File "examples/main.py", line 279, in main_worker
feat_nv2recon, f, f_recon, f_nv, f_nv2recon, pid, index, config, iterations)
File "/home/ly/yx/GCL/gcl/trainer.py", line 112, in gen_update
self.memory_loss_id = self.memory(F.normalize(f), F.normalize(f_nv), index)
File "/home/ly/anaconda3/envs/GCL/lib/python3.7/site-packages/torch/nn/modules/module.py", line 550, in call
result = self.forward(*input, **kwargs)
File "/home/ly/yx/GCL/gcl/models/memory.py", line 66, in forward
negatives = torch.stack(negatives)
RuntimeError: stack expects each tensor to be equal size, but got [8192] at entry 0 and [7833] at entry 3

load the pretrained identity enconder

Couldyou please tell me whether the pretrained identity encoder network you are training in stage 2 is idnet or gen_ pth\dis_.th? For this problem, I can modify the K value without reporting an error, but I feel that it will affect the training accuracy.

Some questions in reproducing the code in windows OS

陈博士你好
我是在windows系统运行你的代码的,有一些问题想问下你,期待你的回复,谢谢:)

目前我将duke作为目标域进行训练,根据Github上的指导,我是这么做的:

根据train_stage2_duke.sh的内容在main.py里面调整【parser.add_argument】参数,然后直接运行main.py

目前结果如下图:

image

想问一下
1、在这段步骤中不会出现rank-1,map类的指标显示么?
2、指导里面只说了纯无监督的执行方法,如果要做duke→market这类的跨域应该怎么修改文件呢?

torch version issue.

Hello.

I have some issue with your model with different torch version.

When I trained your network with torch version 1.6.0, the performance was really degraded.

Stage3 first epoch results and losses are as below.

pytorch == 1.2.0 (Your original version)
image
image

pytorch == 1.6.0
image
image

As you can see, it is so differenent when I only changed torch version.

I am trying to figure out what caused the problem.
Could you give me some help what is causing the difference? I need to inevitably use torch version higher than 1.6.0..

Thanks in advance.

Problems with generated images

Hi, I have a few problem with generating synthetic persons using your code in examples/generate_data.py.!

This is the resuls what I get from original image to generated image.
0002_c1s1_000451_03

0002_c1s1_000451_03

As you can see, the result is not good..

I have resumed your model same as when ./train_stage3_market.sh starts.
Below is the model(generator, discrimminator) weights when ./train_stage2_market.sh ends.
So, I resumed your model from those weights from the code below

"
trainer = DGNet_Trainer(config, model_1, args.idnet_fix).cuda()
iterations = trainer.resume(checkpoint_path, hyperparameters=config)
"

image

image

Actually, I trained your model with stage3, -> ./train_stage3_market.sh
and saved the model_best.pth in the outputs folder like below images.
image
image

So, I tried to bring your model_best.pth and resume it, hopefully thinking it will generate good results, but I could not resume your model because of the difference of the weights and models,.
image

What should I do to generate good results of your training datasets??
Thanks in advance!

About 3D Mesh generator.

Thank you for sharing your great work.
I have a few questions about the 3D Mesh generator!.

  1. Would it be okay if I use other recent 3D Human Mesh generator?
  2. Did you just use their pretrained 3D Mesh model and input the Re-ID persons datasets
    to create 3D Mesh persons???

Thanks in advance.

How did you warm up identity encoder??

Thanks you for providing your great work.

I read your code and there seems to be no code stage=1, warming up identity encoder.

It saids in the paper that

"We firstly use a state-of-the-art unsupervised Re - ID method to warm up Eid, which is then
considered as a baseline in our ablation studies" which you used JTCV? method to warm up identity encoder.
"

I figured out when input image x is fed into identity-encoder(Eid), it outputs feature vector fid(2048x4x1 feature after part average pooling in ft_net in the code). But how did you train the encoder(Eid)?? Did you use just apply your ft_net
in the JTCV, or MLC code and train it??

For example, below is the framework of MLC paper.
image

In the above image, the CNN layer is your ft_net and you trained the whole network so the weights in the CNN(ft_net) could be warmed up?

image

Is this right??

是否可以提供预训练模型

你好,现在我想用预训练模型跑generate_data.py生成数据

python examples/generate_data.py

提示我没有outputs/market_init_JVTC_unsupervised/checkpoints没有模型,是否可以提供预训练模型网盘,谢谢
训练模型需要太大的显存,起不来

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.