j96w / 6-PACK

"6-PACK: Category-level 6D Pose Tracker with Anchor-Based Keypoints" code repository
https://sites.google.com/view/6packtracking
MIT License
297 stars 52 forks source link

ValueError: operands could not be broadcast together with shapes (128000,) (117656,) #22

Closed sunshantong closed 4 years ago

sunshantong commented 4 years ago

Hi, thank you for your work. When I run python train.py, the following happens

Traceback (most recent call last):
  File "train.py", line 57, in <module>
    for i, data in enumerate(dataloader, 0):
  File "/home/.local/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 314, in __next__
    batch = self.collate_fn([self.dataset[i] for i in indices])
  File "/home/.local/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 314, in <listcomp>
    batch = self.collate_fn([self.dataset[i] for i in indices])
  File "/home/6-PACK/dataset/dataset_nocs.py", line 438, in __getitem__
    img_fr, choose_fr, cloud_fr, r_fr, t_fr, target_fr, mesh_pts_fr, mesh_bbox_fr, mask_target = self.get_frame(choose_frame[0], choose_obj, syn_or_real)
  File "/home/6-PACK/dataset/dataset_nocs.py", line 331, in get_frame
    back_img = np.transpose(back_img, (2, 0, 1))
  File "/home/.local/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 575, in transpose
    return _wrapfunc(a, 'transpose', axes)
  File "/home/.local/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 52, in _wrapfunc
    return getattr(obj, method)(*args, **kwds)
ValueError: axes don't match array

This seems to be because the COCO dataset contains grayscale images. I fixed it by adding. convert ("RGB"). But another problem arises.

Traceback (most recent call last):
  File "train.py", line 57, in <module>
    for i, data in enumerate(dataloader, 0):
  File "/home/.local/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 314, in __next__
    batch = self.collate_fn([self.dataset[i] for i in indices])
  File "/home/.local/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 314, in <listcomp>
    batch = self.collate_fn([self.dataset[i] for i in indices])
  File "/home/6-PACK/dataset/dataset_nocs.py", line 441, in __getitem__
    img_to, choose_to, cloud_to, r_to, t_to, target_to, _, _, _, = self.get_frame(choose_frame[1], choose_obj, syn_or_real)
  File "/home/6-PACK/dataset/dataset_nocs.py", line 383, in get_frame
    choose = ((depth.flatten() != 0.0) * choose_temp).nonzero()[0]
ValueError: operands could not be broadcast together with shapes (128000,) (117656,) 

This problem has bothered me for a long time. Can you give me some suggestions? Thank you very much.

JiazeWang commented 4 years ago

Hello, I met the same problem when running the code. Could your please tell me how to solve the problem?

Thanks you!

sunshantong commented 4 years ago

@JiazeWang Hi, If it's not debugging, you can keep the "try-except" code in Line 434 and Line 457 of the dataset/dataset_nocs.py..