optical.visualizer.visualizer.Visualizer¶
-
class
optical.visualizer.visualizer.Visualizer(images_dir: Union[str, os.PathLike], dataframe: pandas.core.frame.DataFrame, split: Optional[str] = None, img_size: int = 512, **kwargs)[source]¶ Bases:
objectCreates visualizer to visualze images with annotations by batch size, name and index. Required dataframe of the dataset as input.Can show all images with annotations as a video.
- Parameters
images_dir (Union[str, os.PathLike]) – Path to images in the dataset
dataframe (pd.DataFrame) – Pandas dataframe which is created by
optical.converter. Must contain["image_id", "x_min", "y_min", "width", "height", "category", "class_id"]columns.split (Optional[str], optional) – Split of the dataset to be visualized.
img_size (int, optional) – Image size to resize and maintain uniformity. Defaults to 512.
-
__init__(images_dir: Union[str, os.PathLike], dataframe: pandas.core.frame.DataFrame, split: Optional[str] = None, img_size: int = 512, **kwargs)[source]¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__(images_dir, dataframe[, split, …])Initialize self.
Resets all the filters applied on original dataframe.
show_batch([num_imgs, previous, save_path, …])Displays a batch of images based on input size.
show_image([index, name, save_path, render])Displays images with annotation given index or name.
show_video([use_original])Displays whole dataset as a video.
-
show_batch(num_imgs: int = 9, previous: bool = False, save_path: Optional[str] = None, render: str = 'pil', random: bool = True, **kwargs) → Any[source]¶ Displays a batch of images based on input size.
- Parameters
num_imgs (int, optional) – Number of images and their annotation to be visualized. Defaults to 9.
previous (bool, optional) – If
Truejust displays last batch. Defaults to False.save_path (Optional[str], optional) – Output path if images and annotations to be saved. Defaults to None.
render (str, optional) – Rendering to be used. Available options are
mpl,``pil``,``mpy``. Ifmpl, usesmatplotlibto display the images and annotations. Ifpil, usesPillowto display the images and annotations. Ifmpy, usesmediapyto display as video Defaults to “pil”.random (bool, optional) – If
Truerandomly selectsnum_imgsimages otherwise follows a sequence. Defaults to True.
- Returns
Incase of Pillow or mediapy rendering IPython media object will be returned.
- Return type
Any
-
show_image(index: int = 0, name: Optional[str] = None, save_path: Optional[str] = None, render: str = 'mpl', **kwargs) → Any[source]¶ Displays images with annotation given index or name.
- Parameters
index (int, optional) – Index of the image to be fetched. Defaults to 0.
name (Optional[str], optional) – Name of the image to be fetched. Defaults to None.
save_path (Optional[str], optional) – Output path if images and annotations to be saved. Defaults to None.
render (str, optional) – Rendering to be used. Available options are
mpl,``pil``,``mpy``. Ifmpl, usesmatplotlibto display the images and annotations. Ifpil, usesPillowto display the images and annotations. Ifmpy, usesmediapyto display as video Defaults to “pil”.
- Returns
Incase of Pillow or mediapy rendering IPython media object will be returned.
- Return type
Any
-
show_video(use_original: bool = True, **kwargs) → Any[source]¶ Displays whole dataset as a video.
- Parameters
use_original (bool) – Whether to original dataset or filtered dataset.Defaults to
True- Keyword Arguments
show_image_name (bool) – Whether to show image names in the video or not.
image_time (float) – How many seconds each should be displayed in the video. e.g:
image_time = 1means each image will be displayed for one second.image_time = 0.5means each image will be displayed for half a second.
- Returns
Returns IPython media object.
- Return type
Any