Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
automatic1111
GitHub Repository: automatic1111/stable-diffusion-webui
Path: blob/master/modules/infotext_versions.py
3058 views
1
from modules import shared
2
from packaging import version
3
import re
4
5
6
v160 = version.parse("1.6.0")
7
v170_tsnr = version.parse("v1.7.0-225")
8
v180 = version.parse("1.8.0")
9
v180_hr_styles = version.parse("1.8.0-139")
10
11
12
def parse_version(text):
13
if text is None:
14
return None
15
16
m = re.match(r'([^-]+-[^-]+)-.*', text)
17
if m:
18
text = m.group(1)
19
20
try:
21
return version.parse(text)
22
except Exception:
23
return None
24
25
26
def backcompat(d):
27
"""Checks infotext Version field, and enables backwards compatibility options according to it."""
28
29
if not shared.opts.auto_backcompat:
30
return
31
32
ver = parse_version(d.get("Version"))
33
if ver is None:
34
return
35
36
if ver < v160 and '[' in d.get('Prompt', ''):
37
d["Old prompt editing timelines"] = True
38
39
if ver < v160 and d.get('Sampler', '') in ('DDIM', 'PLMS'):
40
d["Pad conds v0"] = True
41
42
if ver < v170_tsnr:
43
d["Downcast alphas_cumprod"] = True
44
45
if ver < v180 and d.get('Refiner'):
46
d["Refiner switch by sampling steps"] = True
47
48