From 52a5f1f56fcf40b5a867bc79a21dbcac601a898f Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Thu, 31 Aug 2023 22:50:53 -0400 Subject: [PATCH 1/7] prevent from trying to set vram on macs --- .../backend/install/invokeai_configure.py | 3 +- .../diffusion/cross_attention_control.py | 2 +- .../diffusion/shared_invokeai_diffusion.py | 20 ++++-- .../image_degradation/bsrgan.py | 4 +- .../image_degradation/bsrgan_light.py | 4 +- .../image_degradation/utils_image.py | 72 ++++++++----------- .../training/textual_inversion_training.py | 5 +- invokeai/backend/util/mps_fixes.py | 2 +- invokeai/backend/util/util.py | 2 +- 9 files changed, 59 insertions(+), 55 deletions(-) diff --git a/invokeai/backend/install/invokeai_configure.py b/invokeai/backend/install/invokeai_configure.py index 90298ce076..077ac2f92a 100755 --- a/invokeai/backend/install/invokeai_configure.py +++ b/invokeai/backend/install/invokeai_configure.py @@ -594,7 +594,8 @@ https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/blob/main/LICENS "vram", "outdir", ]: - setattr(new_opts, attr, getattr(self, attr).value) + if hasattr(self, attr): + setattr(new_opts, attr, getattr(self, attr).value) for attr in self.autoimport_dirs: directory = Path(self.autoimport_dirs[attr].value) diff --git a/invokeai/backend/stable_diffusion/diffusion/cross_attention_control.py b/invokeai/backend/stable_diffusion/diffusion/cross_attention_control.py index 334837a273..35d4800859 100644 --- a/invokeai/backend/stable_diffusion/diffusion/cross_attention_control.py +++ b/invokeai/backend/stable_diffusion/diffusion/cross_attention_control.py @@ -265,7 +265,7 @@ class InvokeAICrossAttentionMixin: if q.shape[1] <= 4096: # (512x512) max q.shape[1]: 4096 return self.einsum_lowest_level(q, k, v, None, None, None) else: - slice_size = math.floor(2 ** 30 / (q.shape[0] * q.shape[1])) + slice_size = math.floor(2**30 / (q.shape[0] * q.shape[1])) return self.einsum_op_slice_dim1(q, k, v, slice_size) def einsum_op_mps_v2(self, q, k, v): diff --git a/invokeai/backend/stable_diffusion/diffusion/shared_invokeai_diffusion.py b/invokeai/backend/stable_diffusion/diffusion/shared_invokeai_diffusion.py index 331b42c047..f05adafca2 100644 --- a/invokeai/backend/stable_diffusion/diffusion/shared_invokeai_diffusion.py +++ b/invokeai/backend/stable_diffusion/diffusion/shared_invokeai_diffusion.py @@ -215,7 +215,10 @@ class InvokeAIDiffuserComponent: dim=0, ), } - (encoder_hidden_states, encoder_attention_mask,) = self._concat_conditionings_for_batch( + ( + encoder_hidden_states, + encoder_attention_mask, + ) = self._concat_conditionings_for_batch( conditioning_data.unconditioned_embeddings.embeds, conditioning_data.text_embeddings.embeds, ) @@ -277,7 +280,10 @@ class InvokeAIDiffuserComponent: wants_cross_attention_control = len(cross_attention_control_types_to_do) > 0 if wants_cross_attention_control: - (unconditioned_next_x, conditioned_next_x,) = self._apply_cross_attention_controlled_conditioning( + ( + unconditioned_next_x, + conditioned_next_x, + ) = self._apply_cross_attention_controlled_conditioning( sample, timestep, conditioning_data, @@ -285,7 +291,10 @@ class InvokeAIDiffuserComponent: **kwargs, ) elif self.sequential_guidance: - (unconditioned_next_x, conditioned_next_x,) = self._apply_standard_conditioning_sequentially( + ( + unconditioned_next_x, + conditioned_next_x, + ) = self._apply_standard_conditioning_sequentially( sample, timestep, conditioning_data, @@ -293,7 +302,10 @@ class InvokeAIDiffuserComponent: ) else: - (unconditioned_next_x, conditioned_next_x,) = self._apply_standard_conditioning( + ( + unconditioned_next_x, + conditioned_next_x, + ) = self._apply_standard_conditioning( sample, timestep, conditioning_data, diff --git a/invokeai/backend/stable_diffusion/image_degradation/bsrgan.py b/invokeai/backend/stable_diffusion/image_degradation/bsrgan.py index 2a2edc92bd..e4d614207b 100644 --- a/invokeai/backend/stable_diffusion/image_degradation/bsrgan.py +++ b/invokeai/backend/stable_diffusion/image_degradation/bsrgan.py @@ -395,7 +395,7 @@ def add_Gaussian_noise(img, noise_level1=2, noise_level2=25): D = np.diag(np.random.rand(3)) U = orth(np.random.rand(3, 3)) conv = np.dot(np.dot(np.transpose(U), D), U) - img = img + np.random.multivariate_normal([0, 0, 0], np.abs(L ** 2 * conv), img.shape[:2]).astype(np.float32) + img = img + np.random.multivariate_normal([0, 0, 0], np.abs(L**2 * conv), img.shape[:2]).astype(np.float32) img = np.clip(img, 0.0, 1.0) return img @@ -413,7 +413,7 @@ def add_speckle_noise(img, noise_level1=2, noise_level2=25): D = np.diag(np.random.rand(3)) U = orth(np.random.rand(3, 3)) conv = np.dot(np.dot(np.transpose(U), D), U) - img += img * np.random.multivariate_normal([0, 0, 0], np.abs(L ** 2 * conv), img.shape[:2]).astype(np.float32) + img += img * np.random.multivariate_normal([0, 0, 0], np.abs(L**2 * conv), img.shape[:2]).astype(np.float32) img = np.clip(img, 0.0, 1.0) return img diff --git a/invokeai/backend/stable_diffusion/image_degradation/bsrgan_light.py b/invokeai/backend/stable_diffusion/image_degradation/bsrgan_light.py index 6c516c8101..cd74adc519 100644 --- a/invokeai/backend/stable_diffusion/image_degradation/bsrgan_light.py +++ b/invokeai/backend/stable_diffusion/image_degradation/bsrgan_light.py @@ -399,7 +399,7 @@ def add_Gaussian_noise(img, noise_level1=2, noise_level2=25): D = np.diag(np.random.rand(3)) U = orth(np.random.rand(3, 3)) conv = np.dot(np.dot(np.transpose(U), D), U) - img = img + np.random.multivariate_normal([0, 0, 0], np.abs(L ** 2 * conv), img.shape[:2]).astype(np.float32) + img = img + np.random.multivariate_normal([0, 0, 0], np.abs(L**2 * conv), img.shape[:2]).astype(np.float32) img = np.clip(img, 0.0, 1.0) return img @@ -417,7 +417,7 @@ def add_speckle_noise(img, noise_level1=2, noise_level2=25): D = np.diag(np.random.rand(3)) U = orth(np.random.rand(3, 3)) conv = np.dot(np.dot(np.transpose(U), D), U) - img += img * np.random.multivariate_normal([0, 0, 0], np.abs(L ** 2 * conv), img.shape[:2]).astype(np.float32) + img += img * np.random.multivariate_normal([0, 0, 0], np.abs(L**2 * conv), img.shape[:2]).astype(np.float32) img = np.clip(img, 0.0, 1.0) return img diff --git a/invokeai/backend/stable_diffusion/image_degradation/utils_image.py b/invokeai/backend/stable_diffusion/image_degradation/utils_image.py index 11df5c5710..2a0773c3ed 100644 --- a/invokeai/backend/stable_diffusion/image_degradation/utils_image.py +++ b/invokeai/backend/stable_diffusion/image_degradation/utils_image.py @@ -562,18 +562,14 @@ def rgb2ycbcr(img, only_y=True): if only_y: rlt = np.dot(img, [65.481, 128.553, 24.966]) / 255.0 + 16.0 else: - rlt = ( - np.matmul( - img, - [ - [65.481, -37.797, 112.0], - [128.553, -74.203, -93.786], - [24.966, 112.0, -18.214], - ], - ) - / 255.0 - + [16, 128, 128] - ) + rlt = np.matmul( + img, + [ + [65.481, -37.797, 112.0], + [128.553, -74.203, -93.786], + [24.966, 112.0, -18.214], + ], + ) / 255.0 + [16, 128, 128] if in_img_type == np.uint8: rlt = rlt.round() else: @@ -592,18 +588,14 @@ def ycbcr2rgb(img): if in_img_type != np.uint8: img *= 255.0 # convert - rlt = ( - np.matmul( - img, - [ - [0.00456621, 0.00456621, 0.00456621], - [0, -0.00153632, 0.00791071], - [0.00625893, -0.00318811, 0], - ], - ) - * 255.0 - + [-222.921, 135.576, -276.836] - ) + rlt = np.matmul( + img, + [ + [0.00456621, 0.00456621, 0.00456621], + [0, -0.00153632, 0.00791071], + [0.00625893, -0.00318811, 0], + ], + ) * 255.0 + [-222.921, 135.576, -276.836] if in_img_type == np.uint8: rlt = rlt.round() else: @@ -626,18 +618,14 @@ def bgr2ycbcr(img, only_y=True): if only_y: rlt = np.dot(img, [24.966, 128.553, 65.481]) / 255.0 + 16.0 else: - rlt = ( - np.matmul( - img, - [ - [24.966, 112.0, -18.214], - [128.553, -74.203, -93.786], - [65.481, -37.797, 112.0], - ], - ) - / 255.0 - + [16, 128, 128] - ) + rlt = np.matmul( + img, + [ + [24.966, 112.0, -18.214], + [128.553, -74.203, -93.786], + [65.481, -37.797, 112.0], + ], + ) / 255.0 + [16, 128, 128] if in_img_type == np.uint8: rlt = rlt.round() else: @@ -728,11 +716,11 @@ def ssim(img1, img2): mu1 = cv2.filter2D(img1, -1, window)[5:-5, 5:-5] # valid mu2 = cv2.filter2D(img2, -1, window)[5:-5, 5:-5] - mu1_sq = mu1 ** 2 - mu2_sq = mu2 ** 2 + mu1_sq = mu1**2 + mu2_sq = mu2**2 mu1_mu2 = mu1 * mu2 - sigma1_sq = cv2.filter2D(img1 ** 2, -1, window)[5:-5, 5:-5] - mu1_sq - sigma2_sq = cv2.filter2D(img2 ** 2, -1, window)[5:-5, 5:-5] - mu2_sq + sigma1_sq = cv2.filter2D(img1**2, -1, window)[5:-5, 5:-5] - mu1_sq + sigma2_sq = cv2.filter2D(img2**2, -1, window)[5:-5, 5:-5] - mu2_sq sigma12 = cv2.filter2D(img1 * img2, -1, window)[5:-5, 5:-5] - mu1_mu2 ssim_map = ((2 * mu1_mu2 + C1) * (2 * sigma12 + C2)) / ((mu1_sq + mu2_sq + C1) * (sigma1_sq + sigma2_sq + C2)) @@ -749,8 +737,8 @@ def ssim(img1, img2): # matlab 'imresize' function, now only support 'bicubic' def cubic(x): absx = torch.abs(x) - absx2 = absx ** 2 - absx3 = absx ** 3 + absx2 = absx**2 + absx3 = absx**3 return (1.5 * absx3 - 2.5 * absx2 + 1) * ((absx <= 1).type_as(absx)) + ( -0.5 * absx3 + 2.5 * absx2 - 4 * absx + 2 ) * (((absx > 1) * (absx <= 2)).type_as(absx)) diff --git a/invokeai/backend/training/textual_inversion_training.py b/invokeai/backend/training/textual_inversion_training.py index 658db5e1d5..d92aa80b38 100644 --- a/invokeai/backend/training/textual_inversion_training.py +++ b/invokeai/backend/training/textual_inversion_training.py @@ -475,7 +475,10 @@ class TextualInversionDataset(Dataset): if self.center_crop: crop = min(img.shape[0], img.shape[1]) - (h, w,) = ( + ( + h, + w, + ) = ( img.shape[0], img.shape[1], ) diff --git a/invokeai/backend/util/mps_fixes.py b/invokeai/backend/util/mps_fixes.py index be465d7d9a..8a4e6baab5 100644 --- a/invokeai/backend/util/mps_fixes.py +++ b/invokeai/backend/util/mps_fixes.py @@ -203,7 +203,7 @@ class ChunkedSlicedAttnProcessor: if attn.upcast_attention: out_item_size = 4 - chunk_size = 2 ** 29 + chunk_size = 2**29 out_size = query.shape[1] * key.shape[1] * out_item_size chunks_count = min(query.shape[1], math.ceil((out_size - 1) / chunk_size)) diff --git a/invokeai/backend/util/util.py b/invokeai/backend/util/util.py index da0b9f6834..7ef9c72fb0 100644 --- a/invokeai/backend/util/util.py +++ b/invokeai/backend/util/util.py @@ -207,7 +207,7 @@ def parallel_data_prefetch( return gather_res -def rand_perlin_2d(shape, res, device, fade=lambda t: 6 * t ** 5 - 15 * t ** 4 + 10 * t ** 3): +def rand_perlin_2d(shape, res, device, fade=lambda t: 6 * t**5 - 15 * t**4 + 10 * t**3): delta = (res[0] / shape[0], res[1] / shape[1]) d = (shape[0] // res[0], shape[1] // res[1]) From 44b49c7f2d323759c80141f5f142ae64dd08a779 Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Thu, 31 Aug 2023 22:55:17 -0400 Subject: [PATCH 2/7] fixed true source of problem --- invokeai/backend/install/invokeai_configure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/invokeai/backend/install/invokeai_configure.py b/invokeai/backend/install/invokeai_configure.py index 077ac2f92a..8583ba9e0f 100755 --- a/invokeai/backend/install/invokeai_configure.py +++ b/invokeai/backend/install/invokeai_configure.py @@ -496,7 +496,7 @@ Use cursor arrows to make a checkbox selection, and space to toggle. scroll_exit=True, ) else: - self.vram_cache_size = DummyWidgetValue.zero + self.vram = DummyWidgetValue.zero self.nextrely += 1 self.outdir = self.add_widget_intelligent( FileBox, From 86185f2fe3c6a6847d17001fb11f962cb4f2ef13 Mon Sep 17 00:00:00 2001 From: blessedcoolant <54517381+blessedcoolant@users.noreply.github.com> Date: Tue, 5 Sep 2023 22:37:14 +1200 Subject: [PATCH 3/7] feat: Scaled Bounding Box Dimensions now respect Aspect Ratio --- .../src/features/canvas/store/canvasSlice.ts | 12 ++++++++ .../InfillAndScaling/ParamScaledHeight.tsx | 28 +++++++++++++++---- .../InfillAndScaling/ParamScaledWidth.tsx | 28 +++++++++++++++---- 3 files changed, 56 insertions(+), 12 deletions(-) diff --git a/invokeai/frontend/web/src/features/canvas/store/canvasSlice.ts b/invokeai/frontend/web/src/features/canvas/store/canvasSlice.ts index ca26a0567f..fb908fa601 100644 --- a/invokeai/frontend/web/src/features/canvas/store/canvasSlice.ts +++ b/invokeai/frontend/web/src/features/canvas/store/canvasSlice.ts @@ -235,10 +235,18 @@ export const canvasSlice = createSlice({ state.boundingBoxDimensions.width, state.boundingBoxDimensions.height, ]; + const [currScaledWidth, currScaledHeight] = [ + state.scaledBoundingBoxDimensions.width, + state.scaledBoundingBoxDimensions.height, + ]; state.boundingBoxDimensions = { width: currHeight, height: currWidth, }; + state.scaledBoundingBoxDimensions = { + width: currScaledHeight, + height: currScaledWidth, + }; }, setBoundingBoxCoordinates: (state, action: PayloadAction) => { state.boundingBoxCoordinates = floorCoordinates(action.payload); @@ -788,6 +796,10 @@ export const canvasSlice = createSlice({ state.boundingBoxDimensions.width / ratio, 64 ); + state.scaledBoundingBoxDimensions.height = roundToMultiple( + state.scaledBoundingBoxDimensions.width / ratio, + 64 + ); } }); }, diff --git a/invokeai/frontend/web/src/features/parameters/components/Parameters/Canvas/InfillAndScaling/ParamScaledHeight.tsx b/invokeai/frontend/web/src/features/parameters/components/Parameters/Canvas/InfillAndScaling/ParamScaledHeight.tsx index 7dae01bb91..26e3ce8eb6 100644 --- a/invokeai/frontend/web/src/features/parameters/components/Parameters/Canvas/InfillAndScaling/ParamScaledHeight.tsx +++ b/invokeai/frontend/web/src/features/parameters/components/Parameters/Canvas/InfillAndScaling/ParamScaledHeight.tsx @@ -2,6 +2,7 @@ import { createSelector } from '@reduxjs/toolkit'; import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; import { defaultSelectorOptions } from 'app/store/util/defaultMemoizeOptions'; import IAISlider from 'common/components/IAISlider'; +import { roundToMultiple } from 'common/util/roundDownToMultiple'; import { canvasSelector } from 'features/canvas/store/canvasSelectors'; import { setScaledBoundingBoxDimensions } from 'features/canvas/store/canvasSlice'; import { generationSelector } from 'features/parameters/store/generationSelectors'; @@ -12,12 +13,13 @@ const selector = createSelector( [generationSelector, canvasSelector], (generation, canvas) => { const { scaledBoundingBoxDimensions, boundingBoxScaleMethod } = canvas; - const { model } = generation; + const { model, aspectRatio } = generation; return { model, scaledBoundingBoxDimensions, isManual: boundingBoxScaleMethod === 'manual', + aspectRatio, }; }, defaultSelectorOptions @@ -25,7 +27,7 @@ const selector = createSelector( const ParamScaledHeight = () => { const dispatch = useAppDispatch(); - const { model, isManual, scaledBoundingBoxDimensions } = + const { model, isManual, scaledBoundingBoxDimensions, aspectRatio } = useAppSelector(selector); const initial = ['sdxl', 'sdxl-refiner'].includes(model?.base_model as string) @@ -35,19 +37,33 @@ const ParamScaledHeight = () => { const { t } = useTranslation(); const handleChangeScaledHeight = (v: number) => { + let newWidth = scaledBoundingBoxDimensions.width; + const newHeight = Math.floor(v); + + if (aspectRatio) { + newWidth = roundToMultiple(newHeight * aspectRatio, 8); + } + dispatch( setScaledBoundingBoxDimensions({ - ...scaledBoundingBoxDimensions, - height: Math.floor(v), + width: newWidth, + height: newHeight, }) ); }; const handleResetScaledHeight = () => { + let resetWidth = scaledBoundingBoxDimensions.width; + const resetHeight = Math.floor(initial); + + if (aspectRatio) { + resetWidth = roundToMultiple(resetHeight * aspectRatio, 8); + } + dispatch( setScaledBoundingBoxDimensions({ - ...scaledBoundingBoxDimensions, - height: Math.floor(initial), + width: resetWidth, + height: resetHeight, }) ); }; diff --git a/invokeai/frontend/web/src/features/parameters/components/Parameters/Canvas/InfillAndScaling/ParamScaledWidth.tsx b/invokeai/frontend/web/src/features/parameters/components/Parameters/Canvas/InfillAndScaling/ParamScaledWidth.tsx index 0eda5a122c..d869d98c80 100644 --- a/invokeai/frontend/web/src/features/parameters/components/Parameters/Canvas/InfillAndScaling/ParamScaledWidth.tsx +++ b/invokeai/frontend/web/src/features/parameters/components/Parameters/Canvas/InfillAndScaling/ParamScaledWidth.tsx @@ -2,6 +2,7 @@ import { createSelector } from '@reduxjs/toolkit'; import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; import { defaultSelectorOptions } from 'app/store/util/defaultMemoizeOptions'; import IAISlider from 'common/components/IAISlider'; +import { roundToMultiple } from 'common/util/roundDownToMultiple'; import { canvasSelector } from 'features/canvas/store/canvasSelectors'; import { setScaledBoundingBoxDimensions } from 'features/canvas/store/canvasSlice'; import { generationSelector } from 'features/parameters/store/generationSelectors'; @@ -12,11 +13,12 @@ const selector = createSelector( [canvasSelector, generationSelector], (canvas, generation) => { const { boundingBoxScaleMethod, scaledBoundingBoxDimensions } = canvas; - const { model } = generation; + const { model, aspectRatio } = generation; return { model, scaledBoundingBoxDimensions, + aspectRatio, isManual: boundingBoxScaleMethod === 'manual', }; }, @@ -25,7 +27,7 @@ const selector = createSelector( const ParamScaledWidth = () => { const dispatch = useAppDispatch(); - const { model, isManual, scaledBoundingBoxDimensions } = + const { model, isManual, scaledBoundingBoxDimensions, aspectRatio } = useAppSelector(selector); const initial = ['sdxl', 'sdxl-refiner'].includes(model?.base_model as string) @@ -35,19 +37,33 @@ const ParamScaledWidth = () => { const { t } = useTranslation(); const handleChangeScaledWidth = (v: number) => { + const newWidth = Math.floor(v); + let newHeight = scaledBoundingBoxDimensions.height; + + if (aspectRatio) { + newHeight = roundToMultiple(newWidth / aspectRatio, 8); + } + dispatch( setScaledBoundingBoxDimensions({ - ...scaledBoundingBoxDimensions, - width: Math.floor(v), + width: newWidth, + height: newHeight, }) ); }; const handleResetScaledWidth = () => { + const resetWidth = Math.floor(initial); + let resetHeight = scaledBoundingBoxDimensions.height; + + if (aspectRatio) { + resetHeight = roundToMultiple(resetWidth / aspectRatio, 8); + } + dispatch( setScaledBoundingBoxDimensions({ - ...scaledBoundingBoxDimensions, - width: Math.floor(initial), + width: resetWidth, + height: resetHeight, }) ); }; From 9caa2a20439452736e7d6561a30e258f3519aa90 Mon Sep 17 00:00:00 2001 From: blessedcoolant <54517381+blessedcoolant@users.noreply.github.com> Date: Tue, 5 Sep 2023 22:59:37 +1200 Subject: [PATCH 4/7] fix: Set scaled steps to be at 64 to be in sync with the rest of the canvas --- .../Parameters/Canvas/InfillAndScaling/ParamScaledHeight.tsx | 4 ++-- .../Parameters/Canvas/InfillAndScaling/ParamScaledWidth.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/invokeai/frontend/web/src/features/parameters/components/Parameters/Canvas/InfillAndScaling/ParamScaledHeight.tsx b/invokeai/frontend/web/src/features/parameters/components/Parameters/Canvas/InfillAndScaling/ParamScaledHeight.tsx index 26e3ce8eb6..6d0ac52b2f 100644 --- a/invokeai/frontend/web/src/features/parameters/components/Parameters/Canvas/InfillAndScaling/ParamScaledHeight.tsx +++ b/invokeai/frontend/web/src/features/parameters/components/Parameters/Canvas/InfillAndScaling/ParamScaledHeight.tsx @@ -41,7 +41,7 @@ const ParamScaledHeight = () => { const newHeight = Math.floor(v); if (aspectRatio) { - newWidth = roundToMultiple(newHeight * aspectRatio, 8); + newWidth = roundToMultiple(newHeight * aspectRatio, 64); } dispatch( @@ -57,7 +57,7 @@ const ParamScaledHeight = () => { const resetHeight = Math.floor(initial); if (aspectRatio) { - resetWidth = roundToMultiple(resetHeight * aspectRatio, 8); + resetWidth = roundToMultiple(resetHeight * aspectRatio, 64); } dispatch( diff --git a/invokeai/frontend/web/src/features/parameters/components/Parameters/Canvas/InfillAndScaling/ParamScaledWidth.tsx b/invokeai/frontend/web/src/features/parameters/components/Parameters/Canvas/InfillAndScaling/ParamScaledWidth.tsx index d869d98c80..71a8615d74 100644 --- a/invokeai/frontend/web/src/features/parameters/components/Parameters/Canvas/InfillAndScaling/ParamScaledWidth.tsx +++ b/invokeai/frontend/web/src/features/parameters/components/Parameters/Canvas/InfillAndScaling/ParamScaledWidth.tsx @@ -41,7 +41,7 @@ const ParamScaledWidth = () => { let newHeight = scaledBoundingBoxDimensions.height; if (aspectRatio) { - newHeight = roundToMultiple(newWidth / aspectRatio, 8); + newHeight = roundToMultiple(newWidth / aspectRatio, 64); } dispatch( @@ -57,7 +57,7 @@ const ParamScaledWidth = () => { let resetHeight = scaledBoundingBoxDimensions.height; if (aspectRatio) { - resetHeight = roundToMultiple(resetWidth / aspectRatio, 8); + resetHeight = roundToMultiple(resetWidth / aspectRatio, 64); } dispatch( From 500f3046a9ae72ade91af0b2d0ac8f41926f7d10 Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Tue, 5 Sep 2023 07:50:12 -0400 Subject: [PATCH 5/7] remove choice to update from main and add a warning about tags & branches --- invokeai/frontend/install/invokeai_update.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/invokeai/frontend/install/invokeai_update.py b/invokeai/frontend/install/invokeai_update.py index 3fe9bb6f97..45a0e8ec0a 100644 --- a/invokeai/frontend/install/invokeai_update.py +++ b/invokeai/frontend/install/invokeai_update.py @@ -54,13 +54,15 @@ def welcome(versions: dict): def text(): yield f"InvokeAI Version: [bold yellow]{__version__}" yield "" - yield "This script will update InvokeAI to the latest release, or to a development version of your choice." + yield "This script will update InvokeAI to the latest release, or to the development version of your choice." + yield "" + yield "When updating to an arbitrary tag or branch, be aware that the front end may be mismatched to the backend," + yield "making the web frontend unusable. Please downgrade to the latest release if this happens." yield "" yield "[bold yellow]Options:" yield f"""[1] Update to the latest official release ([italic]{versions[0]['tag_name']}[/italic]) -[2] Update to the bleeding-edge development version ([italic]main[/italic]) -[3] Manually enter the [bold]tag name[/bold] for the version you wish to update to -[4] Manually enter the [bold]branch name[/bold] for the version you wish to update to""" +[2] Manually enter the [bold]tag name[/bold] for the version you wish to update to +[3] Manually enter the [bold]branch name[/bold] for the version you wish to update to""" console.rule() print( @@ -104,11 +106,11 @@ def main(): if choice == "1": release = versions[0]["tag_name"] elif choice == "2": - release = "main" + while not tag: + tag = Prompt.ask("Enter an InvokeAI tag name") elif choice == "3": - tag = Prompt.ask("Enter an InvokeAI tag name") - elif choice == "4": - branch = Prompt.ask("Enter an InvokeAI branch name") + while not branch: + branch = Prompt.ask("Enter an InvokeAI branch name") extras = get_extras() From 9c290f45755270b436f5ec1d284590300b749464 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Tue, 5 Sep 2023 23:46:20 +1000 Subject: [PATCH 6/7] fix(nodes): add version to iterate and collect --- invokeai/app/services/graph.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/invokeai/app/services/graph.py b/invokeai/app/services/graph.py index 0e40636280..c47d437956 100644 --- a/invokeai/app/services/graph.py +++ b/invokeai/app/services/graph.py @@ -182,7 +182,7 @@ class IterateInvocationOutput(BaseInvocationOutput): # TODO: Fill this out and move to invocations -@invocation("iterate") +@invocation("iterate", version="1.0.0") class IterateInvocation(BaseInvocation): """Iterates over a list of items""" @@ -203,7 +203,7 @@ class CollectInvocationOutput(BaseInvocationOutput): ) -@invocation("collect") +@invocation("collect", version="1.0.0") class CollectInvocation(BaseInvocation): """Collects values into a collection""" From 0a1c5bea05b66786d7ce116b4d8a33ef67a890ac Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Wed, 6 Sep 2023 00:01:26 +1000 Subject: [PATCH 7/7] fix(ui): do not assign empty string to version if undefined this causes zod to fail when building workflows --- invokeai/frontend/web/src/features/nodes/util/parseSchema.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/invokeai/frontend/web/src/features/nodes/util/parseSchema.ts b/invokeai/frontend/web/src/features/nodes/util/parseSchema.ts index d8bb189abc..553d0770aa 100644 --- a/invokeai/frontend/web/src/features/nodes/util/parseSchema.ts +++ b/invokeai/frontend/web/src/features/nodes/util/parseSchema.ts @@ -73,7 +73,7 @@ export const parseSchema = ( const title = schema.title.replace('Invocation', ''); const tags = schema.tags ?? []; const description = schema.description ?? ''; - const version = schema.version ?? ''; + const version = schema.version; const inputs = reduce( schema.properties,