Code Monkey home page Code Monkey logo

ecn's Introduction

Preparation

Requirements: Python=3.6 and Pytorch>=1.0.0

  1. Install Pytorch

  2. Download dataset

    Ensure the File structure is as follow:

    ECN/data    
    │
    └───market OR duke OR msmt17
       │   
       └───bounding_box_train
       │   
       └───bounding_box_test
       │   
       └───bounding_box_train_camstyle
       | 
       └───query
    

Training and test domain adaptation model for person re-ID

# For Duke to Market-1501
python main.py -s duke -t market --logs-dir logs/duke2market-ECN

# For Market-1501 to Duke
python main.py -s market -t duke --logs-dir logs/market2duke-ECN

# For Market-1501 to MSMT17
python main.py -s market -t msmt17 --logs-dir logs/market2msmt17-ECN --re 0

# For Duke to MSMT17
python main.py -s duke -t msmt17 --logs-dir logs/duke2msmt17-ECN --re 0

Results

References

  • [1] Our code is conducted based on open-reid

  • [2] Camera Style Adaptation for Person Re-identification. CVPR 2018.

  • [3] Generalizing A Person Retrieval Model Hetero- and Homogeneously. ECCV 2018.

Citation

If you find this code useful in your research, please consider citing:

@inproceedings{zhong2019invariance,
  title={Invariance Matters: Exemplar Memory for Domain Adaptive Person Re-identification},
  author={Zhong, Zhun and Zheng, Liang and Luo, Zhiming and Li, Shaozi and Yang, Yi},
  booktitle={Proceedings of IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
  year={2019},
}

Contact me

If you have any questions about this code, please do not hesitate to contact me.

Zhun Zhong

ecn's People

Contributors

zhunzhong07 avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ecn's Issues

question about the result

Hi,thanks for giving such a fabulous code.Here are some questions about the code.
image
image
Both tables have the same result.
1、These two tables respectively show the results of this paper compared with unsupervised and supervised models, right?
2、Is the code in this article unsupervised or supervised?

thank u

basic information about camstyle

Hi, thanks for your open source code, I am a bit confused about camstyle.I trained the duke dataset with stargan4reid.I found the image size with 256x128(h x w).And I also downloaded your trained camstyle images on BaiduYun.The image size is 256x256(h x w).Results are as follows.

python main.py -s market -t duke --logs-dir logs/market2duke-ECN

duke(camstyle you provided): mAP: 39.4%, top1: 63.2%
duke(I trained camstyle with hhl): mAP:29.9%, top1: 50.2%

Then I know that you retrained a new camstyle model.Could you release the training parameters? Thanks.

ValueError: num_samples should be a positive integeral value, but got num_samples=0

Hi,
I was trying main.py and encountered the following error.

/usr/local/lib/python3.6/dist-packages/sklearn/externals/joblib/externals/cloudpickle/cloudpickle.py:47: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp
log_dir= /home/zamra/PYreps/Person_ReId/ECN/logs
Namespace(arch='resnet50', batch_size=128, data_dir='/home/zamra/PYreps/Person_ReId/ECN/data', dist_metric='euclidean', dropout=0.5, epochs=60, epochs_decay=40, evaluate=False, features=4096, height=256, inv_alpha=0.01, inv_beta=0.05, knn=6, lmd=0.3, logs_dir='/home/zamra/PYreps/Person_ReId/ECN/logs', lr=0.1, momentum=0.9, output_feature='pool5', print_freq=1, re=0.5, resume='', source='duke', target='market', weight_decay=0.0005, width=128, workers=8)
DA dataset loaded
  subset   | # ids | # images
  ---------------------------
  source train    |     0 |        0
  target train    | 'Unknown' |        0
  query    |     0 |        0
  gallery  |     0 |        0
Traceback (most recent call last):
  File "main.py", line 229, in <module>
    main(args)
  File "main.py", line 94, in main
    args.re, args.workers)
  File "main.py", line 50, in get_data
    shuffle=True, pin_memory=True, drop_last=True)
  File "/home/zamra/.local/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 802, in __init__
    sampler = RandomSampler(dataset)
  File "/home/zamra/.local/lib/python3.6/site-packages/torch/utils/data/sampler.py", line 64, in __init__
    "value, but got num_samples={}".format(self.num_samples))
ValueError: num_samples should be a positive integeral value, but got num_samples=0

some question of exemplar memory's training time

Thank you for your open source code,In your paper,you analysed the computational cost of the exemplar memory.But when I ran your code,I found It took me more than two hours in my machine. so I want to ask you whether you run on a single GPU or multiple GPUs ? Or do you have any way to reduce the running time? By the way,my machine configuration is a 12G single GPU.
image
I look forward to your reply,Thank you!

[duplicate code] Why use one_hot * weight if one_hot = torch.ones

Hi, thank you for sharing. There are some part of the code i don't understand their importance. one_hot is defined as torch.ones(inputs.size(0), knn). So why do you need to multiply the confidence score weights by a matrix which values are all ones?

targets_onehot.scatter_(1, index_sorted[:, 0:k], ones_mat * weights)

I try to to visualize the results, and there not difference between one_hot * weights and simply using weights.
Thank you

Exemplar invariance

I noticed the performance is slightly improved compared to the baseline (Source Only) in your paper when you just use the exemplar invariance and source domain labeled data? However, I try to implement it , and the rank1(24%) is lower than that of baseline (28.9). Do you have some training tricks?Can you provide some suggestions?
image

Low accuracy than paper

For Duke to Market-1501 transfer task, I got only

Mean AP: 6.5%
CMC Scores
top-1 20.5%
top-5 32.9%
top-10 40.0%
top-20 47.7%
How can I get the same results as paper? Did you run this version on your machine? Please advice me.

Some questions about the code

Hi, it is happy to follow your papers again.

About the code, I am confused about several places.

Question1:

ECN/reid/models/resnet.py

Lines 100 to 102 in 51b2ac3

tgt_feat = self.drop(tgt_feat)
if output_feature == 'tgt_feat':
return tgt_feat

tgt_feat = F.normalize(x)
tgt_feat = self.drop(tgt_feat)
if output_feature == 'tgt_feat':
     return tgt_feat

norm-drop, so the tgt_feat is not norm, Does it matter when you solve the probability of $p(i|x_{t,i})$? Because this is the first time I see get the feature after drop to calculate.

Question2:

fixed_names = []
for name, module in self.base._modules.items():
if name == "layer3":
# assert fixed_names == ["conv1", "bn1", "relu", "maxpool", "layer1", "layer2"]
break
fixed_names.append(name)
for param in module.parameters():
param.requires_grad = False

        fixed_names = []
        for name, module in self.base._modules.items():
            if name == "layer3":
                # assert fixed_names == ["conv1", "bn1", "relu", "maxpool", "layer1", "layer2"]
                break
            fixed_names.append(name)
            for param in module.parameters():
                param.requires_grad = False

fixed them is the result from experiment or other sources?

Qestion3:

ones_mat = torch.ones(targets.size(0), k).to(self.device)
targets = torch.unsqueeze(targets, 1)
targets_onehot = torch.zeros(inputs.size()).to(self.device)
weights = F.softmax(ones_mat, dim=1)
targets_onehot.scatter_(1, index_sorted[:, 0:k], ones_mat * weights)

what is mean of ones_mat * weights? Is it because of historical something?

        ones_mat = torch.ones(targets.size(0), k).to(self.device)
        targets = torch.unsqueeze(targets, 1)
        targets_onehot = torch.zeros(inputs.size()).to(self.device)

        weights = F.softmax(ones_mat, dim=1)
        targets_onehot.scatter_(1, index_sorted[:, 0:k], ones_mat * weights)

Question4:

targets_onehot.scatter_(1, targets, float(1))

targets_onehot.scatter_(1, targets, float(1))

How do you guarantee that $x_{t,i}$ is not in $M(x_{t,i})$. I mean, my understanding is weight of $M(x_{t,i})$ should be sum to be 1. Or there is something I am wrong?

Question5:

ECN/reid/trainers.py

Lines 104 to 115 in 51b2ac3

def set_model_train(self):
self.model.train()
# Fix first BN
fixed_bns = []
for idx, (name, module) in enumerate(self.model.module.named_modules()):
if name.find("layer3") != -1:
# assert len(fixed_bns) == 22
break
if name.find("bn") != -1:
fixed_bns.append(name)
module.eval()

    def set_model_train(self):
        self.model.train()

        # Fix first BN
        fixed_bns = []
        for idx, (name, module) in enumerate(self.model.module.named_modules()):
            if name.find("layer3") != -1:
                # assert len(fixed_bns) == 22
                break
            if name.find("bn") != -1:
                fixed_bns.append(name)
                module.eval()

My understanding is that since you have fixed conv1~layer2, the bn between them should be mode of eval. Is that right?

Question6:

The CamStyle is the same as the HHL?

Thank you, sir.

can you provide pretrained weights?

I am looking for a ReID demo. thanks for open source. I found you didn't release pretrained model. So if convenient, please upload these pretrained wegiths . thank you

Unused neighbor number in variance loss

Hi, Thanks for your excellent work.
It seems that there something wrong with the neighbor number in invariance loss.
In Line 53 of file reid/loss/invariance.py, loss = self.smooth_loss(inputs, targets) use no parameter neighbor number self.knn.
I think it should be loss = self.smooth_loss(inputs, targets, self.knn)
Can you check it?

memory

Hi, how much memory do you need to run this code?

msmt17 datasets split strategy is different

Hi!
Using the msmt17 dataset you provided in the readme file, there are 60.910 images for testing (only one directory in the provided link). While in the original dataset, the authors provide 82161 images.

Can you confirm that you are using the original splitting strategy?
This is what I get using the original dataset
bbox 126,441
identities 4101 i
train images 32,621
train id 1,041
testing images 82,161
testing id 3,060
query images 11,659

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.