bbox_to_segmask

hybrid_learning.experimentation.model_registry.custom_model_postproc.models_common.bbox_to_segmask(bbox_info_batch, logical_or, image_size=(640, 640), target_class=1, min_score=None)[source]

Transform EfficientDet output into segmentation mask. The bbox_info_batch must have shape [batch, #bboxes per image, 6], each row representing [x_min, y_min, x_max, y_max, score, class]. The returned mask has shape [batch, (#bboxes | 1), *image_size]. The per-image-bbox-masks are reduced to per-image-masks using logical_or if this is set. Note that not setting logical_or will only succeed in case of uniform #bboxes! For details see the forward method and attributes of EfficientDetToSetMask.

Parameters
  • bbox_info_batch (Tensor) – tensor of shape [batch, #bbox per image, 6] where the last dimension encodes (x_min, y_min, x_max, y_max, score, class)

  • logical_or (Callable[[List[Tensor]], Tensor]) – callable that accepts a list of tensor segmentation masks with values in [0, 1] (one 2D mask for each bounding box in an image) and returns a single combined segmentation mask; e.g. use a variadic fuzzy logical OR object

  • image_size (Sequence[int]) – the size of the original image as (height, width) for which to draw the bounding boxes

  • target_class (int) – the ID of the target class (see also bbox_info_batch) for selection

  • min_score (Optional[float]) – the minimum score a box must have to be included in the combined mask

Returns

tensor of size (batch, 1, height, width)

Return type

Tensor