src/wai_data_tools/io.py
def load_frames(frame_dir: pathlib.Path) -> Dict[int, Dict[str, Union[str, np.ndarray]]]:
    """
    Loads frame files from a directory.
    :param frame_dir: Path to directory where frames are stored in a target class folder or background class folder
    :return: Dictionary where key is frame index and value is a dictionary with the target class and frame image
    """

    logging.debug("Loading frames at %s", frame_dir)

    frame_filepaths = frame_dir.rglob("*.jpeg")

    frames_dict = {}

    for frame_filepath in frame_filepaths:

        frame_img = imageio.imread(frame_filepath)

        frame_index = int(frame_filepath.stem.split("___")[-1])

        target = frame_filepath.parent.stem

        logging.debug("Frame %s target class is %s", frame_filepath.name, target)

        frames_dict[frame_index] = {"img": frame_img,
                                    "target": target}
    return frames_dict

    Loads frame files from a directory.
    :param frame_dir: Path to directory where frames are stored in a target class folder or background class folder
    :return: Dictionary where key is frame index and value is a dictionary with the target class and frame image
    
Loads frame files from a directory.
Loads frame files from a directory .
def load_frames(frame_dir: pathlib.Path) -> Dict[int, Dict[str, Union[str, np.ndarray]]]:
    logging.debug("Loading frames at %s", frame_dir)
    frame_filepaths = frame_dir.rglob("*.jpeg")
    frames_dict = {}
    for frame_filepath in frame_filepaths:
        frame_img = imageio.imread(frame_filepath)
        frame_index = int(frame_filepath.stem.split("___")[-1])
        target = frame_filepath.parent.stem
        logging.debug("Frame %s target class is %s", frame_filepath.name, target)
        frames_dict[frame_index] = {"img": frame_img,
                                    "target": target}
    return frames_dict
def load_frames ( frame_dir : pathlib . Path ) -> Dict [ int , Dict [ str , Union [ str , np . ndarray ] ] ] : logging . debug ( "Loading frames at %s" , frame_dir ) frame_filepaths = frame_dir . rglob ( "*.jpeg" ) frames_dict = { } for frame_filepath in frame_filepaths : frame_img = imageio . imread ( frame_filepath ) frame_index = int ( frame_filepath . stem . split ( "___" ) [ - 1 ] ) target = frame_filepath . parent . stem logging . debug ( "Frame %s target class is %s" , frame_filepath . name , target ) frames_dict [ frame_index ] = { "img" : frame_img , "target" : target } return frames_dict
Loads frame files from a directory.
Loads frame files from a directory .
"""
    Loads frame files from a directory.
    :param frame_dir: Path to directory where frames are stored in a target class folder or background class folder
    :return: Dictionary where key is frame index and value is a dictionary with the target class and frame image
    """
Dictionary where key is frame index and value is a dictionary with the target class and frame image
Dictionary where key is frame index and value is a dictionary with the target class and frame image
frame_dir
pathlib.Path
Path to directory where frames are stored in a target class folder or background class folder
Path to directory where frames are stored in a target class folder or background class folder