From 47c1794050eef3a4da12cd1c2521c5f1206edd3f Mon Sep 17 00:00:00 2001 From: zhang <461799796@qq.com> Date: Tue, 12 Dec 2023 20:41:10 +0800 Subject: [PATCH] fix the white result --- libs/magicanimate/pipelines/pipeline_animation.py | 4 ++-- nodes.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/libs/magicanimate/pipelines/pipeline_animation.py b/libs/magicanimate/pipelines/pipeline_animation.py index c3b0ac6..e5792be 100644 --- a/libs/magicanimate/pipelines/pipeline_animation.py +++ b/libs/magicanimate/pipelines/pipeline_animation.py @@ -353,7 +353,7 @@ class AnimationPipeline(DiffusionPipeline): def prepare_condition(self, condition, num_videos_per_prompt, device, dtype, do_classifier_free_guidance): # prepare conditions for controlnet - condition = torch.from_numpy(condition.copy()).to(device=device, dtype=dtype) #/ 255.0 + condition = torch.from_numpy(condition.copy()).to(device=device, dtype=dtype) / 255.0 condition = torch.stack([condition for _ in range(num_videos_per_prompt)], dim=0) condition = rearrange(condition, 'b f h w c -> (b f) c h w').clone() if do_classifier_free_guidance: @@ -389,7 +389,7 @@ class AnimationPipeline(DiffusionPipeline): Convert RGB image to VAE latents """ device = self._execution_device - images = torch.from_numpy(images).float().to(dtype) # / 127.5 - 1 + images = torch.from_numpy(images).float().to(dtype) / 127.5 - 1 images = rearrange(images, "f h w c -> f c h w").to(device) latents = [] for frame_idx in range(images.shape[0]): diff --git a/nodes.py b/nodes.py index eb0512d..d8029b9 100644 --- a/nodes.py +++ b/nodes.py @@ -231,7 +231,8 @@ class MagicAnimate: image = self.resize_image_frame(image, size) # print(image.shape) H, W, C = image.shape - + + image = image * 255 prompt = "" n_prompt = "" control = pose_video.detach().cpu().numpy() # (num_frames, H, W, C) @@ -246,7 +247,7 @@ class MagicAnimate: original_length = control.shape[0] if control.shape[0] % config.L > 0: control = np.pad(control, ((0, config.L-control.shape[0] % config.L), (0, 0), (0, 0), (0, 0)), mode='edge') - + control = control * 255 self.generator.manual_seed(seed) dist_kwargs = {"rank":0, "world_size":1, "dist":False}