2024-01-01 11:38:29 +00:00
|
|
|
from modules import shared
|
|
|
|
from packaging import version
|
|
|
|
import re
|
|
|
|
|
|
|
|
|
|
|
|
v160 = version.parse("1.6.0")
|
2024-01-01 11:51:56 +00:00
|
|
|
v170_tsnr = version.parse("v1.7.0-225")
|
2024-03-02 04:39:59 +00:00
|
|
|
v180 = version.parse("1.8.0")
|
2024-01-01 11:38:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
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)
|
2024-01-01 12:00:39 +00:00
|
|
|
except Exception:
|
2024-01-01 11:38:29 +00:00
|
|
|
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
|
|
|
|
|
2024-01-27 19:30:12 +00:00
|
|
|
if ver < v160 and '[' in d.get('Prompt', ''):
|
2024-01-01 11:38:29 +00:00
|
|
|
d["Old prompt editing timelines"] = True
|
|
|
|
|
2024-01-27 19:30:12 +00:00
|
|
|
if ver < v160 and d.get('Sampler', '') in ('DDIM', 'PLMS'):
|
|
|
|
d["Pad conds v0"] = True
|
|
|
|
|
2024-01-01 11:51:56 +00:00
|
|
|
if ver < v170_tsnr:
|
|
|
|
d["Downcast alphas_cumprod"] = True
|
|
|
|
|
2024-03-02 04:39:59 +00:00
|
|
|
if ver < v180 and d.get('Refiner'):
|
|
|
|
d["Refiner switch by sampling steps"] = True
|