src/wai_data_tools/io.py
def save_frames(video_name: str,
                dst_root_dir: pathlib.Path,
                frames_dict: Dict[int, Dict[str, Union[bool, np.ndarray]]]):
    """
    Saves frames to new file structure.
    :param video_name: Path to directory containing source frame images
    :param dst_root_dir: Path to root destination directory to save frame images in
    :param frames_dict: Dictionary where key is frame index and value is a dictionary with the label class
                        and frame image
    """
    dst_video_path = dst_root_dir / video_name

    logging.debug("Saving frames to %s", dst_video_path)

    for frame_ind, f_dict in frames_dict.items():
        frame_filename = f"{video_name}___{frame_ind}.jpeg"

        label_dir = dst_video_path / f_dict["target"]
        label_dir.mkdir(exist_ok=True, parents=True)
        total_path = label_dir / frame_filename
        imageio.imwrite(total_path, f_dict["img"])

    Saves frames to new file structure.
    :param video_name: Path to directory containing source frame images
    :param dst_root_dir: Path to root destination directory to save frame images in
    :param frames_dict: Dictionary where key is frame index and value is a dictionary with the label class
                        and frame image
    
Saves frames to new file structure.
Saves frames to new file structure .
def save_frames(video_name: str,
                dst_root_dir: pathlib.Path,
                frames_dict: Dict[int, Dict[str, Union[bool, np.ndarray]]]):
    dst_video_path = dst_root_dir / video_name
    logging.debug("Saving frames to %s", dst_video_path)
    for frame_ind, f_dict in frames_dict.items():
        frame_filename = f"{video_name}___{frame_ind}.jpeg"
        label_dir = dst_video_path / f_dict["target"]
        label_dir.mkdir(exist_ok=True, parents=True)
        total_path = label_dir / frame_filename
        imageio.imwrite(total_path, f_dict["img"])
def save_frames ( video_name : str , dst_root_dir : pathlib . Path , frames_dict : Dict [ int , Dict [ str , Union [ bool , np . ndarray ] ] ] ) : dst_video_path = dst_root_dir / video_name logging . debug ( "Saving frames to %s" , dst_video_path ) for frame_ind , f_dict in frames_dict . items ( ) : frame_filename = f"{video_name}___{frame_ind}.jpeg" label_dir = dst_video_path / f_dict [ "target" ] label_dir . mkdir ( exist_ok = True , parents = True ) total_path = label_dir / frame_filename imageio . imwrite ( total_path , f_dict [ "img" ] )
Saves frames to new file structure.
Saves frames to new file structure .
"""
    Saves frames to new file structure.
    :param video_name: Path to directory containing source frame images
    :param dst_root_dir: Path to root destination directory to save frame images in
    :param frames_dict: Dictionary where key is frame index and value is a dictionary with the label class
                        and frame image
    """
video_name
str
Path to directory containing source frame images
Path to directory containing source frame images
dst_root_dir
pathlib.Path
Path to root destination directory to save frame images in
Path to root destination directory to save frame images in
frames_dict
Dict[int, Dict[str, Union[bool, np.ndarray]]]
Dictionary where key is frame index and value is a dictionary with the label class
and frame image
Dictionary where key is frame index and value is a dictionary with the label class and frame image