cvlab-epfl / disk

Disk code release
Apache License 2.0
317 stars 46 forks source link

Get AttributeError: 'tuple' object has no attribute 'encode' from `match.py` #9

Closed GabbySuwichaya closed 2 years ago

GabbySuwichaya commented 3 years ago

Could you please give some help to solve the following problem?

I have tested the matching with two images.

In /mnt/HDD4TB2/Disk-NIPS2020/H5_destination ...there are three files generated by detect.py:

- matches.h5
- keypoints.h5
- descriptors.h5

I have executed the following command:

python3 match.py /mnt/HDD4TB2/Disk-NIPS2020/H5_destination

However, I have received the following problem:

Processing /mnt/HDD4TB2/Disk-NIPS2020/H5_destination with DEV=cuda
0it [00:00, ?it/s]Traceback (most recent call last):
  File "match.py", line 194, in <module>
    brute_match(described_samples, hdf)
  File "match.py", line 149, in brute_match
    desc_1 = descriptors[key_1].to(DEV)
  File "match.py", line 68, in __getitem__
    descriptors = self.ds_file[ix][()]
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "/home/xxxxxx/anaconda3/envs/SGAT/lib/python3.6/site-packages/h5py/_hl/group.py", line 287, in __getitem__
    oid = h5o.open(self.id, self._e(name), lapl=self._lapl)
  File "/home/xxxxxx/anaconda3/envs/SGAT/lib/python3.6/site-packages/h5py/_hl/base.py", line 200, in _e
    name = name.encode('ascii')
AttributeError: 'tuple' object has no attribute 'encode'
0it [00:00, ?it/s]
jatentaki commented 3 years ago

Hello, sorry for the late reply. Have you managed to solve your problem by now? If not, could you inspect what the offending name is (the ix variable in line 68)?

GabbySuwichaya commented 3 years ago

@jatentaki I am back ... I debuged with pdb.set_trace().... It shows that ix is "/mnt" .. ?
I guess that "/mnt"is a part of my path to the saved descriptor : /mnt/HDD4TB2/Disk-NIPS2020/H5_destination

Could you please help? What does this actually mean? And how to solve it ...?

Line 69    def __getitem__(self, ix):
Line 70    pdb.set_trace()
Line 71    descriptors = self.ds_file[ix][()]
jatentaki commented 3 years ago

But is it really ix == mnt that causes the exception or is it sometime later in the execution? Can you modify the code like this?

def __getitem__(self, ix):
    try:
        descriptors = self.ds_file[ix][()]
    except AttributeError:
        print(f'Offending attribute {ix=}')
        raise
    ...

but you're right that this mnt looks suspicious. In that case, I'd expect something wrong is going in detect.py. There are two relevant lines: splitting off the extension names would propagate the /mnt absolute prefix, but that prefix shouldn't be there in the first place because of listdir which normally returns file/directory names and not their paths.