Skip to content
class

BBoxSafeRandomCrop

extends_NoParamsTransform[Empty]_BBoxAwareCrop
BBoxSafeRandomCrop(erosion_rate: float = 0.0, p: float = 1.0)

Random crop guaranteed to contain every bounding box (Albumentations BBoxSafeRandomCrop).

Computes the tightest axis-aligned window enclosing every box in the sample, then jitters the four edges outward into the surrounding image — picking a uniformly random crop within that enlarged region. The resulting crop always fully contains every input box, so detection / instance-segmentation labels never need to be filtered. If the sample carries no boxes the transform degenerates into a no-op identity crop covering the full image.

Parameters

erosion_ratefloat= 0.0
Fraction by which the enclosing box-union is shrunk before the jittered window is drawn. 0 keeps every box fully inside; positive values let the window cut into boxes by up to erosion_rate of their extent (Albumentations parity).
pfloat= 1.0
Probability of applying the transform.

Examples

>>> import lucid.utils.transforms as T
>>> tf = T.BBoxSafeRandomCrop(p=1.0)

Used by 1

Constructors

2
dunder

__init__

→None
__init__(erosion_rate: float = 0.0, p: float = 1.0)
dunder

__call__

→object
__call__(inputs: object)

Instance methods

1
fn

make_params

→Emptyfrom _NoParams
make_params(img: Tensor)

Dunder methods

1