edwardzhou130/PolarSeg

ValueError: Input must be 1- or 2-d.

Closed this issue · 4 comments

Hi!
I just do it 'python test_pretrain_SemanticKITTI.py' with KITTI Dataset, but the training is wrong!
I put two files 01 、04 under the data file.
What should i do?
thanks!

(pytorch) ziudarkin@ziudarkin-ubuntu:~/PolarSeg$ python test_pretrain_SemanticKITTI.py 
test_pretrain_SemanticKITTI.py
Namespace(data_dir='data', grid_size=[480, 360, 32], model='polar', model_save_path='pretrained_weight/SemKITTI_PolarSeg.pt', test_batch_size=1, test_output_path='out/SemKITTI_test')
********************************************************************************
Test network performance on validation split
********************************************************************************
0it [00:00, ?it/s]Traceback (most recent call last):
  File "test_pretrain_SemanticKITTI.py", line 185, in <module>
    main(args)
  File "test_pretrain_SemanticKITTI.py", line 122, in main
    iou = per_class_iu(sum(hist_list))
  File "test_pretrain_SemanticKITTI.py", line 26, in per_class_iu
    return np.diag(hist) / (hist.sum(1) + hist.sum(0) - np.diag(hist))
  File "<__array_function__ internals>", line 6, in diag
  File "/home/ziudarkin/anaconda3/envs/pytorch/lib/python3.7/site-packages/numpy/lib/twodim_base.py", line 303, in diag
    raise ValueError("Input must be 1- or 2-d.")
ValueError: Input must be 1- or 2-d.
0it [00:00, ?it/s]

@edwardzhou130 can you help me .

Looks like it's because the valid split data is missing:

train:
- 0
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 9
- 10
valid:
- 8
test:
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21

You can move one file like 04 to the valid split or just simply skip the whole validation part.

Looks like it's because the valid split data is missing:

train:
- 0
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 9
- 10
valid:
- 8
test:
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21

You can move one file like 04 to the valid split or just simply skip the whole validation part.

hi, @edwardzhou130 ,Thank you for your answer. I solved the previous problem in a muddle, but I encountered a new problem, as follows

(pytorch) ZiuDarkin@dl-station303:~/PolarSeg$ python train_SemanticKITTI.py
train_SemanticKITTI.py
Namespace(check_iter=4000, data_dir='data', grid_size=[480, 360, 32], model='polar', model_save_path='./SemKITTI_PolarSeg.pt', train_batch_size=2, val_batch_size=2)
  0%|                                      | 0/136 [00:00<?, ?it/s]Traceback (most recent call last):
  File "train_SemanticKITTI.py", line 197, in <module>
    main(args)
  File "train_SemanticKITTI.py", line 129, in main
    iou = per_class_iu(sum(hist_list))
  File "train_SemanticKITTI.py", line 27, in per_class_iu
    return np.diag(hist) / (hist.sum(1) + hist.sum(0) - np.diag(hist))
AttributeError: 'int' object has no attribute 'sum'
  0%|                                      | 0/136 [00:01<?, ?it/s]

Does this error mean that there is a problem with the calculation method of hist matrix?
best wish

I think I know why, but thank you very much
best wish