wangguanan / HOReID

[CVPR2020] High-Order Information Matters: Learning Relation and Topology for Occluded Person Re-Identification

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ValueError: expected 2D or 3D input (got 1D input)

Yx1322441675 opened this issue · comments

when i train or test the dataset occluded-duke and dukemtmc,it takes error . The details are shown as follows:

(horeid) goo@goo-Z390-GAMING-X:~/yx/HOReID/HOReID-master$ python main.py --mode test --resume_test_path /home/goo/yx/HOReID/pre-trained-models --resume_test_epoch 119 --duke_path /home/goo/yx/datayx/Occluded_Duke --output_path ./results
[[0. 1. 1. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 1.]
[1. 0. 1. 1. 0. 0. 0. 1. 1. 0. 0. 0. 0. 1.]
[1. 1. 0. 0. 1. 0. 0. 1. 1. 0. 0. 0. 0. 1.]
[0. 1. 0. 0. 0. 1. 0. 0. 0. 0. 0. 0. 0. 1.]
[0. 0. 1. 0. 0. 0. 1. 0. 0. 0. 0. 0. 0. 1.]
[0. 0. 0. 1. 0. 0. 0. 0. 0. 0. 0. 0. 0. 1.]
[0. 0. 0. 0. 1. 0. 0. 0. 0. 0. 0. 0. 0. 1.]
[0. 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 1.]
[0. 1. 1. 0. 0. 0. 0. 1. 0. 0. 1. 0. 0. 1.]
[0. 0. 0. 0. 0. 0. 0. 1. 0. 0. 0. 1. 0. 1.]
[0. 0. 0. 0. 0. 0. 0. 0. 1. 0. 0. 0. 1. 1.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 1. 0. 0. 0. 1.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 1. 0. 0. 1.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 1.]]
Existed dirs: ./results
Existed dirs: ./results/models/
Existed dirs: ./results/logs/
Existed dirs: ./results/visualization/market/
Existed dirs: ./results/visualization/duke/

Namespace(auto_resume_training_from_lastest_steps=True, base_learning_rate=0.00035, branch_num=14, cuda='cuda', duke_path='/home/goo/yx/datayx/Occluded_Duke', gcn_lr_scale=0.1, gcn_scale=20.0, gm_lr_scale=1.0, image_size=[256, 128], k=4, margin=0.3, max_save_model_num=1, milestones=[40, 70], mode='test', norm_scale=10.0, output_path='./results', p=16, pid_num=702, resume_test_epoch=119, resume_test_path='/home/goo/yx/HOReID/pre-trained-models', resume_visualize_epoch=0, resume_visualize_path='', total_train_epochs=120, train_dataset='duke', use_gm_after=20, ver_alpha=0.5, ver_in_scale=10.0, ver_lr_scale=1.0, ver_topk=1, weight_decay=0.0005, weight_global_feature=1.0, weight_p_loss=1.0, weight_ver_loss=0.1)
Traceback (most recent call last):
File "main.py", line 162, in
main(config)
File "main.py", line 80, in main
duke_map, duke_rank = testwithVer2(config, logger, base, loaders, 'duke', use_gcn=False, use_gm=False)
File "/home/goo/yx/HOReID/HOReID-master/core/test.py", line 26, in testwithVer2
info, gcned_info = base.forward(images, pids, training=False)
File "/home/goo/yx/HOReID/HOReID-master/core/base.py", line 262, in forward
bned_feature_vector_list, cls_score_list = self.bnclassifiers(feature_vector_list)
File "/home/goo/anaconda3/envs/horeid/lib/python3.7/site-packages/torch/nn/modules/module.py", line 493, in call
result = self.forward(*input, **kwargs)
File "/home/goo/anaconda3/envs/horeid/lib/python3.7/site-packages/torch/nn/parallel/data_parallel.py", line 152, in forward
outputs = self.parallel_apply(replicas, inputs, kwargs)
File "/home/goo/anaconda3/envs/horeid/lib/python3.7/site-packages/torch/nn/parallel/data_parallel.py", line 162, in parallel_apply
return parallel_apply(replicas, inputs, kwargs, self.device_ids[:len(replicas)])
File "/home/goo/anaconda3/envs/horeid/lib/python3.7/site-packages/torch/nn/parallel/parallel_apply.py", line 83, in parallel_apply
raise output
File "/home/goo/anaconda3/envs/horeid/lib/python3.7/site-packages/torch/nn/parallel/parallel_apply.py", line 59, in _worker
output = module(*input, **kwargs)
File "/home/goo/yx/HOReID/HOReID-master/core/models/model_reid.py", line 94, in call
bned_feature_vector_i, cls_score_i = classifier_i(feature_vector_i)
File "/home/goo/anaconda3/envs/horeid/lib/python3.7/site-packages/torch/nn/modules/module.py", line 493, in call
result = self.forward(*input, **kwargs)
File "/home/goo/yx/HOReID/HOReID-master/core/models/model_reid.py", line 68, in forward
feature = self.bn(x)
File "/home/goo/anaconda3/envs/horeid/lib/python3.7/site-packages/torch/nn/modules/module.py", line 493, in call
result = self.forward(*input, **kwargs)
File "/home/goo/anaconda3/envs/horeid/lib/python3.7/site-packages/torch/nn/modules/batchnorm.py", line 61, in forward
self._check_input_dim(input)
File "/home/goo/anaconda3/envs/horeid/lib/python3.7/site-packages/torch/nn/modules/batchnorm.py", line 176, in _check_input_dim
.format(input.dim()))
ValueError: expected 2D or 3D input (got 1D input)

Looking forward to your reply.

I have the same question as you. I find that if you print the 'feature_vector_list[13]' in base.py, maybe you will also find the last torch lose a dim. I have this error because I set the batchcsize=1 to test the one query inference time. you can try to use unsqueeze(0) to solve the error.