From 785f2f819d203492e8fbc2264563fd40e69b72a3 Mon Sep 17 00:00:00 2001 From: Martin Kozlovsky Date: Wed, 15 Jan 2025 19:14:02 -0500 Subject: [PATCH] updated perlin --- luxonis_train/loaders/perlin.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/luxonis_train/loaders/perlin.py b/luxonis_train/loaders/perlin.py index 687fd015..cd201d35 100644 --- a/luxonis_train/loaders/perlin.py +++ b/luxonis_train/loaders/perlin.py @@ -14,7 +14,7 @@ def compute_gradients(res: tuple[int, int]) -> torch.Tensor: @torch.jit.script -def lerp_torch( +def lerp_torch( # pragma: no cover x: torch.Tensor, y: torch.Tensor, w: torch.Tensor ) -> torch.Tensor: return (y - x) * w + x @@ -92,7 +92,7 @@ def rand_perlin_2d( @torch.jit.script -def rotate_noise(noise: torch.Tensor) -> torch.Tensor: +def rotate_noise(noise: torch.Tensor) -> torch.Tensor: # pragma: no cover angle = torch.rand(1) * 2 * torch.pi h, w = noise.shape center_y, center_x = h // 2, w // 2 @@ -165,11 +165,6 @@ def apply_anomaly_to_img( - perlin_mask (torch.Tensor): The Perlin noise mask applied to the image. """ - if pixel_augs is None: - - def pixel_augs(image): - return {"image": image} - sampled_anomaly_image_path = random.choice(anomaly_source_paths) anomaly_image = load_image_as_numpy(sampled_anomaly_image_path) @@ -180,7 +175,8 @@ def pixel_augs(image): interpolation=cv2.INTER_LINEAR, ) - anomaly_image = pixel_augs(image=anomaly_image)["image"] + if pixel_augs is not None: + anomaly_image = pixel_augs(image=anomaly_image)["image"] anomaly_image = torch.tensor(anomaly_image).permute(2, 0, 1)