From a6283b9fb60acec4ec2ecc162236c2b66759214e Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Thu, 21 Mar 2024 23:00:29 +1100 Subject: [PATCH] tidy: "fit_image_to_resolution" -> "resize_image_to_resolution" --- invokeai/backend/image_util/canny.py | 6 +++--- invokeai/backend/image_util/hed.py | 6 +++--- invokeai/backend/image_util/lineart.py | 6 +++--- invokeai/backend/image_util/lineart_anime.py | 6 +++--- invokeai/backend/image_util/util.py | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/invokeai/backend/image_util/canny.py b/invokeai/backend/image_util/canny.py index 87219a9356..c1628dc182 100644 --- a/invokeai/backend/image_util/canny.py +++ b/invokeai/backend/image_util/canny.py @@ -3,9 +3,9 @@ from PIL import Image from invokeai.backend.image_util.util import ( cv2_to_pil, - fit_image_to_resolution, normalize_image_channel_count, pil_to_cv2, + resize_image_to_resolution, ) @@ -32,10 +32,10 @@ def get_canny_edges( np_image = pil_to_cv2(image) np_image = normalize_image_channel_count(np_image) - np_image = fit_image_to_resolution(np_image, detect_resolution) + np_image = resize_image_to_resolution(np_image, detect_resolution) edge_map = cv2.Canny(np_image, low_threshold, high_threshold) edge_map = normalize_image_channel_count(edge_map) - edge_map = fit_image_to_resolution(edge_map, image_resolution) + edge_map = resize_image_to_resolution(edge_map, image_resolution) return cv2_to_pil(edge_map) diff --git a/invokeai/backend/image_util/hed.py b/invokeai/backend/image_util/hed.py index 80519ce013..378e3b96e9 100644 --- a/invokeai/backend/image_util/hed.py +++ b/invokeai/backend/image_util/hed.py @@ -8,11 +8,11 @@ from huggingface_hub import hf_hub_download from PIL import Image from invokeai.backend.image_util.util import ( - fit_image_to_resolution, non_maximum_suppression, normalize_image_channel_count, np_to_pil, pil_to_np, + resize_image_to_resolution, safe_step, ) @@ -109,7 +109,7 @@ class HEDProcessor: device = next(iter(self.network.parameters())).device np_image = pil_to_np(input_image) np_image = normalize_image_channel_count(np_image) - np_image = fit_image_to_resolution(np_image, detect_resolution) + np_image = resize_image_to_resolution(np_image, detect_resolution) assert np_image.ndim == 3 height, width, _channels = np_image.shape @@ -128,7 +128,7 @@ class HEDProcessor: detected_map = edge detected_map = normalize_image_channel_count(detected_map) - img = fit_image_to_resolution(np_image, image_resolution) + img = resize_image_to_resolution(np_image, image_resolution) height, width, _channels = img.shape detected_map = cv2.resize(detected_map, (width, height), interpolation=cv2.INTER_LINEAR) diff --git a/invokeai/backend/image_util/lineart.py b/invokeai/backend/image_util/lineart.py index 0a17add422..3d19262822 100644 --- a/invokeai/backend/image_util/lineart.py +++ b/invokeai/backend/image_util/lineart.py @@ -9,10 +9,10 @@ from huggingface_hub import hf_hub_download from PIL import Image from invokeai.backend.image_util.util import ( - fit_image_to_resolution, normalize_image_channel_count, np_to_pil, pil_to_np, + resize_image_to_resolution, ) @@ -131,7 +131,7 @@ class LineartProcessor: np_image = pil_to_np(input_image) np_image = normalize_image_channel_count(np_image) - np_image = fit_image_to_resolution(np_image, detect_resolution) + np_image = resize_image_to_resolution(np_image, detect_resolution) model = self.model_coarse if coarse else self.model assert np_image.ndim == 3 @@ -149,7 +149,7 @@ class LineartProcessor: detected_map = normalize_image_channel_count(detected_map) - img = fit_image_to_resolution(np_image, image_resolution) + img = resize_image_to_resolution(np_image, image_resolution) H, W, C = img.shape detected_map = cv2.resize(detected_map, (W, H), interpolation=cv2.INTER_LINEAR) diff --git a/invokeai/backend/image_util/lineart_anime.py b/invokeai/backend/image_util/lineart_anime.py index f547aac0d0..5185d92c51 100644 --- a/invokeai/backend/image_util/lineart_anime.py +++ b/invokeai/backend/image_util/lineart_anime.py @@ -12,10 +12,10 @@ from huggingface_hub import hf_hub_download from PIL import Image from invokeai.backend.image_util.util import ( - fit_image_to_resolution, normalize_image_channel_count, np_to_pil, pil_to_np, + resize_image_to_resolution, ) @@ -173,7 +173,7 @@ class LineartAnimeProcessor: np_image = pil_to_np(input_image) np_image = normalize_image_channel_count(np_image) - np_image = fit_image_to_resolution(np_image, detect_resolution) + np_image = resize_image_to_resolution(np_image, detect_resolution) H, W, C = np_image.shape Hn = 256 * int(np.ceil(float(H) / 256.0)) @@ -194,7 +194,7 @@ class LineartAnimeProcessor: detected_map = normalize_image_channel_count(detected_map) - img = fit_image_to_resolution(np_image, image_resolution) + img = resize_image_to_resolution(np_image, image_resolution) H, W, C = img.shape detected_map = cv2.resize(detected_map, (W, H), interpolation=cv2.INTER_LINEAR) diff --git a/invokeai/backend/image_util/util.py b/invokeai/backend/image_util/util.py index 6a403efe55..7cfe0ad1a5 100644 --- a/invokeai/backend/image_util/util.py +++ b/invokeai/backend/image_util/util.py @@ -128,7 +128,7 @@ def normalize_image_channel_count(image: np.ndarray) -> np.ndarray: raise ValueError("Invalid number of channels.") -def fit_image_to_resolution(input_image: np.ndarray, resolution: int) -> np.ndarray: +def resize_image_to_resolution(input_image: np.ndarray, resolution: int) -> np.ndarray: """Resizes an image, fitting it to the given resolution. Adapted from https://github.com/huggingface/controlnet_aux (Apache-2.0 license).