diff --git a/albumentations/augmentations/functional.py b/albumentations/augmentations/functional.py index 78b8aec72..464478a71 100644 --- a/albumentations/augmentations/functional.py +++ b/albumentations/augmentations/functional.py @@ -9,7 +9,6 @@ import numpy as np from albucore import ( MAX_VALUES_BY_DTYPE, - add, add_array, add_constant, add_weighted, @@ -117,10 +116,10 @@ def shift_hsv(img: np.ndarray, hue_shift: float, sat_shift: float, val_shift: fl hue = sz_lut(hue, lut_hue, inplace=False) if sat_shift != 0: - sat = add_constant(sat, sat_shift) + sat = add_constant(sat, sat_shift, inplace=True) if val_shift != 0: - val = add_constant(val, val_shift) + val = add_constant(val, val_shift, inplace=True) img = cv2.merge((hue, sat, val)) img = cv2.cvtColor(img, cv2.COLOR_HSV2RGB) @@ -1589,7 +1588,7 @@ def unsharp_mask( soft_mask = blur_fn(mask) - return add(multiply(sharp, soft_mask), multiply(image, 1 - soft_mask)) + return add_array(multiply(sharp, soft_mask), multiply(image, 1 - soft_mask), inplace=True) @preserve_channel_dim @@ -1880,7 +1879,7 @@ def generate_approx_gaussian_noise( @clipped def add_noise(img: np.ndarray, noise: np.ndarray) -> np.ndarray: - return add_array(img, noise) + return add_array(img, noise, inplace=False) def swap_tiles_on_keypoints( diff --git a/albumentations/augmentations/geometric/functional.py b/albumentations/augmentations/geometric/functional.py index 5298ad7d8..cd006cd1c 100644 --- a/albumentations/augmentations/geometric/functional.py +++ b/albumentations/augmentations/geometric/functional.py @@ -6,7 +6,7 @@ import cv2 import numpy as np -from albucore import get_num_channels, hflip, maybe_process_in_chunks, preserve_channel_dim, vflip +from albucore import get_num_channels, hflip, maybe_process_in_chunks, multiply_by_constant, preserve_channel_dim, vflip from albumentations.augmentations.utils import angle_2pi_range, handle_empty_array from albumentations.core.bbox_utils import bboxes_from_masks, denormalize_bboxes, masks_from_bboxes, normalize_bboxes @@ -1512,7 +1512,7 @@ def generate_noise_field() -> np.ndarray: elif noise_distribution == "uniform": field = random_generator.uniform(low=-1, high=1, size=image_shape[:2]).astype(np.float32) cv2.GaussianBlur(field, kernel_size, sigma, dst=field) - return field * alpha + return multiply_by_constant(field, alpha, inplace=True) # Generate first displacement field dx = generate_noise_field()