add automatic backwards version compatibility
This commit is contained in:
parent
d859cec696
commit
d613cd17c7
|
@ -8,7 +8,7 @@ import sys
|
|||
|
||||
import gradio as gr
|
||||
from modules.paths import data_path
|
||||
from modules import shared, ui_tempdir, script_callbacks, processing
|
||||
from modules import shared, ui_tempdir, script_callbacks, processing, infotext_versions, errors
|
||||
from PIL import Image
|
||||
|
||||
sys.modules['modules.generation_parameters_copypaste'] = sys.modules[__name__] # alias for old name
|
||||
|
@ -342,6 +342,8 @@ Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 965400086, Size: 512x512, Model
|
|||
if "Cache FP16 weight for LoRA" not in res and res["FP8 weight"] != "Disable":
|
||||
res["Cache FP16 weight for LoRA"] = False
|
||||
|
||||
infotext_versions.backcompat(res)
|
||||
|
||||
skip = set(shared.opts.infotext_skip_pasting)
|
||||
res = {k: v for k, v in res.items() if k not in skip}
|
||||
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
from modules import shared
|
||||
from packaging import version
|
||||
import re
|
||||
|
||||
|
||||
v160 = version.parse("1.6.0")
|
||||
|
||||
|
||||
def parse_version(text):
|
||||
if text is None:
|
||||
return None
|
||||
|
||||
m = re.match(r'([^-]+-[^-]+)-.*', text)
|
||||
if m:
|
||||
text = m.group(1)
|
||||
|
||||
try:
|
||||
return version.parse(text)
|
||||
except Exception as e:
|
||||
return None
|
||||
|
||||
|
||||
def backcompat(d):
|
||||
"""Checks infotext Version field, and enables backwards compatibility options according to it."""
|
||||
|
||||
if not shared.opts.auto_backcompat:
|
||||
return
|
||||
|
||||
ver = parse_version(d.get("Version"))
|
||||
if ver is None:
|
||||
return
|
||||
|
||||
if ver < v160:
|
||||
d["Old prompt editing timelines"] = True
|
||||
|
|
@ -212,6 +212,7 @@ options_templates.update(options_section(('optimizations', "Optimizations", "sd"
|
|||
}))
|
||||
|
||||
options_templates.update(options_section(('compatibility', "Compatibility", "sd"), {
|
||||
"auto_backcompat": OptionInfo(True, "Automatic backward compatibility").info("automatically enable options for backwards compatibility when importing generation parameters from infotext that has program version."),
|
||||
"use_old_emphasis_implementation": OptionInfo(False, "Use old emphasis implementation. Can be useful to reproduce old seeds."),
|
||||
"use_old_karras_scheduler_sigmas": OptionInfo(False, "Use old karras scheduler sigmas (0.1 to 10)."),
|
||||
"no_dpmpp_sde_batch_determinism": OptionInfo(False, "Do not make DPM++ SDE deterministic across different batch sizes."),
|
||||
|
|
Loading…
Reference in New Issue