Git Product home page Git Product logo

spherereid's Introduction

SphereReID

This is my implementation of SphereReID.

My working environment is python3.5.2, and my pytorch version is 0.4.0. If things are not going well on your system, please check you environment.

I only implement the network-D in the paper which is claimed to have highest performance of the four networks that the author proposed.

Get Market1501 dataset

Execute the script in the command line:

    $ sh get_market1501.sh

Train and Evaluate

  • To train the model, just run the training script:
    $ python train.py

This will train the model and save the parameters to the directory of res/.

  • To embed the gallery and query set with the trained model and compute the accuracy, directly run:
    $ python evaluate.py

This will embed the gallery and query set, and then compute cmc and mAP.

Notes:

Sadly, I am not able to reproduce the result merely with the method mentioned in the paper. So I add a few other tricks beyond the paper which help to boost the performance, these tricks includes:

  • During training phase, use random erasing augumentation method.

  • During embedding phase, aggregate the embeddings of the original pictures and those of their horizontal counterparts by computing the average of these embeddings, as done in MGN.

  • Change the stride of the last stage of resnet50 backbone from 2 to 1.

  • Adjust the total training epoch number to 150, and let the learning rate jump by a factor of 0.1 at epoch 90 and 130.

With these tricks, the rank-1 cmc and mAP of my implementation reaches 93.08 and 83.01.

spherereid's People

Contributors

coincheung 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

Watchers

 avatar  avatar

spherereid's Issues

Why does your model get a big gap with 4 GPUs and 1 GPU

HI! i wanna ask why i use your model with 4 GPUs can get 93.7% Rank1 and 83.3% mAP, but with 1 GPU, it reduce to 91.2% Rank1 and 81.5% mAP? what numbers of GPU you use in your own model?
(i use 4 GPUs with DataParallel)

understanding feature vector extraction for an image ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1, 2048])

I am trying to extract the feature vector from the trained network of yours. Firstly, I am not able to get a single feature vector for a single image. I do not understand the exact reason behind it.

`import torch
from torch.autograd import Variable
from backbone import Network_D
from PIL import Image
from torchvision.transforms import ToTensor
import numpy
import time
model = Network_D()
model.load_state_dict(torch.load('/home/shubam/Documents/person_reidentification/SphereReID/res/model_final.pkl'))
img_path='/home/shubam/Documents/person_reidentification/SphereReID/dataset/Market-1501-v15.09.15/bounding_box_test/0000_c3s2_105228_06.jpg'
image = Image.open(img_path)
image = ToTensor()(image).unsqueeze(0) # unsqueeze to add artificial first dimension
image = Variable(image)

image = torch.cat((image, image), 0)

image = torch.cat((image, torch.zeros_like(image)), 0)

#print("the size of image is {}".format(image))
t1=time.time()
feature = model.forward(image).detach().cpu().numpy()
print("the feature is {}".format(feature[0, :]))
t2=time.time()
print("time for cpu is {}".format(t2-t1))
feature = model.forward(image).detach().cuda()#.numpy()
print("the feature is {}".format(feature[0, :]))
t3=time.time()
print("time for gpu is {}".format(t3-t2))
`
I get this output:
Traceback (most recent call last):
File "/home/shubam/Documents/person_reidentification/SphereReID/model_converter.py", line 18, in
feature = model.forward(image).detach().cpu().numpy()
File "/home/shubam/Documents/person_reidentification/SphereReID/backbone.py", line 54, in forward
x = self.bn2(x)
File "/home/shubam/.virtualenv/tracker/local/lib/python2.7/site-packages/torch-1.0.1.post2-py2.7-linux-x86_64.egg/torch/nn/modules/module.py", line 489, in call
result = self.forward(*input, **kwargs)
File "/home/shubam/.virtualenv/tracker/local/lib/python2.7/site-packages/torch-1.0.1.post2-py2.7-linux-x86_64.egg/torch/nn/modules/batchnorm.py", line 76, in forward
exponential_average_factor, self.eps)
File "/home/shubam/.virtualenv/tracker/local/lib/python2.7/site-packages/torch-1.0.1.post2-py2.7-linux-x86_64.egg/torch/nn/functional.py", line 1619, in batch_norm
raise ValueError('Expected more than 1 value per channel when training, got input size {}'.format(size))
ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1, 2048])

Secondly, I tried to concatenate zeros like the image to increase the dimensions such that torch.Size([2, 2048)

`image = Variable(image)

image = torch.cat((image, image), 0)

image = torch.cat((image, torch.zeros_like(image)), 0)
#print("the size of image is {}".format(image))
t1=time.time()
feature = model.forward(image).detach().cpu().numpy()
print("the feature is {}".format(feature))
t2=time.time()
print("time for cpu is {}".format(t2-t1))
feature = model.forward(image).detach().cuda()#.numpy()
print("the feature is {}".format(feature))
t3=time.time()
print("time for gpu is {}".format(t3-t2))

`
the output is:
the feature is [[ 0.4966124 0.57359195 0.683048 ... -0.6020484 -0.46173286
0.577405 ]
[-0.4953278 -0.60051304 -0.6328474 ... 0.6000462 0.48753467
-0.6212439 ]]
time for cpu is 0.0762948989868
the feature is tensor([[-0.4958, 0.5337, -0.6106, ..., -0.5830, 0.4491, 0.5779],
[ 0.4971, -0.5606, 0.6608, ..., 0.5810, -0.4233, -0.6217]],
device='cuda:0')
time for gpu is 0.0752019882202

here you can see that both the vectors are different and gives different value in different ways of calculation. could you please suggest me a way to find a feature vector for a given image. Thank you.

Now, you can see that the image with zeros also gets some non zero values as the feature vector.

How to aggregate the embeddings as in MGN?

Dear author, thanks for this nice repo! However, you mentioned that "During embedding phase, aggregate the embeddings of the original pictures and those of their horizontal counterparts by computing the average of these embeddings, as done in MGN."

I can't find how this is achieved in the codes. Can you show me how it's done? Thanks!

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.