From 44d2f992ba495fd428b8be37bdfea0b5b62cc718 Mon Sep 17 00:00:00 2001 From: continue revolution Date: Tue, 23 Apr 2024 02:06:30 -0500 Subject: [PATCH] Revert "fix for a1111 pr 15423" (#515) * Revert "fix for a1111 pr 15423 (#501)" This reverts commit 85a854b4389ac98ac1e33adc95eba42e7d39696d. * i * doc * doc --- README.md | 5 +++-- motion_module.py | 4 ++-- scripts/animatediff.py | 6 ++---- scripts/animatediff_infv2v.py | 2 +- scripts/animatediff_ui.py | 4 +--- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 79a98a0a..83559358 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ # AnimateDiff for Stable Diffusion WebUI + +> It seems that WebUI v1.9.0 has some major mess-up. Please do not use this WebUI version. You can use either v1.8.0 or v1.9.3 (latest). + This extension aim for integrating [AnimateDiff](https://github.com/guoyww/AnimateDiff/) with [CLI](https://github.com/s9roll7/animatediff-cli-prompt-travel) into [AUTOMATIC1111 Stable Diffusion WebUI](https://github.com/AUTOMATIC1111/stable-diffusion-webui) with [ControlNet](https://github.com/Mikubill/sd-webui-controlnet), and form the most easy-to-use AI video toolkit. You can generate GIFs in exactly the same way as generating images after enabling this extension. This extension implements AnimateDiff in a different way. It inserts motion modules into UNet at runtime, so that you do not need to reload your model weights if you don't want to. @@ -7,8 +10,6 @@ You might also be interested in another extension I created: [Segment Anything f [Forge](https://github.com/lllyasviel/stable-diffusion-webui-forge) users should either checkout branch [forge/master](https://github.com/continue-revolution/sd-webui-animatediff/tree/forge/master) in this repository or use [sd-forge-animatediff](https://github.com/continue-revolution/sd-forge-animatediff). They will be in sync. -[TusiArt](https://tusiart.com/) (for users inside P.R.China mainland) and [TensorArt](https://tensor.art/) (for others) offers online service of this extension. - ## Table of Contents [Update](#update) | [Future Plan](#future-plan) | [Model Zoo](#model-zoo) | [Documentation](#documentation) | [Tutorial](#tutorial) | [Thanks](#thanks) | [Star History](#star-history) | [Sponsor](#sponsor) diff --git a/motion_module.py b/motion_module.py index f17ff697..4fffd52c 100644 --- a/motion_module.py +++ b/motion_module.py @@ -330,8 +330,8 @@ def __init__( def forward(self, x: torch.Tensor): - from scripts import animatediff_mm - video_length = animatediff_mm.mm_animatediff.ad_params.batch_size + from scripts.animatediff_mm import mm_animatediff + video_length = mm_animatediff.ad_params.batch_size d = x.shape[1] x = rearrange(x, "(b f) d c -> (b d) f c", f=video_length) diff --git a/scripts/animatediff.py b/scripts/animatediff.py index 6d996011..0764e0db 100644 --- a/scripts/animatediff.py +++ b/scripts/animatediff.py @@ -10,6 +10,7 @@ from scripts.animatediff_infv2v import AnimateDiffInfV2V from scripts.animatediff_latent import AnimateDiffI2VLatent from scripts.animatediff_logger import logger_animatediff as logger +from scripts.animatediff_mm import mm_animatediff as motion_module from scripts.animatediff_prompt import AnimateDiffPromptSchedule from scripts.animatediff_output import AnimateDiffOutput from scripts.animatediff_xyz import patch_xyz, xyz_attrs @@ -21,6 +22,7 @@ from scripts.animatediff_freeinit import AnimateDiffFreeInit script_dir = scripts.basedir() +motion_module.set_script_dir(script_dir) class AnimateDiffScript(scripts.Script): @@ -40,8 +42,6 @@ def show(self, is_img2img): def ui(self, is_img2img): - from scripts.animatediff_mm import mm_animatediff as motion_module - motion_module.set_script_dir(script_dir) unit = AnimateDiffUiGroup().render( is_img2img, self.infotext_fields, @@ -53,7 +53,6 @@ def ui(self, is_img2img): def before_process(self, p: StableDiffusionProcessing, params: AnimateDiffProcess): if p.is_api: params = get_animatediff_arg(p) - from scripts.animatediff_mm import mm_animatediff as motion_module motion_module.set_ad_params(params) # apply XYZ settings @@ -92,7 +91,6 @@ def postprocess_image(self, p: StableDiffusionProcessing, pp: PostprocessImageAr def postprocess(self, p: StableDiffusionProcessing, res: Processed, params: AnimateDiffProcess): if params.enable: - from scripts.animatediff_mm import mm_animatediff as motion_module params.prompt_scheduler.save_infotext_txt(res) motion_module.restore(p.sd_model) self.hacked = False diff --git a/scripts/animatediff_infv2v.py b/scripts/animatediff_infv2v.py index ac693869..5c10c523 100644 --- a/scripts/animatediff_infv2v.py +++ b/scripts/animatediff_infv2v.py @@ -7,6 +7,7 @@ from modules import devices, shared from modules.script_callbacks import CFGDenoiserParams from scripts.animatediff_logger import logger_animatediff as logger +from scripts.animatediff_mm import mm_animatediff as motion_module class AnimateDiffInfV2V: @@ -78,7 +79,6 @@ def get_unsorted_index(lst): @staticmethod def animatediff_on_cfg_denoiser(cfg_params: CFGDenoiserParams): - from scripts.animatediff_mm import mm_animatediff as motion_module ad_params = motion_module.ad_params if ad_params is None or not ad_params.enable: return diff --git a/scripts/animatediff_ui.py b/scripts/animatediff_ui.py index 2d51320d..01001121 100644 --- a/scripts/animatediff_ui.py +++ b/scripts/animatediff_ui.py @@ -9,6 +9,7 @@ from modules.launch_utils import git from modules.processing import StableDiffusionProcessing, StableDiffusionProcessingImg2Img +from scripts.animatediff_mm import mm_animatediff as motion_module from scripts.animatediff_xyz import xyz_attrs from scripts.animatediff_logger import logger_animatediff as logger from scripts.animatediff_utils import get_controlnet_units, extract_frames_from_video @@ -95,7 +96,6 @@ def get_list(self, is_img2img: bool): def get_dict(self, is_img2img: bool): - from scripts.animatediff_mm import mm_animatediff as motion_module infotext = { "model": self.model, "video_length": self.video_length, @@ -254,7 +254,6 @@ def __init__(self): def get_model_list(self): - from scripts.animatediff_mm import mm_animatediff as motion_module model_dir = motion_module.get_model_dir() if not os.path.isdir(model_dir): os.mkdir(model_dir) @@ -490,7 +489,6 @@ def update_frames(video_source): with gr.Row(): unload = gr.Button(value="Move motion module to CPU (default if lowvram)") remove = gr.Button(value="Remove motion module from any memory") - from scripts.animatediff_mm import mm_animatediff as motion_module unload.click(fn=motion_module.unload) remove.click(fn=motion_module.remove)