ethnhe / FFB6D

[CVPR2021 Oral] FFB6D: A Full Flow Bidirectional Fusion Network for 6D Pose Estimation.
MIT License
290 stars 72 forks source link

Fuse.py: "np.AxisError: axis 2 out of bounds for array of dim 2" #67

Closed MiriamJo closed 2 years ago

MiriamJo commented 2 years ago

I adapted linemod dataset to have my own objects. I generated renderes data and am now trying to generate fused data. However, when I try to run the fuse.py with following execution command: python3 fuse.py --cls ape --fuse_num 5 The following error occurs:

0%| | 0/5 [00:00<?, ?it/s] concurrent.futures.process._RemoteTraceback: """ Traceback (most recent call last): File "/usr/lib/python3.8/concurrent/futures/process.py", line 239, in _process_worker r = call_item.fn(*call_item.args, call_item.kwargs) File "fuse.py", line 288, in prepare_dataset_single rgb, mask, depth, begin, pose = randomly_sample_foreground( File "fuse.py", line 226, in randomly_sample_foreground mask = np.sum(mask,2)>0 File "<__array_function__ internals>", line 180, in sum File "/home/miriam/.local/lib/python3.8/site-packages/numpy/core/fromnumeric.py", line 2296, in sum return _wrapreduction(a, np.add, 'sum', axis, dtype, out, keepdims=keepdims, File "/home/miriam/.local/lib/python3.8/site-packages/numpy/core/fromnumeric.py", line 86, in _wrapreduction return ufunc.reduce(obj, axis, dtype, out, passkwargs) numpy.AxisError: axis 2 is out of bounds for array of dimension 2 """

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "fuse.py", line 353, in prepare_dataset_parallel( File "fuse.py", line 335, in prepare_dataset_parallel res = f.result() File "/usr/lib/python3.8/concurrent/futures/_base.py", line 444, in result return self.get_result() File "/usr/lib/python3.8/concurrent/futures/_base.py", line 389, in get_result raise self._exception numpy.AxisError: axis 2 is out of bounds for array of dimension 2

I thought it was just my own objects, but this output is from trying to execute the script with "ape", which is a linemod original. Is there something wrong with tqdm? I really can't figure out what causes the error.

MiriamJo commented 2 years ago

Update:

I printed out the shape of the linemor preprocessed masks. They are all in shape (480,640,3) whereas my generated masks all just have the shape of (480, 640). What am I doing wrong and how can I achieve this shape of the np array for my own data?

I generated the data using bop_toolkit.

MiriamJo commented 2 years ago

I finally figured it out. I needed to make sure my mask images are converted to RGB. So in fuse.py Line 223 i added:

with Image.open(msk_pth).convert('RGB') as li:

Now It has the same shape and works as expected.