LeapTextMask

code_loader.contract.visualizer_classes.LeapTextMask

import numpy.typing as npt
from code_loader.contract.enums import LeapDataType

@dataclass
class LeapTextMask:
    mask: npt.NDArray[np.float32]
    text_array: npt.NDArray[np.float32]
    labels: List[str]
    type: LeapDataType = LeapDataType.TextMask

Examples

Basic Usage

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

def text_segmentation_visualizer(data: np.ndarray, segmentation_prediction: np.ndarray) -> LeapHLeapImageMaskorizontalBar:
    labels = ['neutral', 'positive', 'negative']
    tokenizer = leap_binder.custom_tokenizer
    text = tokenizer.sequences_to_texts(data)
    return LeapImageMask(mask=segmentation_prediction, text=text, labels=labels)
    
leap_binder.set_visualizer(
    name='text_segmentation',
    function=text_segmentation_visualizer,
    visualizer_type=LeapTextMask.type
)

Last updated