cleinc / bts

From Big to Small: Multi-Scale Local Planar Guidance for Monocular Depth Estimation
GNU General Public License v3.0
635 stars 179 forks source link

TypeError: only integer scalar arrays can be converted to a scalar index #75

Open 1byxero opened 4 years ago

1byxero commented 4 years ago

I was getting above error when doing Prepare NYU Depth V2 test set step. The error trace was as follows when executing the command python extract_official_train_test_set_from_mat.py nyu_depth_v2_labeled.mat splits.mat ../../dataset/nyu_depth_v2/official_splits/

Traceback (most recent call last):
  File "extract_official_train_test_set_from_mat.py", line 87, in <module>
    scenes = [u''.join(chr(c) for c in h5_file[obj_ref]) for obj_ref in h5_file['sceneTypes'][0]]
  File "extract_official_train_test_set_from_mat.py", line 87, in <listcomp>
    scenes = [u''.join(chr(c) for c in h5_file[obj_ref]) for obj_ref in h5_file['sceneTypes'][0]]
  File "extract_official_train_test_set_from_mat.py", line 87, in <genexpr>
    scenes = [u''.join(chr(c) for c in h5_file[obj_ref]) for obj_ref in h5_file['sceneTypes'][0]]
TypeError: only integer scalar arrays can be converted to a scalar index

After debugging, I realized that following line was the culprit

scenes = [u''.join(chr(c) for c in h5_file[obj_ref]) for obj_ref in h5_file['sceneTypes'][0]]

The issue was variable c was actually an array of single item and hence the above error. To solve it I replaced the line with scenes = [u''.join(chr(c[0]) for c in h5_file[obj_ref]) for obj_ref in h5_file['sceneTypes'][0]]

Things worked out after that, I checked if images generated looked ok, which they did.

I just wanted to confirm if doing this was ok

1byxero commented 4 years ago

Also, I just tried this on node of university cluster and I did not need to make the change I mentioned in the above comment

Samad08 commented 3 years ago

hey thanks for the help. You saved me some time !!!

xuelimin commented 3 years ago

thanks!

LeoRainly commented 2 years ago

thanks a lot

xuelimin commented 2 years ago

邮件已查收,我会尽快回复您!

YuhsiHu commented 2 years ago

Thanks a lot. This issue saved me some time!

xuelimin commented 2 years ago

邮件已查收,我会尽快回复您!

BinZhu-ece commented 2 years ago

I was getting above error when doing Prepare NYU Depth V2 test set step. The error trace was as follows when executing the command python extract_official_train_test_set_from_mat.py nyu_depth_v2_labeled.mat splits.mat ../../dataset/nyu_depth_v2/official_splits/

Traceback (most recent call last):
  File "extract_official_train_test_set_from_mat.py", line 87, in <module>
    scenes = [u''.join(chr(c) for c in h5_file[obj_ref]) for obj_ref in h5_file['sceneTypes'][0]]
  File "extract_official_train_test_set_from_mat.py", line 87, in <listcomp>
    scenes = [u''.join(chr(c) for c in h5_file[obj_ref]) for obj_ref in h5_file['sceneTypes'][0]]
  File "extract_official_train_test_set_from_mat.py", line 87, in <genexpr>
    scenes = [u''.join(chr(c) for c in h5_file[obj_ref]) for obj_ref in h5_file['sceneTypes'][0]]
TypeError: only integer scalar arrays can be converted to a scalar index

After debugging, I realized that following line was the culprit

scenes = [u''.join(chr(c) for c in h5_file[obj_ref]) for obj_ref in h5_file['sceneTypes'][0]]

The issue was variable c was actually an array of single item and hence the above error. To solve it I replaced the line with scenes = [u''.join(chr(c[0]) for c in h5_file[obj_ref]) for obj_ref in h5_file['sceneTypes'][0]]

Things worked out after that, I checked if images generated looked ok, which they did.

I just wanted to confirm if doing this was ok

Nice, brother!

xuelimin commented 2 years ago

邮件已查收,我会尽快回复您!

Lost-little-dinosaur commented 1 month ago

Thank you bro! It works!

xuelimin commented 1 month ago

邮件已查收,我会尽快回复您!