Skip to content

Commit

Permalink
updated perlin
Browse files Browse the repository at this point in the history
  • Loading branch information
kozlov721 committed Jan 16, 2025
1 parent bb5e882 commit 785f2f8
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions luxonis_train/loaders/perlin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)

Expand Down

0 comments on commit 785f2f8

Please sign in to comment.