Giter VIP home page Giter VIP logo

implementation-cvpr2015-cnn-for-reid's Introduction

Implementation-CVPR2015-CNN-for-ReID


Notice:

Code for CUHK03 has already been updated.

Test Environment:

  • Ubuntu 18.04
  • Python 3.6.6
  • TensorFlow 1.11
  • Keras 2.1.6-tf
  • CUDA 9.0
  • cudnn 7.3.1
  • NVIDIA GTX 1080Ti

Working on:

  • Use TensorFlow Low API to update the code
  • CMC and mAP
  • TensorBoard
  • Multi-GPU
  • Estimator

Things to do:

  • Show the Test Result Form.
  • Share the trained model to reproduce the test result with Baidu Drive or Google Drive.
  • Same to the code for Market-1501.

Implementation for CVPR 2015 Paper: "An Improved Deep Learning Architecture for Person Re-Identification".

Paper link

This architechture is implemented based on Keras with Tensorflow backen using Python Programming Language.

Train the model on which dataset?

  1. CUHK-03

The model structure

implementation-cvpr2015-cnn-for-reid's People

Contributors

baomingwang avatar ning-ding avatar prashanthbasani 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  avatar

implementation-cvpr2015-cnn-for-reid's Issues

ValueError: output of generator should be a tuple `(x, y, sample_weight)` or `(x, y)`. Found: None

Does anybody come across this error? It seems to be something wrong with Keras itself and I have not find an executable way to solve it yet. Appreciate for your kind help. The details are as follows.

C:\ProgramData\Anaconda3\lib\site-packages\keras\legacy\interfaces.py:86: UserWarning: Update your fit_generator call to the Keras 2 API: fit_generator(<data_prep..., 30000, 1, validation_data=<data_prep..., validation_steps=1000)
'` call to the Keras 2 API: ' + signature)
Epoch 1/1
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\threading.py", line 916, in _bootstrap_inner
self.run()
File "C:\ProgramData\Anaconda3\lib\threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\keras\engine\training.py", line 606, in data_generator_task
generator_output = next(self._generator)
File "C:\ProgramData\Anaconda3\lib\site-packages\keras\preprocessing\image.py", line 727, in next
return self.next(*args, **kwargs)
File "F:\Users\wanfb\Documents\Implementation-CVPR2015-CNN-for-ReID-master\CUHK03\data_preparation.py", line 34, in next
index_array, current_index, current_batch_size = next(self.index_generator)
File "C:\ProgramData\Anaconda3\lib\site-packages\keras\preprocessing\image.py", line 718, in _flow_index
yield (index_array[current_index: current_index + current_batch_size],
TypeError: slice indices must be integers or None or have an index method

Traceback (most recent call last):
File "main.py", line 100, in
main(args.dataset_path)
File "main.py", line 20, in main
train(model, dataset_path)
File "main.py", line 43, in train
model.fit_generator(Data_Generator.flow(f,flag = flag_train),one_epoch,epoch_num,validation_data=Data_Generator.flow(f,train_or_validation=which_val_data,flag=flag_val),nb_val_samples=nb_val_samples)
File "C:\ProgramData\Anaconda3\lib\site-packages\keras\legacy\interfaces.py", line 87, in wrapper
return func(*args, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\keras\engine\training.py", line 1851, in fit_generator
str(generator_output))
ValueError: output of generator should be a tuple (x, y, sample_weight) or (x, y). Found: None

When train the model with running main.py, i triggers a TypeError

Error message is as follow:
File "F:/Implementation-CVPR2015-CNN-for-ReID-master/CUHK03/main.py", line 109, in
main('F:/Implementation-CVPR2015-CNN-for-ReID-master/CUHK03/cuhk-03.h5')

File "F:/Implementation-CVPR2015-CNN-for-ReID-master/CUHK03/main.py", line 21, in main
train(model, dataset_path)

File "F:/Implementation-CVPR2015-CNN-for-ReID-master/CUHK03/main.py", line 49, in train
model.fit_generator(Data_Generator.flow(f,flag = flag_train),
one_epoch,epoch_num,
validation_data=Data_Generator.flow(f,train_or_validation=which_val_data,flag=flag_val),
nb_val_samples=nb_val_samples)

File "E:\Anaconda\lib\site-packages\keras\legacy\interfaces.py", line 91, in wrapper
return func(*args, **kwargs)

File "E:\Anaconda\lib\site-packages\keras\engine\training.py", line 2079, in fit_generator
do_validation = bool(validation_data)

TypeError: 'float' object cannot be interpreted as an integer

python version: 3.5.2
keras version:2.1.5
tensorflow-gpu:1.7
OS:windows 10

It seems that bool() need a integer argument,but 'validation_data' is an object of class 'NumpyArrayIterator_for_CUHK03 '. I don't know how to deal with it.Thanks for your help.
@Ning-Ding

About modification and redistribution

Hi! I modified your model to work with ROS(Robot OS) and uploaded modified version in

https://github.com/swstarlab/DIP

with other modules such as object detection, image captioning modules.

I checked redistribution term of other open-source codes but I can't find

LICENCE file in your repo.

If you have any issues about redistribution, please tell me anytime:)

The `Merge` layer is deprecated

Thank you for share your work.
When I trying to run the model using market1501 database, I have problem like this:

File "model_for_market1501.py", line 69, in cross_input_asym
tensor_left_padding = K.spatial_2d_padding(tensor_left,padding=(2,2))
File "/usr/local/lib/python2.7/dist-packages/Keras-2.0.3-py2.7.egg/keras/backend/tensorflow_backend.py", line 1834, in spatial_2d_padding
assert len(padding[0]) == 2
TypeError: object of type 'int' has no len()

my tensorflow version is ** 0.12**

Thankou for help!!

Model test of CMC is ineffective

The loss I trained on the CHUK03 data set is:
loss: 0.0057 - acc: 0.9997 - val_loss: 0.0048 - val_acc: 1.0000
Itrained 5500 epoch.
the result of CMC is not good,rank1 to rank 20 are listed as below.
0.0
0.04
0.03
0.07
0.11
0.09
0.11
0.19
0.19
0.26
0.28
0.27
0.28
0.35
0.32
0.43
0.42
0.45
0.47
0.5
I don't know why the effect is so bad, whether it's a training problem or a model problem. I use the CMC function in main.py.

TensorFlow and keras version

Hi,
First of all, thanks for this work.
I am trying to run both models, but I think that I have some problems with the versions of the libraries.
Which versions did you use ?

In CUHK03 dataset, you divide the dataset into 'a' and 'b', according to the views of the cameras, they don't say nothing like this in the paper. I am newbie with this dataset, is it normal ?

Thanks!!!

TypeError : get_updates() takes exactly 4 arguments (3 given)

Hi guys, I've installed all dependencies for this project, but when I run main.py I got this error:
TypeError:get_updates() takes exactly 4 arguments (3 given)

I've checked all files of project, my project has compiled successfully and couldn't find where this get_update used.
please help, I am in a hurry.

regards.
screenshot from 2018-05-17 09-09-19

training model use gpu

Dear author, I came across a problem when i training my own data . I find the progress use CPU instead of GPU, I have already set TensorFlow as backend , but it dose not work. Could you give me some help?

message as follow:

Total params: 2,183,147.0
Trainable params: 2,183,147.0
Non-trainable params: 0.0


Model Compile Successful.
number 0 in 100
Epoch 1/1
4/30000 [..............................] - ETA: 135972s - loss: 1.2097 - acc: 0.4883^CTraceback (most recent call last):

GPU status
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 384.69 Driver Version: 384.69 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+==================|
| 0 GeForce GTX 108... Off | 00000000:03:00.0 Off | N/A |
| 29% 40C P0 52W / 250W | 0MiB / 11172MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
| 1 GeForce GTX 108... Off | 00000000:04:00.0 Off | N/A |
| 30% 44C P0 48W / 250W | 0MiB / 11172MiB | 1% Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|==============================================|
| No running processes found |
+-----------------------------------------------------------------------------+

a problem with running main.py

Hi.
I tried to run main.py for cuhk03,but I met a problem.Additionally,my tensorflow version is 1.4.0,keras is 2.0.8,python is 3.6.2 and cuDNN is 6.0.I really don't know how to solve.Thanks for your help!
Error information is as follows:
Model Compile Successful.
number 0 in 100
F:/py/main.py:44: UserWarning: The semantics of the Keras 2 argument steps_per_epoch is not the same as the Keras 1 argument samples_per_epoch. steps_per_epoch is the number of batches to draw from the generator at each epoch. Basically steps_per_epoch = samples_per_epoch/batch_size. Similarly nb_val_samples->validation_steps and val_samples->steps arguments have changed. Update your method calls accordingly.
model.fit_generator(Data_Generator.flow(f,flag = flag_train),one_epoch,epoch_num,validation_data=Data_Generator.flow(f,train_or_validation=which_val_data,flag=flag_val),nb_val_samples=nb_val_samples)
F:/py/main.py:44: UserWarning: Update your fit_generator call to the Keras 2 API: fit_generator(<data_prep..., 30000, 1, validation_data=<data_prep..., validation_steps=1000)
model.fit_generator(Data_Generator.flow(f,flag = flag_train),one_epoch,epoch_num,validation_data=Data_Generator.flow(f,train_or_validation=which_val_data,flag=flag_val),nb_val_samples=nb_val_samples)
Traceback (most recent call last):
File "F:/py/main.py", line 101, in
main(dataset_path)
File "F:/py/main.py", line 21, in main
train(model, dataset_path)
File "F:/py/main.py", line 44, in train
model.fit_generator(Data_Generator.flow(f,flag = flag_train),one_epoch,epoch_num,validation_data=Data_Generator.flow(f,train_or_validation=which_val_data,flag=flag_val),nb_val_samples=nb_val_samples)
File "D:\Program Files (x86)\Anaconda3\lib\site-packages\keras\legacy\interfaces.py", line 87, in wrapper
return func(*args, **kwargs)
File "D:\Program Files (x86)\Anaconda3\lib\site-packages\keras\engine\training.py", line 1926, in fit_generator
self._make_train_function()
File "D:\Program Files (x86)\Anaconda3\lib\site-packages\keras\engine\training.py", line 960, in _make_train_function
loss=self.total_loss)
TypeError: get_updates() missing 1 required positional argument: 'constraints'

Process finished with exit code 1

Error with "tf.python.control_flow_ops = tf"

Hello, firstly thanks for your effort!
when i'm trying to redo the re-id project with your code(marked1501), i encountered an error given as followed:

Traceback (most recent call last):
  File "/home/abner/CVPR2015-CNN-for-ReID/market1501/model_for_market1501.py", line 6, in <module>
    tf.python.control_flow_ops = tf
AttributeError: 'module' object has no attribute 'python'

I have tried my best but can't solved it. I'm wondering if you can give me a hand!
Thanks again!

Folder not found errors

I get this error when I try to run the ./CUHK03/create_dataset.py code. can you please let me know how to fix it:

Traceback (most recent call last):
  File "./CUHK03/create_dataset.py", line 92, in <module>
    create_dataset(args.mat_file_path)
  File "./CUHK03/create_dataset.py", line 33, in create_dataset
    val_index = (f[f['testsets'][0][0]][:].T - 1).tolist()
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper (/Users/ilan/minonda/conda-bld/h5py_1490025880382/work/h5py/_objects.c:2846)
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper (/Users/ilan/minonda/conda-bld/h5py_1490025880382/work/h5py/_objects.c:2804)
  File "/Users/mf186053/anaconda/lib/python2.7/site-packages/h5py/_hl/group.py", line 169, in __getitem__
    oid = h5o.open(self.id, self._e(name), lapl=self._lapl)
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper (/Users/ilan/minonda/conda-bld/h5py_1490025880382/work/h5py/_objects.c:2846)
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper (/Users/ilan/minonda/conda-bld/h5py_1490025880382/work/h5py/_objects.c:2804)
  File "h5py/h5o.pyx", line 190, in h5py.h5o.open (/Users/ilan/minonda/conda-bld/h5py_1490025880382/work/h5py/h5o.c:3740)
KeyError: "Unable to open object (Object 'testsets' doesn't exist)"

error in CUHK03

please help me solve this problem:
File "main.py", line 460, in
validation_steps=1)
File "/home/omnisky/anaconda3/envs/zhaoyin_env/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py", line 1509, in fit
validation_split=validation_split)
File "/home/omnisky/anaconda3/envs/zhaoyin_env/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py", line 953, in _standardize_user_data
K.get_session().run(x.initializer)
File "/home/omnisky/anaconda3/envs/zhaoyin_env/lib/python3.6/site-packages/tensorflow/python/keras/backend.py", line 461, in get_session
_SESSION = session_module.Session(config=config)
File "/home/omnisky/anaconda3/envs/zhaoyin_env/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1511, in init
super(Session, self).init(target, graph, config=config)
File "/home/omnisky/anaconda3/envs/zhaoyin_env/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 634, in init
self._session = tf_session.TF_NewSessionRef(self._graph._c_graph, opts)
tensorflow.python.framework.errors_impl.InternalError: cudaGetDevice() failed. Status: CUDA driver version is insufficient for CUDA runtime version

Weights

Hi,
The computing performance of my GPU is very low, could you upload the weights ?
Thank you!

problem in Market 1501

Hello, Author. I have this problem in Market 1501.
import tensorflow as tf
tf.python.control_flow_ops = tf

When I corrected this mistake in my own way, the following problems arose:
now begin to compile the model with the difference between ones and neighbour matrixs.
/home/omnisky/zy/market1501/model_for_market1501.py:95: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(20, (5, 5), kernel_regularizer=<keras.reg..., data_format="channels_last")
share = Convolution2D(20,5,5,dim_ordering='tf', W_regularizer=l2(l=weight_decay))
/home/omnisky/zy/market1501/model_for_market1501.py:100: UserWarning: Update your MaxPooling2D call to the Keras 2 API: MaxPooling2D(data_format="channels_last")
a4 = MaxPooling2D(dim_ordering='tf')(a3)
/home/omnisky/zy/market1501/model_for_market1501.py:101: UserWarning: Update your MaxPooling2D call to the Keras 2 API: MaxPooling2D(data_format="channels_last")
b4 = MaxPooling2D(dim_ordering='tf')(b3)
/home/omnisky/zy/market1501/model_for_market1501.py:102: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(25, (5, 5), kernel_regularizer=<keras.reg..., data_format="channels_last")
share2 = Convolution2D(25,5,5,dim_ordering='tf', W_regularizer=l2(l=weight_decay))
/home/omnisky/zy/market1501/model_for_market1501.py:107: UserWarning: Update your MaxPooling2D call to the Keras 2 API: MaxPooling2D(data_format="channels_last")
a7 = MaxPooling2D(dim_ordering='tf')(a6)
/home/omnisky/zy/market1501/model_for_market1501.py:108: UserWarning: Update your MaxPooling2D call to the Keras 2 API: MaxPooling2D(data_format="channels_last")
b7 = MaxPooling2D(dim_ordering='tf')(b6)
Traceback (most recent call last):
File "/home/omnisky/zy/market1501/model_for_market1501.py", line 393, in
model = model_def()
File "/home/omnisky/zy/market1501/model_for_market1501.py", line 109, in model_def
a8 = merge([a7,b7],mode=cross_input_asym,output_shape=cross_input_shape)
TypeError: 'module' object is not callable

Look forward to your reply

Testing the model

@Ning-Ding @prashanthbasani @wangbm HI guys thanks for the wonderful work , just wanted to know after running the model how to test it , i donot see any test.py file can you let me know the mode to test it

TypeError: get_updates() missing 1 required positional argument: 'constraints'

Dear author, I came across a problem while compiling your code. I ran " python main.py --dataset cuhk-03.h5, to get the following error. A lot of efforts were paid to solve the problem but I still can't figure it out. Could you please give me some help?

F:\Users\wanfb\Documents\Implementation-CVPR2015-CNN-for-ReID-master\CUHK03>python main.py --dataset cuhk-03.h5
Using TensorFlow backend.


Layer (type) Output Shape Param # Connected to

input_1 (InputLayer) (None, 160, 60, 3) 0


conv2d_1 (Conv2D) (None, 156, 56, 20) 1520 input_1[0][0]
input_2[0][0]


max_pooling2d_1 (MaxPooling2D) multiple 0 conv2d_1[0][0]
conv2d_1[1][0]
conv2d_2[0][0]
conv2d_2[1][0]
conv2d_5[0][0]
conv2d_6[0][0]


input_2 (InputLayer) (None, 160, 60, 3) 0


conv2d_2 (Conv2D) (None, 74, 24, 25) 12525 max_pooling2d_1[0][0]
max_pooling2d_1[1][0]


lambda_1 (Lambda) (None, 185, 60, 25) 0 max_pooling2d_1[2][0]
max_pooling2d_1[3][0]


up_sampling2d_1 (UpSampling2D) (None, 185, 60, 25) 0 max_pooling2d_1[2][0]
max_pooling2d_1[3][0]


lambda_2 (Lambda) (None, 185, 60, 25) 0 lambda_1[0][0]
lambda_1[1][0]


add_1 (Add) (None, 185, 60, 25) 0 up_sampling2d_1[0][0]
lambda_2[1][0]


add_2 (Add) (None, 185, 60, 25) 0 up_sampling2d_1[1][0]
lambda_2[0][0]


conv2d_3 (Conv2D) (None, 37, 12, 25) 15650 add_1[0][0]


conv2d_4 (Conv2D) (None, 37, 12, 25) 15650 add_2[0][0]


conv2d_5 (Conv2D) (None, 35, 10, 25) 5650 conv2d_3[0][0]


conv2d_6 (Conv2D) (None, 35, 10, 25) 5650 conv2d_4[0][0]


concatenate_1 (Concatenate) (None, 17, 5, 50) 0 max_pooling2d_1[4][0]
max_pooling2d_1[5][0]


flatten_1 (Flatten) (None, 4250) 0 concatenate_1[0][0]


dense_1 (Dense) (None, 500) 2125500 flatten_1[0][0]


dense_2 (Dense) (None, 2) 1002 dense_1[0][0]

Total params: 2,183,147
Trainable params: 2,183,147
Non-trainable params: 0


Model Compile Successful.
number 0 in 100
start model.fit_generator
Traceback (most recent call last):
File "main.py", line 108, in
main(args.dataset_path)
File "main.py", line 24, in main
train(model, dataset_path)
File "main.py", line 49, in train
model.fit_generator(Data_Generator.flow(f,flag = flag_train),one_epoch,epoch_num,validation_data=Data_Generator.flow(f,train_or_validation=which_v
al_data,flag=flag_val),validation_steps=nb_val_samples, workers=1)
File "C:\ProgramData\Anaconda3\lib\site-packages\keras\legacy\interfaces.py", line 87, in wrapper
return func(*args, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\keras\engine\training.py", line 1961, in fit_generator
self._make_train_function()
File "C:\ProgramData\Anaconda3\lib\site-packages\keras\engine\training.py", line 990, in _make_train_function
loss=self.total_loss)
TypeError: get_updates() missing 1 required positional argument: 'constraints'

fit_generator throws error on validation data being float data type

I'm trying to run CUHK03 Person Re-ID script.
Error text reads as follows:

TypeError Traceback (most recent call last)
in ()
----> 1 main("E:\DL\cuhk-03.h5")

in main(dataset_path)
17 model = generate_model()
18 model = compile_model(model)
---> 19 train(model, dataset_path)
20
21 def train(model,

in train(model, h5_path, weights_name, train_num, one_epoch, epoch_num, flag_random, random_pattern, flag_train, flag_val, which_val_data, nb_val_samples)
39 rand_x = np.random.rand()
40 flag_train = random_pattern(rand_x)
---> 41 model.fit_generator(Data_Generator.flow(f,flag = flag_train),one_epoch,epoch_num,validation_data=Data_Generator.flow(f,train_or_validation=which_val_data,flag=flag_val),nb_val_samples=nb_val_samples)
42 Rank1s.append(round(cmc(model)[0],2))
43 print (Rank1s)

~\Anaconda3\lib\site-packages\keras\legacy\interfaces.py in wrapper(*args, **kwargs)
89 warnings.warn('Update your ' + object_name + 90 ' call to the Keras 2 API: ' + signature, stacklevel=2)
---> 91 return func(*args, **kwargs)
92 wrapper._original_function = func
93 return wrapper

~\Anaconda3\lib\site-packages\keras\engine\training.py in fit_generator(self, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, class_weight, max_queue_size, workers, use_multiprocessing, shuffle, initial_epoch)
2023 epoch = initial_epoch
2024
-> 2025 do_validation = bool(validation_data)
2026 self._make_train_function()
2027 if do_validation:

TypeError: 'float' object cannot be interpreted as an integer

I am using Jupyter Notebook in Anaconda on Windows 10(x86).
Keras version 2.1.3
Python version 3.6.3
Tensorflow backend (1.4.0)

about the train result

my result is
[0.03]
number 1 in 10
[0.03, 0.03]
number 2 in 10
[0.03, 0.03, 0.03]
number 3 in 10
[0.03, 0.03, 0.03, 0.03]
number 4 in 10
[0.03, 0.03, 0.03, 0.03, 0.03]
number 5 in 10
[0.03, 0.03, 0.03, 0.03, 0.03, 0.03]
number 6 in 10
[0.03, 0.03, 0.03, 0.03, 0.03, 0.03, 0.03]
number 7 in 10
[0.03, 0.03, 0.03, 0.03, 0.03, 0.03, 0.03, 0.03]
number 8 in 10
[0.03, 0.03, 0.03, 0.03, 0.03, 0.03, 0.03, 0.03, 0.03]
number 9 in 10
[0.03, 0.03, 0.03, 0.03, 0.03, 0.03, 0.03, 0.03, 0.03, 0.03]
why it's not learning

training result

In training, the result is that the precision of the training set reaches 99 or more, but the accuracy of the validation set is only 56. The loss values also vary greatly, there is an overfitting situation, and the first rank-1 shows 0.08. It is how it happened? @Ning-Ding @prashanthbasani @wangbm

How to use the models

Hi, thanks for the code. This is sort of an absolute beginner question but how do you use the models to test the performance over the datasets once you compile the models. I ran model_for_cuhk03.py and got the message:

model definition complete
model definition done.
model compile done.

together with the network architecture. How do I continue from here?

CMC rank

Hi,

How to achieve the ranks with the same mentioned in the paper for CUHK03 for example.
Thanks

Batch size and iteration

Hi,
First of all thanks a lot for the code.
This is sort of an absolute beginner question, but if you use 150 batch size samples, and the total images of the CUHK03 dataset are 13164, the numbers of iteration per epoch should be 13164/batch size, right?. If you use 30000 iteration don't you risk to fall in the overfitting problem?
In the article, there was written that they use 210000 iteration, but they don't clarify if they use 210000 iterations per epoch or this number include all training iterations.

Thanks

Data augmentation

Hi,
First of all, thanks for your work!

In a previous issue you said that you have 130000 images, they are image pairs, are they ?
In data augmentation, I understand that you double the dataset by a random transform.

Do you consider to add more transformation to enlarge your data set ? or it may be to noisy ?
thanks!

Ran out of memory


W tensorflow/core/common_runtime/bfc_allocator.cc:274] **_*******************************xxx************************xx********************xxxxxxxxxxxxxxxxx
W tensorflow/core/common_runtime/bfc_allocator.cc:275] Ran out of memory trying to allocate 25.41MiB.  See logs for memory state.
W tensorflow/core/framework/op_kernel.cc:993] Resource exhausted: OOM when allocating tensor with shape[150,25,74,24]
Traceback (most recent call last):
  File "main.py", line 100, in <module>
    main(args.dataset_path)
  File "main.py", line 20, in main
    train(model, dataset_path)
  File "main.py", line 43, in train
    model.fit_generator(Data_Generator.flow(f,flag = flag_train),one_epoch,epoch_num,validation_data=Data_Generator.flow(f,train_or_validation=which_val_data,flag=flag_val),nb_val_samples=nb_val_samples)
  File "/Users/gerrie/tensorflow/lib/python2.7/site-packages/keras/legacy/interfaces.py", line 88, in wrapper
    return func(*args, **kwargs)
  File "/Users/gerrie/tensorflow/lib/python2.7/site-packages/keras/engine/training.py", line 1877, in fit_generator
    class_weight=class_weight)
  File "/Users/gerrie/tensorflow/lib/python2.7/site-packages/keras/engine/training.py", line 1621, in train_on_batch
    outputs = self.train_function(ins)
  File "/Users/gerrie/tensorflow/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py", line 2103, in __call__
    feed_dict=feed_dict)
  File "/Users/gerrie/tensorflow/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 767, in run
    run_metadata_ptr)
  File "/Users/gerrie/tensorflow/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 965, in _run
    feed_dict_string, options, run_metadata)
  File "/Users/gerrie/tensorflow/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1015, in _do_run
    target_list, options, run_metadata)
  File "/Users/gerrie/tensorflow/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1035, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.ResourceExhaustedError: OOM when allocating tensor with shape[150,74,24,25]
	 [[Node: conv2d_2/convolution = Conv2D[T=DT_FLOAT, data_format="NHWC", padding="VALID", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/gpu:0"](max_pooling2d_1/MaxPool, conv2d_2/kernel/read)]]
	 [[Node: add_9/_35 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_19807_add_9", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]()]]

Caused by op u'conv2d_2/convolution', defined at:
  File "main.py", line 100, in <module>
    main(args.dataset_path)
  File "main.py", line 18, in main
    model = generate_model()
  File "/Volumes/more/source/cv/reid/Implementation-CVPR2015-CNN-for-ReID/CUHK03/model.py", line 61, in generate_model
    x1 = share_conv_2(x1)
  File "/Users/gerrie/tensorflow/lib/python2.7/site-packages/keras/engine/topology.py", line 578, in __call__
    output = self.call(inputs, **kwargs)
  File "/Users/gerrie/tensorflow/lib/python2.7/site-packages/keras/layers/convolutional.py", line 164, in call
    dilation_rate=self.dilation_rate)
  File "/Users/gerrie/tensorflow/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py", line 2893, in conv2d
    data_format='NHWC')
  File "/Users/gerrie/tensorflow/lib/python2.7/site-packages/tensorflow/python/ops/nn_ops.py", line 639, in convolution
    op=op)
  File "/Users/gerrie/tensorflow/lib/python2.7/site-packages/tensorflow/python/ops/nn_ops.py", line 308, in with_space_to_batch
    return op(input, num_spatial_dims, padding)
  File "/Users/gerrie/tensorflow/lib/python2.7/site-packages/tensorflow/python/ops/nn_ops.py", line 631, in op
    name=name)
  File "/Users/gerrie/tensorflow/lib/python2.7/site-packages/tensorflow/python/ops/nn_ops.py", line 129, in _non_atrous_convolution
    name=name)
  File "/Users/gerrie/tensorflow/lib/python2.7/site-packages/tensorflow/python/ops/gen_nn_ops.py", line 396, in conv2d
    data_format=data_format, name=name)
  File "/Users/gerrie/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 763, in apply_op
    op_def=op_def)
  File "/Users/gerrie/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2327, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "/Users/gerrie/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1226, in __init__
    self._traceback = _extract_stack()

ResourceExhaustedError (see above for traceback): OOM when allocating tensor with shape[150,74,24,25]
	 [[Node: conv2d_2/convolution = Conv2D[T=DT_FLOAT, data_format="NHWC", padding="VALID", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/gpu:0"](max_pooling2d_1/MaxPool, conv2d_2/kernel/read)]]
	 [[Node: add_9/_35 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_19807_add_9", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]()]]

Seem like GPU memory run out . How to solve this problem?

my device is :

CUHK03 git:(master) ✗  $ cuda-smi
Device 0 [PCIe 0:1:0.0]: GeForce GT 650M (CC 3.0): 745.94 of 1023.7 MB (i.e. 72.9%) Free

The memory should be enough since I've ran other big project using tensorflow.
and I run on macOS 10.12. latest tensorflow version .

load model error.

I try to save model after every iteration,and when i reload the model ,it report error:ValueError: Missing layer: input_2.
model = load_model('model35.h5')
File "/usr/local/lib/python3.5/dist-packages/keras/models.py", line 233, in load_model
model = model_from_config(model_config, custom_objects=custom_objects)
File "/usr/local/lib/python3.5/dist-packages/keras/models.py", line 307, in model_from_config
return layer_module.deserialize(config, custom_objects=custom_objects)
File "/usr/local/lib/python3.5/dist-packages/keras/layers/init.py", line 54, in deserialize
printable_module_name='layer')
File "/usr/local/lib/python3.5/dist-packages/keras/utils/generic_utils.py", line 139, in deserialize_keras_object
list(custom_objects.items())))
File "/usr/local/lib/python3.5/dist-packages/keras/engine/topology.py", line 2450, in from_config
process_layer(layer_data)
File "/usr/local/lib/python3.5/dist-packages/keras/engine/topology.py", line 2437, in process_layer
raise ValueError('Missing layer: ' + inbound_layer_name)
ValueError: Missing layer: input_2

Similarly,when i add json_string = model.to_json() open('my_model_architecture.json','w').write(json_string)in main,
model = generate_model()
model = compile_model(model)
json_string = model.to_json()
open('model.json','w').write(json_string)

and when i try to reload the model
from keras.models import model_from_json

json_file = open('model.json', 'r')
loaded_model_json = json_file.read()
json_file.close()
loaded_model = model_from_json(loaded_model_json)
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.5/dist-packages/keras/models.py", line 339, in model_from_json
return layer_module.deserialize(config, custom_objects=custom_objects)
File "/usr/local/lib/python3.5/dist-packages/keras/layers/init.py", line 54, in deserialize
printable_module_name='layer')
File "/usr/local/lib/python3.5/dist-packages/keras/utils/generic_utils.py", line 139, in deserialize_keras_object
list(custom_objects.items())))
File "/usr/local/lib/python3.5/dist-packages/keras/engine/topology.py", line 2450, in from_config
process_layer(layer_data)
File "/usr/local/lib/python3.5/dist-packages/keras/engine/topology.py", line 2437, in process_layer
raise ValueError('Missing layer: ' + inbound_layer_name)
ValueError: Missing layer: input_2

How to solve this problem?
How the program can stop and continue next time?

error while running model Market1501

When tried to run model-for-market1501.py after the h5 file was made, this error showed up. Keras and other libs are installed

Using TensorFlow backend.
default dim order is: tf
please input your system user name:fahad
now begin to compile the model with the difference between ones and neighbour matrixs.
model_for_market1501.py:93: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(20, (5, 5), kernel_regularizer=<keras.reg..., data_format="channels_last")
share = Convolution2D(20,5,5,dim_ordering='tf', W_regularizer=l2(l=weight_decay))
model_for_market1501.py:98: UserWarning: Update your MaxPooling2D call to the Keras 2 API: MaxPooling2D(data_format="channels_last")
a4 = MaxPooling2D(dim_ordering='tf')(a3)
model_for_market1501.py:99: UserWarning: Update your MaxPooling2D call to the Keras 2 API: MaxPooling2D(data_format="channels_last")
b4 = MaxPooling2D(dim_ordering='tf')(b3)
model_for_market1501.py:100: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(25, (5, 5), kernel_regularizer=<keras.reg..., data_format="channels_last")
share2 = Convolution2D(25,5,5,dim_ordering='tf', W_regularizer=l2(l=weight_decay))
model_for_market1501.py:105: UserWarning: Update your MaxPooling2D call to the Keras 2 API: MaxPooling2D(data_format="channels_last")
a7 = MaxPooling2D(dim_ordering='tf')(a6)
model_for_market1501.py:106: UserWarning: Update your MaxPooling2D call to the Keras 2 API: MaxPooling2D(data_format="channels_last")
b7 = MaxPooling2D(dim_ordering='tf')(b6)
model_for_market1501.py:107: UserWarning: The merge function is deprecated and will be removed after 08/2017. Use instead layers from keras.layers.merge, e.g. add, concatenate, etc.
a8 = merge([a7,b7],mode=cross_input_asym,output_shape=cross_input_shape)
/usr/local/lib/python2.7/dist-packages/keras/legacy/layers.py:458: UserWarning: The Merge layer is deprecated and will be removed after 08/2017. Use instead layers from keras.layers.merge, e.g. add, concatenate, etc.
name=name)
Traceback (most recent call last):
File "model_for_market1501.py", line 391, in
model = model_def()
File "model_for_market1501.py", line 107, in model_def
a8 = merge([a7,b7],mode=cross_input_asym,output_shape=cross_input_shape)
File "/usr/local/lib/python2.7/dist-packages/keras/legacy/layers.py", line 458, in merge
name=name)
File "/usr/local/lib/python2.7/dist-packages/keras/legacy/layers.py", line 120, in init
self(input_tensors, mask=input_masks)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 596, in call
output = self.call(inputs, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/keras/legacy/layers.py", line 201, in call
return self.mode(inputs, **arguments)
File "model_for_market1501.py", line 69, in cross_input_asym
tensor_left_padding = K.spatial_2d_padding(tensor_left,padding=(2,2))
File "/usr/local/lib/python2.7/dist-packages/keras/backend/tensorflow_backend.py", line 1999, in spatial_2d_padding
assert len(padding[0]) == 2
TypeError: object of type 'int' has no len()

about the size of the conv kernel

Hi, I found in the paper that the kernel size is 3 dims, but in your implementation it is 2 dims, is there any difference or influence about that?

Choosing images while calculating CMC curves

Currently, in get_data_for_cmc function in make_hdf5_for_market1501, Line-80,
c1,c2 = np.random.choice(c_list,2), the cameras are selected with replacement. c1 and c2 can be same and will wrongly result in higher accuracies. Shouldn't it be c1,c2 = np.random.choice(c_list,2, replace=False) ?

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.