yzcjtr / GeoNet

Code for GeoNet: Unsupervised Learning of Dense Depth, Optical Flow and Camera Pose (CVPR 2018)
MIT License
723 stars 181 forks source link

Error while camera pose testing #59

Closed ravikt closed 4 years ago

ravikt commented 4 years ago

I am using python geonet_main.py --mode=test_pose --dataset_dir=/path/to/kitti/odom/dataset/ --init_ckpt_file=/path/to/trained/model/ --batch_size=1 --seq_length=5 --pose_test_seq=9 --output_dir=/path/to/save/predictions/

with seq_length = 3 , I am getting the following

InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [1,1,256,12] rhs shape= [1,1,256,24] [[Node: save/Assign_29 = Assign[T=DT_FLOAT, _class=["loc:@pose_net/Conv_7/weights"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/gpu:0"](pose_net/Conv_7/weights, save/RestoreV2_29/_3)]] [[Node: save/RestoreV2_7/_50 = _Send[T=DT_FLOAT, client_terminated=false, recv_device="/job:localhost/replica:0/task:0/gpu:0", send_device="/job:localhost/replica:0/task:0/cpu:0", send_device_incarnation=1, tensor_name="edge_143_save/RestoreV2_7", _device="/job:localhost/replica:0/task:0/cpu:0"](save/RestoreV2_7)]]

and with seq_length = 5, the following error

File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 48, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "geonet_main.py", line 161, in main test_pose(opt) File "/ravikt/geonet/GeoNet/geonet_test_pose.py", line 60, in test_pose inputs[b] = image_seq ValueError: could not broadcast input array from shape (128,416,5) into shape (128,416,15)

Can you please help me address this error ?

yzcjtr commented 4 years ago

Hi, can you confirm if your python and tensorflow versions are consistent with ours?

ravikt commented 4 years ago

Python version is 2.7.12 and tensorflow is 1.1.0

yzcjtr commented 4 years ago

Can you post your test command here? Please make sure the seq_length is consistent between data preparation and test stage. Also, try to run the code within a single GPU.

ravikt commented 4 years ago

The full command is as follows python geonet_main.py --mode=test_pose --dataset_dir=/ravikt/geonet_data/processed/ --init_ckpt_file=/ravikt/geonet/geonet_posenet/model --batch_size=1 --seq_length=5 --pose_test_seq=8 --output_dir=/ravikt/geonet_data/predictions/ The code ran error free on the processed data on a single gpu with --seq_length=5. However, I did not get any output predictions. The image loading part in geonet_test_pose.py assumes the directory structure to be of the form sequences/08/image_2, but the after running prepare_train_data.py we do not obtain the data in that format. I am doubtful if the code is able to read the images at all. Do I need to to put all the images in separate image_2 folder ?

The processed data is in jpg, After I changed .png in https://github.com/yzcjtr/GeoNet/blob/5b176025bc63563ef53297aa3d20cc6e575fb833/geonet_test_pose.py#L31 to .jpg. I go the following inputs[b] = image_seq ValueError: could not broadcast input array from shape (128,416,5) into shape (128,416,15)

yzcjtr commented 4 years ago

I guess the data preprocessing is incorrect. Can you post your data preprocessing command here as well? Also, check your formatted data storage. If these files are generated properly, I'm pretty sure you will get reasonable results.

ravikt commented 4 years ago

python prepare_train_data.py --dataset_dir=/home/ravikt/geonet_data/original/ --dataset_name=kitti_odom --dump_root=/home/ravikt/geonet_data/processed/ --seq_length=5 --img_height=128 --img_width=416 --num_threads=16 --remove_static

the processed data has the following directory structure

├── sequences
│   ├── 00
│   ├── 01
│   ├── 02
│   ├── 03
│   ├── 04
│   ├── 05
│   ├── 06
│   ├── 07
│   └── 08
├── train.txt
└── val.txt

The directory structure inside 08 is as follows. times.txt is from the original KITTI odom dataset

.
├── image_0
│   ├── 000002_cam.txt
│   ├── 000002.jpg
│   ├── 000003_cam.txt
│   ├── 000003.jpg
 .    .
 .    .
│   ├── 004068_cam.txt
│   ├── 004068.jpg
└── times.txt
yzcjtr commented 4 years ago

You should pass the original KITTI odometry dataset to the --data_dir argument instead of the processed dataset. This was clarified in the readme file.

ravikt commented 4 years ago

I did pass the originals. The first post in this issue has output error messages for both seq_length of 3 and 5. Those errors are encountered at https://github.com/yzcjtr/GeoNet/blob/5b176025bc63563ef53297aa3d20cc6e575fb833/geonet_test_pose.py#L60

However, your readme clearly states "For replicating our results in all of the three tasks (monocular depth, camera pose and optical flow), you need to download the following datasets, and preprocess them into certain formats"

Are you suggesting that preprocessed data is only for training phase and the original data for testing ?

yzcjtr commented 4 years ago

Yes, please read the test part of our readme file more carefully. Your last posted command suggests the usage of the formatted dataset. There also exists inconsistency between different commands you posted. Again, use a single GPU and the original dataset for test.

ravikt commented 4 years ago

Ok, The last posted command is only for data preprocessing, since you asked if the formatted data is generated correctly. I am running the test on original dataset using the following python geonet_main.py --mode=test_pose --dataset_dir=/ravikt/geonet_data/original/ --init_ckpt_file=/ravikt/geonet/geonet_posenet/model --batch_size=1 --seq_length=5 --pose_test_seq=9 --output_dir=/ravikt/geonet_data/predictions/ it gives File "/ravikt/geonet/GeoNet/geonet_test_pose.py", line 60, in test_pose inputs[b] = image_seq ValueError: could not broadcast input array from shape (128,416,5) into shape (128,416,15)

ravikt commented 4 years ago

Hi @yzcjtr . Thank you for the patient answers. I will have look again on the codes and readme.