Visualizer Function

Tensorleap enables visualizations of data within the model graph by connecting a Visualizer block to a node's output tensor. This allows to visualize the model's input, prediction, ground truth, or any inner tensor.

By default, these naive Visualizers are provided (in the UI):

  • Image

  • Graph

  • Numeric

  • HorizontalBar

  • Text

  • ImageMask

  • TextMask

These naive visualizers shows the data as-is, but in many cases, there is a need to write our own Visualizer Function to make sense of the data. For example:

  • Converting tokenized data to text words

  • Custom post-processing

  • Draw landmarks on images

  • Apply transforms

Example a visualizer function:

import numpy as np
from code_loader.contract.visualizer_classes import LeapText
from code_loader.contract.enums import LeapDataType
...

@tensorleap_custom_visualizer(name="input_visualizer", visualizer_type=LeapDataType.Text)
def input_visualizer(input_ids: np.ndarray) -> LeapText:
    input_ids = np.squeeze(input_ids)
    text = decode_token_ids(input_ids)
    return LeapText(text)

The @tensorleap_custom_visualizerdecorator registers each visualizer into the Tensorleap integration.

These functions should return one of the following types defined in visualizer_classes.

The visualizer_classes pages contain additional, visualizer specific, examples. Moreover, full script usage can be found at Integration Script.

Last updated

Was this helpful?