isl-org / Open3D-ML

An extension of Open3D to address 3D Machine Learning tasks
Other
1.88k stars 321 forks source link

Error when running inference with KPConv - "local variable 'pred' referenced before assignment" #305

Closed guragamb closed 3 years ago

guragamb commented 3 years ago

Hi there, I was trying to evaluate KPConv on SemanticKITTI and keep on getting the following error regarding variable 'pred' (line 189 of ml3d/datasets/semantickitti.py). Here's the output when I tried to run the script:

root@8b4162d2d1d7:~/semKITTI/Open3D-ML# python3 test_semkitti.py
INFO - 2021-06-20 16:49:24,591 - semantic_segmentation - Loading checkpoint ./logs/kpconv_semantickitti_202009090354utc.pth
INFO - 2021-06-20 16:49:26,693 - semantic_segmentation - DEVICE : cuda
INFO - 2021-06-20 16:49:26,693 - semantic_segmentation - Logging in file : ./logs/KPFCNN_SemanticKITTI_torch/log_test_2021-06-20_16:49:26.txt
INFO - 2021-06-20 16:49:26,700 - semantickitti - Found 99 pointclouds for test
INFO - 2021-06-20 16:49:26,967 - semantic_segmentation - Initializing from scratch.
INFO - 2021-06-20 16:49:26,967 - semantic_segmentation - Started testing
test 0/99: 100%|###################################################################################################################################################| 32949/32949 [00:08<00:00, 1660.77it/s]Traceback (most recent call last):
  File "test_semkitti.py", line 33, in <module>
    pipeline.run_test()
  File "/usr/local/lib/python3.6/dist-packages/open3d/_ml3d/torch/pipelines/semantic_segmentation.py", line 241, in run_test
    dataset.save_test_result(inference_result, attr)
  File "/usr/local/lib/python3.6/dist-packages/open3d/_ml3d/datasets/semantickitti.py", line 189, in save_test_result
    pred[pred >= ign] += 1
UnboundLocalError: local variable 'pred' referenced before assignment
test 0/99: 100%|###################################################################################################################################################| 32949/32949 [00:08<00:00, 3894.76it/s]
root@8b4162d2d1d7:~/semKITTI/Open3D-ML#

The test script that I'm running was adapted from the "Running a pretrained model for semantic segmentation" section in the README. Thanks!

sanskar107 commented 3 years ago

@guragamb Thanks for reporting this issue. You can replace pred with results inside save_test_result method to make it work. Feel free to open a pull request to fix it.