Skip to content

Commit

Permalink
Revert "fix for a1111 pr 15423" (#515)
Browse files Browse the repository at this point in the history
* Revert "fix for a1111 pr 15423 (#501)"

This reverts commit 85a854b.

* i

* doc

* doc
  • Loading branch information
continue-revolution authored Apr 23, 2024
1 parent 856fc0e commit 44d2f99
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 12 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions motion_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions scripts/animatediff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand All @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/animatediff_infv2v.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions scripts/animatediff_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 44d2f99

Please sign in to comment.