diff --git a/extensions-builtin/forge_preprocessor_marigold/scripts/preprocessor_marigold.py b/extensions-builtin/forge_preprocessor_marigold/scripts/preprocessor_marigold.py index 9f372e1d..6add9b5c 100644 --- a/extensions-builtin/forge_preprocessor_marigold/scripts/preprocessor_marigold.py +++ b/extensions-builtin/forge_preprocessor_marigold/scripts/preprocessor_marigold.py @@ -55,7 +55,11 @@ class PreprocessorMarigold(Preprocessor): self.load_model() - model_management.load_models_gpu([self.diffusers_patcher.patcher]) + H, W, C = input_image.shape + + self.diffusers_patcher.prepare_memory_before_sampling( + batchsize=1, latent_width=W // 8, latent_height=H // 8 + ) with torch.no_grad(): img = numpy_to_pytorch(input_image).movedim(-1, 1).to( @@ -63,8 +67,8 @@ class PreprocessorMarigold(Preprocessor): dtype=self.diffusers_patcher.dtype) img = img * 2.0 - 1.0 - depth = self.diffusers_patcher.patcher.model(img, num_inference_steps=20, show_pbar=False) - depth = depth * 0.5 + 0.5 + depth = self.diffusers_patcher.pipeline(img, num_inference_steps=20, show_pbar=False) + depth = 0.5 - depth * 0.5 depth = depth.movedim(1, -1)[0].cpu().numpy() depth_image = HWC3((depth * 255.0).clip(0, 255).astype(np.uint8)) diff --git a/modules_forge/diffusers_patcher.py b/modules_forge/diffusers_patcher.py index 531ed8d0..1cd2ff49 100644 --- a/modules_forge/diffusers_patcher.py +++ b/modules_forge/diffusers_patcher.py @@ -43,6 +43,6 @@ class DiffusersModelPatcher: area = 2 * batchsize * latent_width * latent_height inference_memory = (((area * 0.6) / 0.9) + 1024) * (1024 * 1024) model_management.load_models_gpu( - models=[self.pipeline], + models=[self.patcher], memory_required=inference_memory )