hzxie / Pix2Vox

The official implementation of "Pix2Vox: Context-aware 3D Reconstruction from Single and Multi-view Images". (Xie et al., ICCV 2019)

Home Page:https://haozhexie.com/project/pix2vox

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

getting inference Test using Pix2Vox pre-trained models

AmirAliVz opened this issue · comments

Hi,
I am trying to use your code to reconstruct 3D models of real objects using 2D images. I use python runner.py --test --weights=/path/to/pretrained/model/Pix2Vox-A.pth command and I get the following error:

Use config:
{'CONST': {'BATCH_SIZE': 64,
'CROP_IMG_H': 128,
'CROP_IMG_W': 128,
'DEVICE': '0',
'IMG_H': 224,
'IMG_W': 224,
'N_VIEWS_RENDERING': 1,
'N_VOX': 32,
'RNG_SEED': 0,
'WEIGHTS': './weights/Pix2Vox-A-ShapeNet.pth'},
'DATASET': {'MEAN': [0.5, 0.5, 0.5],
'STD': [0.5, 0.5, 0.5],
'TEST_DATASET': 'ShapeNet',
'TRAIN_DATASET': 'ShapeNet'},
'DATASETS': {'PASCAL3D': {'ANNOTATION_PATH': '/home/hzxie/Datasets/PASCAL3D/Annotations/%s_imagenet/%s.mat',
'RENDERING_PATH': '/home/hzxie/Datasets/PASCAL3D/Images/%s_imagenet/%s.JPEG',
'TAXONOMY_FILE_PATH': './datasets/Pascal3D.json',
'VOXEL_PATH': '/home/hzxie/Datasets/PASCAL3D/CAD/%s/%02d.binvox'},
'PIX3D': {'ANNOTATION_PATH': '/home/hzxie/Datasets/Pix3D/pix3d.json',
'RENDERING_PATH': '/home/hzxie/Datasets/Pix3D/img/%s/%s.%s',
'TAXONOMY_FILE_PATH': './datasets/Pix3D.json',
'VOXEL_PATH': '/home/hzxie/Datasets/Pix3D/model/%s/%s/%s.binvox'},
'SHAPENET': {'RENDERING_PATH': '/home/hzxie/Datasets/ShapeNet/ShapeNetRendering/%s/%s/rendering/%02d.png',
'TAXONOMY_FILE_PATH': './datasets/ShapeNet.json',
'VOXEL_PATH': '/home/hzxie/Datasets/ShapeNet/ShapeNetVox32/%s/%s/model.binvox'}},
'DIR': {'OUT_PATH': './output',
'RANDOM_BG_PATH': '/home/hzxie/Datasets/SUN2012/JPEGImages'},
'NETWORK': {'LEAKY_VALUE': 0.2,
'TCONV_USE_BIAS': False,
'USE_MERGER': True,
'USE_REFINER': True},
'TEST': {'RANDOM_BG_COLOR_RANGE': [[240, 240], [240, 240], [240, 240]],
'VOXEL_THRESH': [0.2, 0.3, 0.4, 0.5]},
'TRAIN': {'BETAS': [0.9, 0.999],
'BRIGHTNESS': 0.4,
'CONTRAST': 0.4,
'DECODER_LEARNING_RATE': 0.001,
'DECODER_LR_MILESTONES': [150],
'ENCODER_LEARNING_RATE': 0.001,
'ENCODER_LR_MILESTONES': [150],
'EPOCH_START_USE_MERGER': 0,
'EPOCH_START_USE_REFINER': 0,
'GAMMA': 0.5,
'MERGER_LEARNING_RATE': 0.0001,
'MERGER_LR_MILESTONES': [150],
'MOMENTUM': 0.9,
'NOISE_STD': 0.1,
'NUM_EPOCHES': 250,
'NUM_WORKER': 4,
'POLICY': 'adam',
'RANDOM_BG_COLOR_RANGE': [[225, 255], [225, 255], [225, 255]],
'REFINER_LEARNING_RATE': 0.001,
'REFINER_LR_MILESTONES': [150],
'RESUME_TRAIN': False,
'SATURATION': 0.4,
'SAVE_FREQ': 10,
'UPDATE_N_VIEWS_RENDERING': False}}
[INFO] 2022-06-26 15:55:48.623421 Collecting files of Taxonomy[ID=02691156, Name=aeroplane]
[WARN] 2022-06-26 15:55:48.624419 Ignore sample 02691156/6c432109eee42aed3b053f623496d8f5 since volume file not exists.
[WARN] 2022-06-26 15:55:48.625415 Ignore sample 02691156/a9b95631bcbefe9ad225a1c252daae25 since volume file not exists.
[WARN] 2022-06-26 15:55:48.627409 Ignore sample 02691156/5d8583703889178a8bc354dd4eb23614 since volume file not exists.
[WARN] 2022-06-26 15:55:52.753700 Ignore sample 04530566/283dc6c755398547657a96a9bceb8713 since volume file not exists.
[WARN] 2022-06-26 15:55:52.753700 Ignore sample 04530566/aba35304010a7ca093f1a6337ed3a54c since volume file not exists.
[WARN] 2022-06-26 15:55:52.754696 Ignore sample 04530566/21256efa0a78f86b4448fadc60fab7a7 since volume file not exists.
[WARN] 2022-06-26 15:55:52.754696 Ignore sample 04530566/819a7b31f925a302474a33db0a80b327 since volume file not exists.
[WARN] 2022-06-26 15:55:52.754696 Ignore sample 04530566/1d8adfa96dca83849143982c80da1e75 since volume file not exists.
[WARN] 2022-06-26 15:55:52.755693 Ignore sample 04530566/d0652ef190720c84f4e9dade6d46323d since volume file not exists.
[WARN] 2022-06-26 15:55:52.755693 Ignore sample 04530566/8fb16643e061a3bd82b5804533e545b1 since volume file not exists.
[WARN] 2022-06-26 15:55:52.755693 Ignore sample 04530566/5af5aa92ba49930c3f41ddf3713a131 since volume file not exists.
[WARN] 2022-06-26 15:55:52.756688 Ignore sample 04530566/62255074b0df6a115fa2a5df3ce5bc40 since volume file not exists.
[WARN] 2022-06-26 15:55:52.756688 Ignore sample 04530566/4b7642b98790bd4a58a8952c93ff9829 since volume file not exists.
[WARN] 2022-06-26 15:55:52.757687 Ignore sample 04530566/2de6a45649b392d2f7051f81d65f99eb since volume file not exists.
[WARN] 2022-06-26 15:55:52.757687 Ignore sample 04530566/fad2e708e354b0315e585de41f56d4fd since volume file not exists.
[WARN] 2022-06-26 15:55:52.757687 Ignore sample 04530566/a7444ff7be7aad024c8ad92cfce1307c since volume file not exists.
[WARN] 2022-06-26 15:55:52.758681 Ignore sample 04530566/94a0345790869eace074faa875b76f82 since volume file not exists.
[WARN] 2022-06-26 15:55:52.758681 Ignore sample 04530566/705df680888e17ed8841beb2e0280e42 since volume file not exists.
[WARN] 2022-06-26 15:55:52.758681 Ignore sample 04530566/b4f254a5c49748a2db2b485c26c9f191 since volume file not exists.
[INFO] 2022-06-26 15:55:52.759680 Complete collecting files of the dataset. Total files: 0.
[INFO] 2022-06-26 15:55:55.921073 Loading weights from ./weights/Pix2Vox-A-ShapeNet.pth ...
[INFO/Process-1] child process calling self.run()
[INFO/Process-1] process shutting down
[INFO/Process-1] process exiting with exitcode 0
E:\Develop\Pix2Vox\core\test.py:168: RuntimeWarning: invalid value encountered in double_scalars
mean_iou = np.sum(mean_iou, axis=0) / n_samples
============================ TEST RESULTS ============================
Taxonomy #Sample Baseline t=0.20 t=0.30 t=0.40 t=0.50
Overall Traceback (most recent call last):
File "runner.py", line 93, in
main()
File "runner.py", line 77, in main
test_net(cfg)
File "E:\Develop\Pix2Vox\core\test.py", line 194, in test_net
for mi in mean_iou:
TypeError: 'numpy.float64' object is not iterable
[INFO/MainProcess] process shutting down

It seems like the code is unable to find some files and in the end number of samples is 0.
I need to know how can I pass my test images into the model and receive the 3D model as a .obj file.

You also mentioned that I should update the config.py file and update the file path of the dataset. so do I need to download the whole dataset even for testing the pre-trained model? and if yes which dataset should I download?

Please double-check the dataset's path and follow the instructions in the README.

The proposed method generates voxels and doesn't save the prediction results to files.
You can use marching cubes to convert voxels to meshes and save them as .obj files.