Source code for vis4d.vis.base

"""Visualizer base class."""

from vis4d.common.typing import ArgsType


[docs] class Visualizer: """Base visualizer class.""" def __init__(self, vis_freq: int = 50, image_mode: str = "RGB") -> None: """Initialize the visualizer. Args: vis_freq (int): Visualization frequency. Defaults to 0. image_mode (str): Image channel mode (RGB or BGR). """ self.vis_freq = vis_freq self.image_mode = image_mode assert image_mode in {"RGB", "BGR"} def _run_on_batch(self, cur_iter: int) -> bool: """Return whether to run on current iteration. Args: cur_iter (int): Current iteration. """ return cur_iter % self.vis_freq == 0
[docs] def reset(self) -> None: """Reset visualizer for new round of evaluation.""" raise NotImplementedError()
[docs] def process(self, cur_iter: int, *args: ArgsType) -> None: """Process data of single sample.""" raise NotImplementedError()
[docs] def show(self, cur_iter: int, blocking: bool = True) -> None: """Shows the visualization. Args: cur_iter (int): Current iteration. blocking (bool): If the visualization should be blocking and wait for human input. Defaults to True. """ raise NotImplementedError()
[docs] def save_to_disk(self, cur_iter: int, output_folder: str) -> None: """Saves the visualization to disk. Args: cur_iter (int): Current iteration. output_folder (str): Folder where the output should be written. """ raise NotImplementedError()