@@ -23,23 +23,23 @@ def __init__(
2323 """Augmentation to apply letterbox resizing to images. Also
2424 transforms masks, bboxes and keypoints to correct shape.
2525
26- @param height: Desired height of the output.
2726 @type height: int
28- @param width : Desired width of the output.
27+ @param height : Desired height of the output.
2928 @type width: int
30- @param interpolation: Cv2 flag to specify interpolation used
31- when resizing. Defaults to cv2.INTER_LINEAR.
29+ @param width: Desired width of the output.
3230 @type interpolation: int, optional
33- @param border_value: Padding value for images. Defaults to 0.
31+ @param interpolation: cv2 flag to specify interpolation used
32+ when resizing. Defaults to C{cv2.INTER_LINEAR}.
3433 @type border_value: int, optional
35- @param mask_value : Padding value for masks . Defaults to 0 .
34+ @param border_value : Padding value for images . Defaults to C{0} .
3635 @type mask_value: int, optional
37- @param always_apply: Whether to always apply the transform.
38- Defaults to False.
36+ @param mask_value: Padding value for masks. Defaults to C{0}.
3937 @type always_apply: bool, optional
40- @param p: Probability of applying the transform. Defaults to
41- 1.0 .
38+ @param always_apply: Whether to always apply the transform.
39+ Defaults to C{False} .
4240 @type p: float, optional
41+ @param p: Probability of applying the transform. Defaults to
42+ C{1.0}.
4343 """
4444
4545 super ().__init__ (always_apply , p )
@@ -108,20 +108,20 @@ def apply(
108108 ) -> np .ndarray :
109109 """Applies the letterbox augmentation to an image.
110110
111- @param img: Input image to which resize is applied.
112111 @type img: np.ndarray
113- @param pad_top: Number of pixels to pad at the top .
112+ @param img: Input image to which resize is applied .
114113 @type pad_top: int
115- @param pad_bottom : Number of pixels to pad at the bottom .
114+ @param pad_top : Number of pixels to pad at the top .
116115 @type pad_bottom: int
117- @param pad_left : Number of pixels to pad on the left .
116+ @param pad_bottom : Number of pixels to pad at the bottom .
118117 @type pad_left: int
119- @param pad_right : Number of pixels to pad on the right .
118+ @param pad_left : Number of pixels to pad on the left .
120119 @type pad_right: int
121- @param params: Additional parameters for the padding operation .
122- @type params : Any
123- @return: Image with applied letterbox resize .
120+ @param pad_right: Number of pixels to pad on the right .
121+ @type kwargs : Any
122+ @param kwargs: Additional parameters for the padding operation .
124123 @rtype: np.ndarray
124+ @return: Image with applied letterbox resize.
125125 """
126126
127127 resized_img = cv2 .resize (
@@ -155,20 +155,20 @@ def apply_to_mask(
155155 ) -> np .ndarray :
156156 """Applies letterbox augmentation to the input mask.
157157
158- @param img: Input mask to which resize is applied.
159158 @type img: np.ndarray
160- @param pad_top: Number of pixels to pad at the top .
159+ @param img: Input mask to which resize is applied .
161160 @type pad_top: int
162- @param pad_bottom : Number of pixels to pad at the bottom .
161+ @param pad_top : Number of pixels to pad at the top .
163162 @type pad_bottom: int
164- @param pad_left : Number of pixels to pad on the left .
163+ @param pad_bottom : Number of pixels to pad at the bottom .
165164 @type pad_left: int
166- @param pad_right : Number of pixels to pad on the right .
165+ @param pad_left : Number of pixels to pad on the left .
167166 @type pad_right: int
168- @param params: Additional parameters for the padding operation .
167+ @param pad_right: Number of pixels to pad on the right .
169168 @type params: Any
170- @return: Mask with applied letterbox resize .
169+ @param params: Additional parameters for the padding operation .
171170 @rtype: np.ndarray
171+ @return: Mask with applied letterbox resize.
172172 """
173173
174174 resized_img = cv2 .resize (
@@ -202,20 +202,20 @@ def apply_to_bbox(
202202 ) -> BoxType :
203203 """Applies letterbox augmentation to the bounding box.
204204
205- @param img: Bounding box to which resize is applied.
206- @type img: BoxType
207- @param pad_top: Number of pixels to pad at the top.
205+ @type bbox: BoxType
206+ @param bbox: Bounding box to which resize is applied.
208207 @type pad_top: int
209- @param pad_bottom : Number of pixels to pad at the bottom .
208+ @param pad_top : Number of pixels to pad at the top .
210209 @type pad_bottom: int
211- @param pad_left : Number of pixels to pad on the left .
210+ @param pad_bottom : Number of pixels to pad at the bottom .
212211 @type pad_left: int
213- @param pad_right : Number of pixels to pad on the right .
212+ @param pad_left : Number of pixels to pad on the left .
214213 @type pad_right: int
215- @param params: Additional parameters for the padding operation .
214+ @param pad_right: Number of pixels to pad on the right .
216215 @type params: Any
217- @return: Bounding box with applied letterbox resize .
216+ @param params: Additional parameters for the padding operation .
218217 @rtype: BoxType
218+ @return: Bounding box with applied letterbox resize.
219219 """
220220
221221 x_min , y_min , x_max , y_max = denormalize_bbox (
@@ -245,29 +245,29 @@ def apply_to_keypoint(
245245 pad_bottom : int ,
246246 pad_left : int ,
247247 pad_right : int ,
248- ** params ,
248+ ** kwargs ,
249249 ) -> KeypointType :
250250 """Applies letterbox augmentation to the keypoint.
251251
252- @param img: Keypoint to which resize is applied.
253- @type img: KeypointType
254- @param pad_top: Number of pixels to pad at the top.
252+ @type keypoint: KeypointType
253+ @param keypoint: Keypoint to which resize is applied.
255254 @type pad_top: int
256- @param pad_bottom : Number of pixels to pad at the bottom .
255+ @param pad_top : Number of pixels to pad at the top .
257256 @type pad_bottom: int
258- @param pad_left : Number of pixels to pad on the left .
257+ @param pad_bottom : Number of pixels to pad at the bottom .
259258 @type pad_left: int
260- @param pad_right : Number of pixels to pad on the right .
259+ @param pad_left : Number of pixels to pad on the left .
261260 @type pad_right: int
262- @param params: Additional parameters for the padding operation .
263- @type params : Any
264- @return: Keypoint with applied letterbox resize .
261+ @param pad_right: Number of pixels to pad on the right .
262+ @type kwargs : Any
263+ @param kwargs: Additional parameters for the padding operation .
265264 @rtype: KeypointType
265+ @return: Keypoint with applied letterbox resize.
266266 """
267267
268268 x , y , angle , scale = keypoint [:4 ]
269- scale_x = (self .width - pad_left - pad_right ) / params ["cols" ]
270- scale_y = (self .height - pad_top - pad_bottom ) / params ["rows" ]
269+ scale_x = (self .width - pad_left - pad_right ) / kwargs ["cols" ]
270+ scale_y = (self .height - pad_top - pad_bottom ) / kwargs ["rows" ]
271271 new_x = (x * scale_x ) + pad_left
272272 new_y = (y * scale_y ) + pad_top
273273 # if keypoint is in the padding then set coordinates to -1
@@ -286,8 +286,8 @@ def apply_to_keypoint(
286286 def get_transform_init_args_names (self ) -> Tuple [str , ...]:
287287 """Gets the default arguments for the letterbox augmentation.
288288
289- @return: The string keywords of the arguments.
290289 @rtype: Tuple[str, ...]
290+ @return: The string keywords of the arguments.
291291 """
292292
293293 return (
@@ -303,14 +303,14 @@ def _out_of_bounds(
303303 ) -> bool :
304304 """ "Check if the given value is outside the specified limits.
305305
306- @param value: The value to be checked.
307306 @type value: float
308- @param min_limit: Minimum limit .
307+ @param value: The value to be checked .
309308 @type min_limit: float
310- @param max_limit: Maximum limit.
309+ @param min_limit: Minimum limit.
311310 @type max_limit: float
311+ @param max_limit: Maximum limit.
312+ @rtype: bool
312313 @return: True if the value is outside the specified limits,
313314 False otherwise.
314- @rtype: bool
315315 """
316316 return value < min_limit or value > max_limit
0 commit comments