Skip to content

outputdatadescriptions

outputdatadescriptions

Module for output datadescriptions

Classes

OutputImageDataDescription

Bases: DataDescription, ABC

DataDescription used for models with images as output (e.g. SemSeg)

Functions
get_output_channel_count
get_output_channel_count()

Returns the number of output channels

Source code in niceml/data/datadescriptions/outputdatadescriptions.py
def get_output_channel_count(self) -> int:
    """Returns the number of output channels"""
    return len(self.get_output_channel_names())
get_output_channel_names abstractmethod
get_output_channel_names()

Returns a list of the output channel names

Source code in niceml/data/datadescriptions/outputdatadescriptions.py
@abstractmethod
def get_output_channel_names(self) -> List[str]:
    """Returns a list of the output channel names"""
get_output_image_size abstractmethod
get_output_image_size()

Returns the ImageSize of the input image(s)

Source code in niceml/data/datadescriptions/outputdatadescriptions.py
@abstractmethod
def get_output_image_size(self) -> ImageSize:
    """Returns the ImageSize of the input image(s)"""
get_output_tensor_shape
get_output_tensor_shape()

Returns the 3-dim shape of the input tensor [height, width, channel_count]

Source code in niceml/data/datadescriptions/outputdatadescriptions.py
def get_output_tensor_shape(self) -> Tuple[int, int, int]:
    """Returns the 3-dim shape of the input tensor [height, width, channel_count]"""
    return self.get_output_image_size().to_numpy_shape() + (
        self.get_output_channel_count(),
    )
get_use_void_class abstractmethod
get_use_void_class()

Returns whether the model uses a default class (e.g. background)

Source code in niceml/data/datadescriptions/outputdatadescriptions.py
@abstractmethod
def get_use_void_class(self) -> bool:
    """Returns whether the model uses a default class (e.g. background)"""

OutputObjDetDataDescription

Bases: DataDescription, ABC

Abstract baseclass for OutputObjDetDataDescription

Functions
get_anchor_aspect_ratios abstractmethod
get_anchor_aspect_ratios()

Returns the aspect ratios for each feature map

Source code in niceml/data/datadescriptions/outputdatadescriptions.py
@abstractmethod
def get_anchor_aspect_ratios(self) -> List[float]:
    """Returns the aspect ratios for each feature map"""
get_anchor_scales abstractmethod
get_anchor_scales()

Returns the scales for each feature map

Source code in niceml/data/datadescriptions/outputdatadescriptions.py
@abstractmethod
def get_anchor_scales(self) -> List[float]:
    """Returns the scales for each feature map"""
get_anchorcount_featuremap_list
get_anchorcount_featuremap_list()

Returns the anchorcount for the feature list

Source code in niceml/data/datadescriptions/outputdatadescriptions.py
def get_anchorcount_featuremap_list(self) -> List[int]:
    """Returns the anchorcount for the feature list"""
    return [
        self.get_anchorcount_for_scale(scale)
        for scale in self.get_featuremap_scales()
    ]
get_anchorcount_for_scale abstractmethod
get_anchorcount_for_scale(scale)

Calculates the anchorcount for a specific scale

Source code in niceml/data/datadescriptions/outputdatadescriptions.py
@abstractmethod
def get_anchorcount_for_scale(self, scale: int) -> int:
    """Calculates the anchorcount for a specific scale"""
get_anchorcount_per_feature abstractmethod
get_anchorcount_per_feature()

Returns the number of anchors which are generated per feature cell

Source code in niceml/data/datadescriptions/outputdatadescriptions.py
@abstractmethod
def get_anchorcount_per_feature(self) -> int:
    """Returns the number of anchors which are generated per feature cell"""
get_anchorcount_per_image
get_anchorcount_per_image()

Sums up all generated anchors for all feature maps and returns it.

Source code in niceml/data/datadescriptions/outputdatadescriptions.py
def get_anchorcount_per_image(self) -> int:
    """Sums up all generated anchors for all feature maps and returns it."""
    return sum(self.get_anchorcount_featuremap_list())
get_base_area_side abstractmethod
get_base_area_side()

Returns one side of a square base, which is used to determine the anchor size

Source code in niceml/data/datadescriptions/outputdatadescriptions.py
@abstractmethod
def get_base_area_side(self) -> float:
    """Returns one side of a square base, which is used to determine the anchor size"""
get_box_variance abstractmethod
get_box_variance()

Returns the box_variance list (length of 4)

Source code in niceml/data/datadescriptions/outputdatadescriptions.py
@abstractmethod
def get_box_variance(self) -> List[float]:
    """Returns the box_variance list (length of 4)"""
get_coordinates_count abstractmethod
get_coordinates_count()

Returns the count of coordinates required to represent the object (e.g. bounding box: 4)

Source code in niceml/data/datadescriptions/outputdatadescriptions.py
@abstractmethod
def get_coordinates_count(self) -> int:
    """
    Returns the count of coordinates required to represent
    the object (e.g. bounding box: 4)
    """
get_featuremap_count
get_featuremap_count()

Returns the number of feature maps. Should be the length of the featuremap_scales.

Source code in niceml/data/datadescriptions/outputdatadescriptions.py
def get_featuremap_count(self) -> int:
    """Returns the number of feature maps. Should be the length of the featuremap_scales."""
    return len(self.get_featuremap_scales())
get_featuremap_scales abstractmethod
get_featuremap_scales()

Returns the scale per feature map as int. E.g. 2 means (1024,1024) -> (512, 512) It is assumed that a feature map is always smaller than the original image.

Source code in niceml/data/datadescriptions/outputdatadescriptions.py
@abstractmethod
def get_featuremap_scales(self) -> List[int]:
    """
    Returns the scale per feature map as int.
    E.g. 2 means (1024,1024) -> (512, 512)
    It is assumed that a feature map is always smaller than
    the original image.
    """
get_output_class_count
get_output_class_count()

Returns the count of output classes used

Source code in niceml/data/datadescriptions/outputdatadescriptions.py
def get_output_class_count(self) -> int:
    """Returns the count of output classes used"""
    return len(self.get_output_class_names())
get_output_class_names abstractmethod
get_output_class_names()

Returns the used output class names

Source code in niceml/data/datadescriptions/outputdatadescriptions.py
@abstractmethod
def get_output_class_names(self) -> List[str]:
    """Returns the used output class names"""

OutputVectorDataDescription

Bases: DataDescription, ABC

DataDescription used by models with vectors as output

Functions
get_index_for_name
get_index_for_name(name)

Returns the index of the given output entry name(s) as int or list of indices

Source code in niceml/data/datadescriptions/outputdatadescriptions.py
def get_index_for_name(
    self, name: Union[str, List[str]]
) -> Optional[Union[int, List[int]]]:
    """Returns the index of the given output entry name(s) as int or list of indices"""
    if isinstance(name, str) and name in self.get_output_entry_names():
        return self.get_output_entry_names().index(name)
    if isinstance(name, list):
        index_list = []
        for cur_name in name:
            cur_index = self.get_index_for_name(cur_name)
            if cur_index is None:
                continue
            if isinstance(cur_index, list):
                index_list += cur_index
            else:
                index_list.append(cur_index)
        index_list = sorted(list(set(index_list)))
        return None if len(index_list) == 0 else index_list
    return None
get_name_for_index
get_name_for_index(index)

Returns a name or list of names for given class index or indices

Source code in niceml/data/datadescriptions/outputdatadescriptions.py
def get_name_for_index(self, index: Union[int, List[int]]) -> Union[str, List[str]]:
    """Returns a name or list of names for given class index or indices"""
    output_names = self.get_output_entry_names()
    if isinstance(index, list):
        return [output_names[cur_idx] for cur_idx in index]
    return output_names[index]
get_output_entry_names abstractmethod
get_output_entry_names()

Returns a name for each vector entry

Source code in niceml/data/datadescriptions/outputdatadescriptions.py
@abstractmethod
def get_output_entry_names(self) -> List[str]:
    """Returns a name for each vector entry"""
get_output_size abstractmethod
get_output_size()

Returns the size of the output vector(s)

Source code in niceml/data/datadescriptions/outputdatadescriptions.py
@abstractmethod
def get_output_size(self) -> int:
    """Returns the size of the output vector(s)"""