zenseact / zod

Software Development Kit for the Zenseact Open Dataset (ZOD)
https://zod.zenseact.com
MIT License
92 stars 13 forks source link

Reading issue of vehicle_data of sequence #22

Closed ShawnZhaoMX closed 10 months ago

ShawnZhaoMX commented 10 months ago

Hi ZOD developers! I've downloaded mini dataset and tried to view vehicle data of sequence, but I got an error when I tried to index vehicle_data from seq = zod_sequences["000002"].

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/tmp/ipykernel_11445/309491222.py in <module>
----> 1 seq.vehicle_data

~/.local/lib/python3.10/site-packages/zod/data_classes/sequence.py in vehicle_data(self)
     55         if self._vehicle_data is None:
     56             assert self.info.vehicle_data_path is not None, "Vehicle data path is missing."
---> 57             self._vehicle_data = VehicleData.from_hdf5(self.info.vehicle_data_path)
     58         return self._vehicle_data
     59 

~/.local/lib/python3.10/site-packages/zod/data_classes/vehicle_data.py in from_hdf5(cls, path)
     20         with h5py.File(path, "r") as h5_file:
     21             return cls(
---> 22                 ego_vehicle_data=_load_group_data(h5_file, "ego_vehicle_data"),
     23                 ego_vehicle_controls=_load_group_data(h5_file, "ego_vehicle_controls"),
     24                 satellite=_load_group_data(h5_file, "satellite"),

~/.local/lib/python3.10/site-packages/zod/data_classes/vehicle_data.py in _load_group_data(h5_file, group_name)
     29     group_data = {}
     30     for key in h5_file[group_name].keys():
---> 31         group_data[key] = h5_file[group_name][key][()]
     32     return group_data

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

~/.local/lib/python3.10/site-packages/h5py/_hl/group.py in __getitem__(self, name)
    357             oid = h5o.open(self.id, self._e(name), lapl=self._lapl)
    358         else:
--> 359             raise TypeError("Accessing a group is done with bytes or str, "
    360                             "not {}".format(type(name)))
    361 

TypeError: Accessing a group is done with bytes or str, not <class 'tuple'>

I found that the datatype of h5_file[group_name][key] is h5py._hl.group.Group rather than h5py._hl.dataset.Dataset, so h5_file[group_name][key][()] could not work. I hope you could notice this issue! Thank you very much!

wljungbergh commented 10 months ago

Hi. We have now fixed the above issue in this commit. Please upgrade to zod>=0.3.4.