LogoLogo
  • Tensorleap
  • Examples
    • Semantic Segmentation
    • Image Analysis
    • Sentiment Analysis
    • MNIST Project Walkthrough
    • IMDB Project Walkthrough
  • Quickstart using CLI
  • Guides
    • Full Guides
      • MNIST Guide
        • Dataset Integration
        • Model Integration
        • Model Perception Analysis
        • Advanced Metrics
      • IMDB Guide
        • Dataset Integration
        • Model Integration
        • Model Perception Analysis
        • Advanced Metrics
    • Integration Script
      • Preprocess Function
      • Input Encoder
      • Ground Truth Encoder
      • Metadata Function
      • Visualizer Function
      • Prediction
      • Custom Metrics
      • Custom Loss Function
      • Custom Layers
      • Unlabeled Data
      • Examples
        • CelebA Object Detection (YoloV7)
        • Wikipedia Toxicity (using Tensorflow Datasets)
        • Confusion Matrix
        • CelebA Classification (using GCS)
  • Platform
    • Resources Management
    • Project
    • Dataset
    • Secret Manager
    • Network
      • Dataset Node
      • Layers
      • Loss and Optimizer
      • Visualizers
      • Import Model
      • Metrics
    • Evaluate / Train Model
    • Metrics Dashboard
    • Versions
    • Issues
    • Tests
    • Analysis
      • helpers
        • detection
          • YOLO
    • Team management
    • Insights
  • API
    • code_loader
      • leap_binder
        • add_custom_metric
        • set_preprocess
        • set_unlabeled_data_preprocess
        • set_input
        • set_ground_truth
        • set_metadata
        • add_prediction
        • add_custom_loss
        • set_visualizer
      • enums
        • DatasetMetadataType
        • LeapDataType
      • datasetclasses
        • PreprocessResponse
      • visualizer_classes
        • LeapImage
        • LeapImageWithBBox
        • LeapGraph
        • LeapText
        • LeapHorizontalBar
        • LeapImageMask
        • LeapTextMask
  • Tips & Tricks
    • Import External Code
  • Legal
    • Terms of Use
    • Privacy Policy
Powered by GitBook
On this page

Was this helpful?

  1. API
  2. code_loader
  3. leap_binder

set_visualizer

code_loader.leap_binder.set_visualizer

Previousadd_custom_lossNextenums

Last updated 2 years ago

Was this helpful?

The leap_binder.set_visualizer binding function points to . In addition, it defines the visualizer_type and name for reference.

code_loader.leap_binder.set_visualizer(
    name=str,
    function=VisualizerCallableInterface,
    visualizer_type=LeapDataType,
    heatmap_visualizer=Optional[Callable[[npt.NDArray[np.float32]], npt.NDArray[np.float32]]]
)
Args

function

name

(str) with the given name of the input, e.g. image.

visualizer_type

heatmap_visualizer

(optional)

Callable[[npt.NDArray[np.float32]], npt.NDArray[np.float32]] This parameter points to a function that modifies the heatmap data before visualization.

Examples

Basic Usage

import numpy as np
from code_loader.contract.visualizer_classes import LeapText
from code_loader import leap_binder
...

def text_visualizer_func(data: np.ndarray) -> LeapText:
    tokenizer = leap_binder.custom_tokenizer
    text = tokenizer.sequences_to_texts(data)
    return LeapText(text)
    
leap_binder.set_visualizer(
    function=text_visualizer_func,
    visualizer_type=LeapText.type,
    name='text_from_token'
)

Resize Image and Heatmap

When changing the original data shape in the visualizer function, we need to reshape the heatmap data that is projected. heatmap_visualizer points to a function that modifies the heatmap data respectively. Consider the following example:

from code_loader.contract.visualizer_classes import LeapImage
from code_loader import le

def resized_image_visualizer(data: npt.NDArray[np.float32]) -> LeapImage:
    return LeapImage(np.resize(data, (256, 512, 3)))

def resized_image_visualizer_heatmap(data: npt.NDArray[np.float32]) -> npt.NDArray[np.float32]:
    # data is the heatmap with original size (origin_W, origin_H)
    return np.resize(data, (256, 512))    # we reshape to the resized shape


leap_binder.set_visualizer(
    function=resized_image_visualizer,
    name='resized_image_visualizer',
    visualizer_type=LeapImage.type,
    heatmap_visualizer=resized_image_visualizer_heatmap
)

Guides

Full examples can be found in the Dataset Integration section of the following guides:

(VisualizerCallableInterface) This parameter points to the mentioned above.

() This property sets the type of the data to be visualized by the visualizer.

The pages contain additional, decoder specific, examples. Moreover, full script usage can be found in .

Visualizer Function
MNIST Guide
IMDB Guide
Visualizer Function
LeapDataType
decoder_classes
Integration Script