v1.13.1 (#403)
* fix mp4 encoding error (#402)
* Support infotext paste (#400)
* Add support for pasting infotext
* Fix names for params in img2img infotext
* move setup of paste fields into render(), revert infotext field names back to variable names
* Revert "move setup of paste fields into render(), revert infotext field names back to variable names"
This reverts commit ea062abcbc.
* revert infotext field names back to variable names
* move setup of paste fields into render()
* refactor getting param names into a function
* style fixes
* validate prompt travel frame numbers (#401)
Co-authored-by: zappityzap <you@example.com>
* 1.13.1
---------
Co-authored-by: hkz <hkunzhe24@gmail.com>
Co-authored-by: zappityzap <128872140+zappityzap@users.noreply.github.com>
Co-authored-by: zappityzap <you@example.com>
pull/404/head
parent
55ecff3656
commit
e9db9f287e
|
|
@ -64,9 +64,10 @@ You might also be interested in another extension I created: [Segment Anything f
|
|||
- `2023/11/06`: [v1.11.1](https://github.com/continue-revolution/sd-webui-animatediff/releases/tag/v1.11.1): Optimize VRAM for ControlNet V2V, patch [encode_pil_to_base64](https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/master/modules/api/api.py#L104-L133) for api return a video, save frames to `AnimateDiff/yy-mm-dd/`, recover from assertion error, optional [request id](#api) for API.
|
||||
- `2023/11/10`: [v1.12.0](https://github.com/continue-revolution/sd-webui-animatediff/releases/tag/v1.12.0): [AnimateDiff for SDXL](https://github.com/guoyww/AnimateDiff/tree/sdxl) supported. See [SDXL](#sdxl) for more information.
|
||||
- `2023/11/16`: [v1.12.1](https://github.com/continue-revolution/sd-webui-animatediff/releases/tag/v1.12.1): FP8 precision and LCM sampler supported. See [Optimizations](#optimizations) for more information. You can also optionally upload videos to AWS S3 storage by configuring appropriately via `Settings/AnimateDiff AWS`.
|
||||
- `2023/12/19`: [v1.13.0](https://github.com/continue-revolution/sd-webui-animatediff/releases/tag/v1.13.0): [AnimateDiff V3](https://github.com/guoyww/AnimateDiff?tab=readme-ov-file#202312-animatediff-v3-and-sparsectrl) supported. See [V3](#v3) for more information. Also: release all official models in fp16 & safetensors format [here](https://huggingface.co/conrevo/AnimateDiff-A1111/tree/main), add option to disable LCM sampler in `Settings/AnimateDiff`, remove patch [encode_pil_to_base64](https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/master/modules/api/api.py#L104-L133) because A1111 [v1.7.0](https://github.com/AUTOMATIC1111/stable-diffusion-webui/tree/v1.7.0) now supports video return for API.
|
||||
- `2023/12/19`: [v1.13.0](https://github.com/continue-revolution/sd-webui-animatediff/releases/tag/v1.13.0): [AnimateDiff V3](https://github.com/guoyww/AnimateDiff?tab=readme-ov-file#202312-animatediff-v3-and-sparsectrl) supported. See [V3](#v3) for more information. Also: release all official models in fp16 & safetensors format [here](https://huggingface.co/conrevo/AnimateDiff-A1111/tree/main), add option to disable LCM sampler in `Settings/AnimateDiff`, remove patch [encode_pil_to_base64](https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/master/modules/api/api.py#L104-L133) because A1111 [v1.7.0](https://github.com/AUTOMATIC1111/stable-diffusion-webui/tree/v1.7.0) now supports video return for API.
|
||||
- `2024/01/12`: [v1.13.1](https://github.com/continue-revolution/sd-webui-animatediff/releases/tag/v1.13.1): This small version update completely comes from the community. We fix mp4 encode error [#402](https://github.com/continue-revolution/sd-webui-animatediff/pull/402), support infotext copy-paste [#400](https://github.com/continue-revolution/sd-webui-animatediff/pull/400), validate prompt travel frame numbers [#401](https://github.com/continue-revolution/sd-webui-animatediff/pull/401).
|
||||
|
||||
For future update plan, please query [#366](https://github.com/continue-revolution/sd-webui-animatediff/pull/366). `v1.13.x` is the last version update for `v1`. SparseCtrl, Magic Animate and other control methods will be supported in `v2` via updating both this repo and sd-webui-controlnet.
|
||||
For `v2` update progress, please query [#381](https://github.com/continue-revolution/sd-webui-animatediff/pull/381). For updates (most likely) later than v2, please query [#366](https://github.com/continue-revolution/sd-webui-animatediff/pull/366). All update checklist is tentative and subject to change. `v1.13.x` is the last version update for `v1`. SparseCtrl, Magic Animate and other control methods will be supported in `v2` via updating both this repo and sd-webui-controlnet.
|
||||
|
||||
|
||||
## How to Use
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ 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_ui import AnimateDiffProcess, AnimateDiffUiGroup
|
||||
from scripts.animatediff_infotext import update_infotext
|
||||
from scripts.animatediff_infotext import update_infotext, infotext_pasted
|
||||
|
||||
script_dir = scripts.basedir()
|
||||
motion_module.set_script_dir(script_dir)
|
||||
|
|
@ -27,6 +27,8 @@ class AnimateDiffScript(scripts.Script):
|
|||
self.cn_hacker = None
|
||||
self.prompt_scheduler = None
|
||||
self.hacked = False
|
||||
self.infotext_fields: List[Tuple[gr.components.IOComponent, str]] = []
|
||||
self.paste_field_names: List[str] = []
|
||||
|
||||
|
||||
def title(self):
|
||||
|
|
@ -38,8 +40,13 @@ class AnimateDiffScript(scripts.Script):
|
|||
|
||||
|
||||
def ui(self, is_img2img):
|
||||
return (AnimateDiffUiGroup().render(is_img2img, motion_module.get_model_dir()),)
|
||||
|
||||
unit = AnimateDiffUiGroup().render(
|
||||
is_img2img,
|
||||
motion_module.get_model_dir(),
|
||||
self.infotext_fields,
|
||||
self.paste_field_names
|
||||
)
|
||||
return (unit,)
|
||||
|
||||
def before_process(self, p: StableDiffusionProcessing, params: AnimateDiffProcess):
|
||||
if p.is_api and isinstance(params, dict):
|
||||
|
|
@ -277,3 +284,4 @@ def on_ui_settings():
|
|||
script_callbacks.on_ui_settings(on_ui_settings)
|
||||
script_callbacks.on_after_component(AnimateDiffUiGroup.on_after_component)
|
||||
script_callbacks.on_before_ui(AnimateDiffUiGroup.on_before_ui)
|
||||
script_callbacks.on_infotext_pasted(infotext_pasted)
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ class AnimateDiffControl:
|
|||
unit.batch_images = unit.batch_images[:params.video_length]
|
||||
|
||||
animatediff_i2ibatch.cap_init_image(p, params)
|
||||
prompt_scheduler.parse_prompt(p)
|
||||
prompt_scheduler.parse_prompt(p, params)
|
||||
update_infotext(p, params)
|
||||
return getattr(processing, '__controlnet_original_process_images_inner')(p, *args, **kwargs)
|
||||
|
||||
|
|
|
|||
|
|
@ -23,13 +23,13 @@ def infotext_pasted(infotext, results):
|
|||
if not k.startswith("AnimateDiff"):
|
||||
continue
|
||||
|
||||
assert isinstance(v, str), f"Expect string but got {v}."
|
||||
assert isinstance(v, str), f"Expected string but got {v}."
|
||||
try:
|
||||
for items in v.split(', '):
|
||||
field, value = items.split(': ')
|
||||
results[f"AnimateDiff {field}"] = value
|
||||
except Exception:
|
||||
logger.warn(
|
||||
f"Failed to parse infotext, legacy format infotext is no longer supported:\n{v}"
|
||||
)
|
||||
results.pop("AnimateDiff")
|
||||
except Exception as e:
|
||||
logger.warn(f"Failed to parse infotext value:\n{v}")
|
||||
logger.warn(f"Exception: {e}")
|
||||
break
|
||||
|
|
|
|||
|
|
@ -218,8 +218,8 @@ class AnimateDiffOutput:
|
|||
except ImportError:
|
||||
from launch import run_pip
|
||||
run_pip(
|
||||
"install pyav",
|
||||
"sd-webui-animatediff MP4 save requirement: PyAV",
|
||||
"install imageio[pyav]",
|
||||
"sd-webui-animatediff MP4 save requirement: imageio[pyav]",
|
||||
)
|
||||
import av
|
||||
options = {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from modules.processing import StableDiffusionProcessing, Processed
|
|||
|
||||
from scripts.animatediff_logger import logger_animatediff as logger
|
||||
from scripts.animatediff_infotext import write_params_txt
|
||||
|
||||
from scripts.animatediff_ui import AnimateDiffProcess
|
||||
|
||||
class AnimateDiffPromptSchedule:
|
||||
|
||||
|
|
@ -31,7 +31,7 @@ class AnimateDiffPromptSchedule:
|
|||
write_params_txt(res.info)
|
||||
|
||||
|
||||
def parse_prompt(self, p: StableDiffusionProcessing):
|
||||
def parse_prompt(self, p: StableDiffusionProcessing, params: AnimateDiffProcess):
|
||||
if type(p.prompt) is not str:
|
||||
logger.warn("prompt is not str, cannot support prompt map")
|
||||
return
|
||||
|
|
@ -55,6 +55,8 @@ class AnimateDiffPromptSchedule:
|
|||
match = re.match(r'^(\d+): (.+)$', line)
|
||||
if match:
|
||||
frame, prompt = match.groups()
|
||||
assert int(frame) < params.video_length, \
|
||||
f"invalid prompt travel frame number: {int(frame)} >= number of frames ({params.video_length})"
|
||||
data['mapp_prompts'][int(frame)] = prompt
|
||||
else:
|
||||
mode = 'tail'
|
||||
|
|
|
|||
|
|
@ -107,6 +107,18 @@ class AnimateDiffProcess:
|
|||
return infotext_str
|
||||
|
||||
|
||||
def get_param_names(self, is_img2img: bool):
|
||||
remove = ["format", "request_id", "video_source", "video_path", "last_frame"]
|
||||
if not is_img2img:
|
||||
remove.extend(["latent_power", "latent_power_last", "latent_scale", "latent_scale_last"])
|
||||
|
||||
return [
|
||||
field
|
||||
for field in self.__dict__
|
||||
if field not in remove and not callable(getattr(self, field)) and not field.startswith("__")
|
||||
]
|
||||
|
||||
|
||||
def _check(self):
|
||||
assert (
|
||||
self.video_length >= 0 and self.fps > 0
|
||||
|
|
@ -141,7 +153,7 @@ class AnimateDiffUiGroup:
|
|||
self.params = AnimateDiffProcess()
|
||||
|
||||
|
||||
def render(self, is_img2img: bool, model_dir: str):
|
||||
def render(self, is_img2img: bool, model_dir: str, infotext_fields, paste_field_names):
|
||||
if not os.path.isdir(model_dir):
|
||||
os.mkdir(model_dir)
|
||||
elemid_prefix = "img2img-ad-" if is_img2img else "txt2img-ad-"
|
||||
|
|
@ -313,6 +325,12 @@ class AnimateDiffUiGroup:
|
|||
remove = gr.Button(value="Remove motion module from any memory")
|
||||
unload.click(fn=motion_module.unload)
|
||||
remove.click(fn=motion_module.remove)
|
||||
|
||||
# Set up controls to be copy-pasted using infotext
|
||||
fields = self.params.get_param_names(is_img2img)
|
||||
infotext_fields.extend((getattr(self.params, field), f"AnimateDiff {field}") for field in fields)
|
||||
paste_field_names.extend(f"AnimateDiff {field}" for field in fields)
|
||||
|
||||
return self.register_unit(is_img2img)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue