class
BBoxSafeRandomCrop
extends
_NoParamsTransform[Empty]_BBoxAwareCropBBoxSafeRandomCrop(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.0Fraction 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.0Probability of applying the transform.
Examples
>>> import lucid.utils.transforms as T
>>> tf = T.BBoxSafeRandomCrop(p=1.0)