fix: avoid error parse unknown value

This commit is contained in:
bluelovers 2024-06-06 08:00:01 +08:00
parent 9af67abfcf
commit d2d6ea2f60

View File

@ -268,6 +268,8 @@ Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 965400086, Size: 512x512, Model
for k, v in re_param.findall(lastline):
try:
v = v.strip()
if v.startswith('"') and v.endswith('"'):
v = unquote(v)
elif v.startswith('[') and v.endswith(']'):
@ -280,12 +282,12 @@ Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 965400086, Size: 512x512, Model
res[f"{k}-1"] = m.group(1)
res[f"{k}-2"] = m.group(2)
continue
v = v.strip() # Remove surrounding spaces for non-JSON values
res[k] = v
except Exception as e:
print(f"Error parsing \"{k}: {v}\": {e}")
res[k] = v
# Extract styles from prompt
if shared.opts.infotext_styles != "Ignore":
found_styles, prompt_no_styles, negative_prompt_no_styles = shared.prompt_styles.extract_styles_from_prompt(prompt, negative_prompt)