flame.io

Functions

assert_direc_exists(path)

assert_file_exists(path)

assert_path_exists(path)

find_dataset_config(input_direc, this_id[, ...])

Searches through all files with extension 'file_ext' in provided 'input_direc' for a value of 'id'. Assumes files will be in json format, and will be opened using the builtin json I/O. Will use 'key' to search the dict. If key is a list of strings, each successive string will identify the nested sub-dictionary for search. Outcomes: 1. If a match is found, return the entire dict stored by the associated .json. 2. If no match is found, return None if 'fail_ok' is True. Otherwise throw FLAMEIOError. 3. If multiple matches are found, throw FLAMEIOError.

flame_paths_from_ids(root_dir, index_path, ...)

Description: Will look for flame images based on their unique IDs given a root directory and a table matching IDs to filepaths.

get_input_and_GT_paths(input_direc, ...)

get_unshared_path(p1, p2)

flame.io.find_dataset_config(input_direc: str, this_id: str, key: str | List[str] = ['FLAME_Dataset', 'id'], file_ext: str = 'json', fail_ok: bool = False) None | Tuple[str, dict][source]

Searches through all files with extension ‘file_ext’ in provided ‘input_direc’ for a value of ‘id’. Assumes files will be in json format, and will be opened using the builtin json I/O. Will use ‘key’ to search the dict. If key is a list of strings, each successive string will identify the nested sub-dictionary for search. Outcomes:

  1. If a match is found, return the entire dict stored by the associated .json.

  2. If no match is found, return None if ‘fail_ok’ is True. Otherwise throw FLAMEIOError.

  3. If multiple matches are found, throw FLAMEIOError

Returns:
  • None IF no matches found and ‘fail_ok’ is True

  • tuple(output_hit (str), output_dict (dict)) IF a single match is found. String is path to json and dict is associated dictionary.

flame.io.flame_paths_from_ids(root_dir: str, index_path: str, id_list: List[int], pd_sep: str = ',', id_col: str = 'id', path_col: str = 'image', tile_data_ext: str = 'tileData.txt', accept_missing: bool = False) List[str][source]

Description: Will look for flame images based on their unique IDs given a root directory and a table matching IDs to filepaths.

Args:
  • root_dir (str): a path to the root directory when all images will be searched for

  • index_path (str): a path to the table (DataFrame-like) matching unique image ids to relative image paths

  • id_list (list[int]): single image id or list of image ids

  • pd_sep (str): the separation character that Pandas should use to parse ‘index_path’ into a DataFrame. DEFAULT=’,’

  • id_col (str): the name of the column storing image ids. DEFAULT=’id’

  • path_col (str): the name of the column storing relative image paths. DEFAULT=’image’

  • tile_data_ext (str): the extension used to search for every image’s associated tileData JSON. DEFAULT=’tileData.txt’

  • accept_missing (bool): whether to skip missing ids or raise an error when they are encountered. DEFAULT=False