- class composer.callbacks.ImageVisualizer(interval='100ba', mode='input', num_images=8, channels_last=False, input_key=0, target_key=1)#
Logs image inputs and optionally outputs.
This callback triggers at a user defined interval, and logs a sample of input (optionally also segmentation masks) images under the
>>> from composer import Trainer >>> from composer.callbacks import ImageVisualizer >>> # constructing trainer object with this callback >>> trainer = Trainer( ... model=model, ... train_dataloader=train_dataloader, ... eval_dataloader=eval_dataloader, ... optimizers=optimizer, ... max_duration="1ep", ... callbacks=[ImageVisualizer()], ... )
The images are logged by the
Loggerto the following key(s) as described below.
Sampled examples of train images
Sampled examples of eval images
This callback only works with wandb logging for now.
interval (str | Time, optional) – Time string specifying how often to log train images. For example,
interval='1ep'means images are logged once every epoch, while
interval='100ba'means images are logged once every 100 batches. Eval images are logged once at the start of each eval. Default:
mode (str, optional) – How to log the image labels. Valid values are
"input"(input only) and “segmentation” which also saves segmentation masks. Default:
num_images (int, optional) – Number of images to log. Should be less than or equal to than the microbatch size. If there are not enough images in the microbatch, all the images in the microbatch will be logged. Default:
channels_last (bool, optional) – Whether the image channel dimension is the last dimension. Default:
input_key (str | int | Tuple[Callable, Callable] | Any, optional) – A key that indexes to the input from the batch. Can also be a pair of get and set functions, where the getter is assumed to be first in the pair. The default is 0, which corresponds to any sequence, where the first element is the input. Default:
target_key (str | int | Tuple[Callable, Callable] | Any, optional) – A key that indexes to the target from the batch. Can also be a pair of get and set functions, where the getter is assumed to be first in the pair. The default is 1, which corresponds to any sequence, where the second element is the target. Default: