vis4d.data.io.hdf5

Hdf5 data backend.

This backend works with filepaths pointing to valid HDF5 files. We assume that the given HDF5 file contains the whole dataset associated to this backend.

Classes

HDF5Backend()

Backend for loading data from HDF5 files.

class HDF5Backend[source]

Backend for loading data from HDF5 files.

This backend works with filepaths pointing to valid HDF5 files. We assume that the given HDF5 file contains the whole dataset associated to this backend.

You can use the provided script at vis4d/data/datasets/to_hdf5.py to convert your dataset to the expected hdf5 format before using this backend.

__init__()[source]

Creates an instance of the class.

exists(filepath)[source]

Check if filepath exists.

Parameters:

filepath (str) – Path to file.

Returns:

True if file exists, False otherwise.

Return type:

bool

set(filepath, content, mode='a')[source]

Set the file content.

Parameters:
  • filepath (str) – path/to/file.hdf5/key1/key2/key3

  • content (bytes) – Bytes to be written to entry key3 within group key2 within another group key1, for example.

  • mode (Literal['w', 'a']) – “w” to overwrite the file, “a” to append to it.

Raises:

ValueError – If filepath is not a valid .hdf5 file

Return type:

None

get(filepath)[source]

Get values according to the filepath as bytes.

Parameters:

filepath (str) – The path to the file. It consists of an HDF5 path together with the relative path inside it, e.g.: “/path/to/ file.hdf5/key/subkey/data”. If no .hdf5 given inside filepath, the function will search for the first .hdf5 file present in the path, i.e. “/path/to/file/key/subkey/data” will also /key/ subkey/data from /path/to/file.hdf5.

Raises:
  • FileNotFoundError – If no suitable file exists.

  • ValueError – If key not found inside hdf5 file.

Returns:

The file content in bytes

Return type:

bytes

isfile(filepath)[source]

Check if filepath is a file.

Parameters:

filepath (str) – Path to file.

Raises:
  • FileNotFoundError – If no suitable file exists.

  • ValueError – If key not found inside hdf5 file.

Returns:

True if file exists, False otherwise.

Return type:

bool

listdir(filepath)[source]

List all files in the given directory.

Parameters:

filepath (str) – Path to directory.

Raises:
  • FileNotFoundError – If no suitable file exists.

  • ValueError – If key not found inside hdf5 file.

Returns:

List of files in the given directory.

Return type:

list[str]

close()[source]

Close all opened HDF5 files.

Return type:

None