traveller59 / second.pytorch

SECOND for KITTI/NuScenes object detection
MIT License
1.72k stars 723 forks source link

TypeError: object of type <class 'numpy.float64'> cannot be safely interpreted as an integer. #355

Open Shaoqing26 opened 4 years ago

Shaoqing26 commented 4 years ago

when i run ### python3 ./pytorch/train.py evaluate --config_path=./configs/car.lite.config --model_dir=/media/buaa/MyPassport/Deeplidar/second.pytorch/second/configs/car_lite --measure_time=True --batch_size=1

I got a problem as follow,

/home/buaa/.local/lib/python3.6/site-packages/numba/cuda/envvars.py:16: NumbaDeprecationWarning: Environment variables with the 'NUMBAPRO' prefix are deprecated, found use of NUMBAPRO_NVVM=/usr/local/cuda/nvvm/lib64/libnvvm.so.

For more information visit http://numba.pydata.org/numba-doc/latest/reference/deprecation.html#deprecation-of-numbapro-environment-variables warnings.warn(errors.NumbaDeprecationWarning(msg)) /home/buaa/.local/lib/python3.6/site-packages/numba/cuda/envvars.py:16: NumbaDeprecationWarning: Environment variables with the 'NUMBAPRO' prefix are deprecated, found use of NUMBAPRO_LIBDEVICE=/usr/local/cuda/nvvm/libdevice.

For more information visit http://numba.pydata.org/numba-doc/latest/reference/deprecation.html#deprecation-of-numbapro-environment-variables warnings.warn(errors.NumbaDeprecationWarning(msg)) /home/buaa/.local/lib/python3.6/site-packages/numba/cuda/envvars.py:16: NumbaDeprecationWarning: Environment variables with the 'NUMBAPRO' prefix are deprecated, found use of NUMBAPRO_CUDA_DRIVER=/usr/lib/aarch64-linux-gnu/libcuda.so.

For more information visit http://numba.pydata.org/numba-doc/latest/reference/deprecation.html#deprecation-of-numbapro-environment-variables warnings.warn(errors.NumbaDeprecationWarning(msg)) [ 41 1280 1056] Restoring parameters from /media/buaa/MyPassport/Deeplidar/second.pytorch/second/configs/car_lite/voxelnet-15500.tckpt feature_map_size [1, 160, 132] remain number of infos: 3769 Generate output labels... [100.0%][===================>][8.35it/s][07:36>00:00]
generate label finished(8.19/s). start eval: avg example to torch time: 3.211 ms avg prep time: 5.921 ms avg voxel_feature_extractor time = 1.500 ms avg middle forward time = 49.402 ms avg rpn forward time = 42.073 ms avg predict time = 18.303 ms /home/buaa/.local/lib/python3.6/site-packages/numba/compiler.py:588: NumbaPerformanceWarning: The keyword argument 'parallel=True' was specified but no transformation for parallel execution was possible.

To find out why, try turning on parallel diagnostics, see http://numba.pydata.org/numba-doc/latest/user/parallel.html#diagnostics for help.

File "utils/eval.py", line 129: @numba.jit(nopython=True, parallel=True) def box3d_overlap_kernel(boxes, ^

self.func_ir.loc)) Traceback (most recent call last): File "/home/buaa/.local/lib/python3.6/site-packages/numpy/core/function_base.py", line 117, in linspace num = operator.index(num) TypeError: 'numpy.float64' object cannot be interpreted as an integer

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "./pytorch/train.py", line 665, in fire.Fire() File "/home/buaa/.local/lib/python3.6/site-packages/fire/core.py", line 138, in Fire component_trace = _Fire(component, args, parsed_flag_args, context, name) File "/home/buaa/.local/lib/python3.6/site-packages/fire/core.py", line 471, in _Fire target=component.name) File "/home/buaa/.local/lib/python3.6/site-packages/fire/core.py", line 675, in _CallAndUpdateTrace component = fn(*varargs, *kwargs) File "./pytorch/train.py", line 543, in evaluate str(result_path_step)) File "/media/buaa/MyPassport/Deeplidar/second.pytorch/second/data/kitti_dataset.py", line 149, in evaluation z_center=z_center) File "/media/buaa/MyPassport/Deeplidar/second.pytorch/second/utils/eval.py", line 884, in get_coco_eval_result z_center=z_center) File "/media/buaa/MyPassport/Deeplidar/second.pytorch/second/utils/eval.py", line 704, in do_coco_style_eval min_overlaps[:, i, j] = np.linspace(overlap_ranges[:, i, j]) File "<__array_function__ internals>", line 6, in linspace File "/home/buaa/.local/lib/python3.6/site-packages/numpy/core/function_base.py", line 121, in linspace .format(type(num))) TypeError: object of type <class 'numpy.float64'> cannot be safely interpreted as an integer.

what can i do to solved it?

system info:

Xavier ubuntu18.04 pytorch 1.3.0 cmake 3.13.2 pillow 6.2.2 numba 0.44.1 numpy 1.18.2 llvmlite 0.29.0

andraspalffy commented 4 years ago

Hi,

numpy 1.18 will have this problem, earlier versions work, see e.g. https://github.com/xingyizhou/CenterNet/issues/547

To solve it, you can either downgrade your numpy, or modify utils/eval.py, line 704:

for i in range(overlap_ranges.shape[1]):  
        for j in range(overlap_ranges.shape[2]):
            a, b, c = overlap_ranges[:, i, j] #extracting the three numbers
            min_overlaps[:, i, j] = np.linspace(a, b, int(c)) #casting to integer
            #min_overlaps[:, i, j] = np.linspace(*overlap_ranges[:, i, j])

I left the original line in there for reference. The trick is that the third param of linspace has to be an int.

ryontang commented 4 years ago

i also meet the same problem, thanks!

scrouzet commented 4 years ago

I had the same issue and the change in eval.py suggested by @paland3 solved it. Thanks