MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / __call__

Method __call__

monai/apps/detection/transforms/array.py:515–543  ·  view source on GitHub ↗

Args: boxes: bounding boxes, Nx4 or Nx6 torch tensor or ndarray. The box mode is assumed to be ``StandardMode`` labels: Sequence of array. Each element represents classification labels or scores Returns: - cropped boxes, does not share memory wit

(  # type: ignore[override]
        self, boxes: NdarrayTensor, labels: Sequence[NdarrayOrTensor] | NdarrayOrTensor
    )

Source from the content-addressed store, hash-verified

513 raise ValueError("Currently negative indexing is not supported for SpatialCropBox.")
514
515 def __call__( # type: ignore[override]
516 self, boxes: NdarrayTensor, labels: Sequence[NdarrayOrTensor] | NdarrayOrTensor
517 ) -> tuple[NdarrayTensor, tuple | NdarrayOrTensor]:
518 """
519 Args:
520 boxes: bounding boxes, Nx4 or Nx6 torch tensor or ndarray. The box mode is assumed to be ``StandardMode``
521 labels: Sequence of array. Each element represents classification labels or scores
522
523 Returns:
524 - cropped boxes, does not share memory with original boxes
525 - cropped labels, does not share memory with original labels
526
527 Example:
528 .. code-block:: python
529
530 box_cropper = SpatialCropPadBox(roi_start=[0, 1, 4], roi_end=[21, 15, 8])
531 boxes = torch.ones(2, 6)
532 class_labels = torch.Tensor([0, 1])
533 pred_scores = torch.Tensor([[0.4,0.3,0.3], [0.5,0.1,0.4]])
534 labels = (class_labels, pred_scores)
535 boxes_crop, labels_crop_tuple = box_cropper(boxes, labels)
536 """
537 spatial_dims = min(len(self.slices), get_spatial_dims(boxes=boxes)) # spatial dims
538 boxes_crop, keep = spatial_crop_boxes(
539 boxes,
540 [self.slices[axis].start for axis in range(spatial_dims)],
541 [self.slices[axis].stop for axis in range(spatial_dims)],
542 )
543 return boxes_crop, select_labels(labels, keep)
544
545
546class RotateBox90(Rotate90):

Callers

nothing calls this directly

Calls 4

get_spatial_dimsFunction · 0.90
spatial_crop_boxesFunction · 0.90
minFunction · 0.85
select_labelsFunction · 0.85

Tested by

no test coverage detected