From d7cab6fd8b4c96c5f8f5bcd1fd0a9b4ac8edcddd Mon Sep 17 00:00:00 2001 From: Marie Roald Date: Tue, 10 Sep 2024 17:25:31 +0200 Subject: [PATCH 1/4] Update inkgenerator to work with new version of numpy --- augraphy/utilities/inkgenerator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/augraphy/utilities/inkgenerator.py b/augraphy/utilities/inkgenerator.py index 30cd597..88d8f88 100644 --- a/augraphy/utilities/inkgenerator.py +++ b/augraphy/utilities/inkgenerator.py @@ -346,7 +346,7 @@ def apply_highlighter_effect(self, ink_image, ink_background): n_clusters = (200 + kernel_size * 10, 250 + kernel_size * 10) n_samples = (200 + kernel_size * 5, 250 + kernel_size * 5) - std_range = (3 + np.ceil(kernel_size / 5), 7 + np.ceil(kernel_size / 5)) + std_range = (3 + np.ceil(kernel_size / 5).astype(int), 7 + np.ceil(kernel_size / 5).astype(int)) image_noise_center = self.generate_noise_clusters(gray_image, n_clusters, n_samples, std_range) image_noise_border = self.generate_noise_clusters(gray_image, n_clusters, n_samples, std_range) From adeb30309f281865db26db0f349b1fd11eeeb0ce Mon Sep 17 00:00:00 2001 From: Marie Roald Date: Mon, 23 Sep 2024 07:00:00 +0200 Subject: [PATCH 2/4] fix astype(int) -> item() --- augraphy/utilities/inkgenerator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/augraphy/utilities/inkgenerator.py b/augraphy/utilities/inkgenerator.py index 88d8f88..c93c68c 100644 --- a/augraphy/utilities/inkgenerator.py +++ b/augraphy/utilities/inkgenerator.py @@ -346,7 +346,7 @@ def apply_highlighter_effect(self, ink_image, ink_background): n_clusters = (200 + kernel_size * 10, 250 + kernel_size * 10) n_samples = (200 + kernel_size * 5, 250 + kernel_size * 5) - std_range = (3 + np.ceil(kernel_size / 5).astype(int), 7 + np.ceil(kernel_size / 5).astype(int)) + std_range = (3 + np.ceil(kernel_size / 5).item(), 7 + np.ceil(kernel_size / 5).item()) image_noise_center = self.generate_noise_clusters(gray_image, n_clusters, n_samples, std_range) image_noise_border = self.generate_noise_clusters(gray_image, n_clusters, n_samples, std_range) From d554967c3fce548a8dcf2200c7f41d1fc0215423 Mon Sep 17 00:00:00 2001 From: Marie Roald Date: Mon, 23 Sep 2024 07:00:33 +0200 Subject: [PATCH 3/4] Fix badphotocopy --- augraphy/augmentations/badphotocopy.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/augraphy/augmentations/badphotocopy.py b/augraphy/augmentations/badphotocopy.py index 8f54c3d..04bdee1 100644 --- a/augraphy/augmentations/badphotocopy.py +++ b/augraphy/augmentations/badphotocopy.py @@ -88,18 +88,18 @@ def __init__( # clamp values # noise value range from 0-255 self.noise_value = list(self.noise_value) - self.noise_value[0] = np.clip(self.noise_value[0], 0, 255) - self.noise_value[1] = np.clip(self.noise_value[1], 0, 255) + self.noise_value[0] = np.clip(self.noise_value[0], 0, 255).item() + self.noise_value[1] = np.clip(self.noise_value[1], 0, 255).item() # sparsity range from 0-1 self.noise_sparsity = list(self.noise_sparsity) - self.noise_sparsity[0] = np.clip(self.noise_sparsity[0], 0, 1) - self.noise_sparsity[1] = np.clip(self.noise_sparsity[1], 0, 1) + self.noise_sparsity[0] = np.clip(self.noise_sparsity[0], 0, 1).item() + self.noise_sparsity[1] = np.clip(self.noise_sparsity[1], 0, 1).item() # concentration range from 0-1 self.noise_concentration = list(self.noise_concentration) - self.noise_concentration[0] = np.clip(self.noise_concentration[0], 0, 1) - self.noise_concentration[1] = np.clip(self.noise_concentration[1], 0, 1) + self.noise_concentration[0] = np.clip(self.noise_concentration[0], 0, 1).item() + self.noise_concentration[1] = np.clip(self.noise_concentration[1], 0, 1).item() # Constructs a string representation of this Augmentation. def __repr__(self): From 88f17f63328eb57b0dee181f583c4c7ad0d7c020 Mon Sep 17 00:00:00 2001 From: Marie Roald Date: Wed, 25 Sep 2024 20:35:50 +0200 Subject: [PATCH 4/4] Revert astype(int) -> item() --- augraphy/utilities/inkgenerator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/augraphy/utilities/inkgenerator.py b/augraphy/utilities/inkgenerator.py index c93c68c..88d8f88 100644 --- a/augraphy/utilities/inkgenerator.py +++ b/augraphy/utilities/inkgenerator.py @@ -346,7 +346,7 @@ def apply_highlighter_effect(self, ink_image, ink_background): n_clusters = (200 + kernel_size * 10, 250 + kernel_size * 10) n_samples = (200 + kernel_size * 5, 250 + kernel_size * 5) - std_range = (3 + np.ceil(kernel_size / 5).item(), 7 + np.ceil(kernel_size / 5).item()) + std_range = (3 + np.ceil(kernel_size / 5).astype(int), 7 + np.ceil(kernel_size / 5).astype(int)) image_noise_center = self.generate_noise_clusters(gray_image, n_clusters, n_samples, std_range) image_noise_border = self.generate_noise_clusters(gray_image, n_clusters, n_samples, std_range)