beexplainable.utils package

Submodules

beexplainable.utils.annot_computers module

beexplainable.utils.metafile_readers module

Library for opening metafiles and converting them into dictionaries

beexplainable.utils.metafile_readers.bboxes_to_dict(metafile_path: str, values_as_strings: bool = True) Dict[str, List[str]][source]

Opens file containing BBox coordinates (in CUB format) and returns is as a dictionary.

Parameters
  • metafile_path (str) – Path to the file to be read.

  • values_as_strings (bool, optional) – Whether to return bbox coordinates as strings. If False, floats are returned. Defaults to True

Returns

Dictionary of type ‘file_id to BBox coords.’

Return type

Dict[str, List[str]]

beexplainable.utils.metafile_readers.metafile_to_dict(metafile_path: str) Dict[str, str][source]

Opens file from metafile_path and returns it as a dictionary os strings. Note that this function works as intended only for files containing simple key to value mappings, such as classes.txt. For more complex mappings, such as in part_locs.txt, special functions were defined below.

Parameters

metafile_path (str) – Path to the file to be read.

Returns

Dictionary of type ‘id-to-id’ or ‘id-to-name’.

Return type

Dict[str, str]

beexplainable.utils.metafile_readers.part_locs_to_dict(metafile_path: str) Dict[str, Dict[str, List[str]]][source]

Opens file containing part locations and returns it as a dictionary. The key is the file id and it is mapped to a second dictionary containing the mappings from the part id to the RLEs.

Parameters

metafile_path (str) – Path to the file to be read.

Returns

Dictionary of type ‘file_id to RLEs (for each part)’.

Return type

Dict[str, Dict[str, List[str]]]

beexplainable.utils.metafile_readers.w_h_to_dict(metafile_path: str) Dict[str, Tuple[int]][source]

Opens file containing widths and heights of original images and returns them as tuples in a dictionary.

Parameters

metafile_path

Returns

Return type

Module contents