File size: 1,189 Bytes
a9658c4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os

from modules.paths import data_path
from modules.processing import StableDiffusionProcessing, StableDiffusionProcessingImg2Img

from scripts.animatediff_ui import AnimateDiffProcess
from scripts.animatediff_logger import logger_animatediff as logger


def update_infotext(p: StableDiffusionProcessing, params: AnimateDiffProcess):
    if p.extra_generation_params is not None:
        p.extra_generation_params["AnimateDiff"] = params.get_dict(isinstance(p, StableDiffusionProcessingImg2Img))


def write_params_txt(info: str):
    with open(os.path.join(data_path, "params.txt"), "w", encoding="utf8") as file:
        file.write(info)



def infotext_pasted(infotext, results):
    for k, v in results.items():
        if not k.startswith("AnimateDiff"):
            continue

        assert isinstance(v, str), f"Expect 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}"
            )
        break