This commit is contained in:
Haoming 2026-05-27 17:19:44 +08:00
parent 476e1f8f1b
commit 2be0c2a861
5 changed files with 9 additions and 26 deletions

View File

@ -214,21 +214,6 @@ class Options:
self.data = json.load(file)
except FileNotFoundError:
self.data = {}
except Exception:
errors.report(f'\nCould not load settings\nThe config file "{filename}" is likely corrupted\nIt has been moved to the "tmp/config.json"\nReverting config to default\n\n''', exc_info=True)
os.replace(filename, os.path.join(script_path, "tmp", "config.json"))
self.data = {}
# 1.6.0 VAE defaults
if self.data.get('sd_vae_as_default') is not None and self.data.get('sd_vae_overrides_per_model_preferences') is None:
self.data['sd_vae_overrides_per_model_preferences'] = not self.data.get('sd_vae_as_default')
# 1.1.1 quicksettings list migration
if self.data.get('quicksettings') is not None and self.data.get('quicksettings_list') is None:
self.data['quicksettings_list'] = [i.strip() for i in self.data.get('quicksettings').split(',')]
# 1.4.0 ui_reorder
if isinstance(self.data.get('ui_reorder'), str) and self.data.get('ui_reorder') and "ui_reorder_list" not in self.data:
self.data['ui_reorder_list'] = [i.strip() for i in self.data.get('ui_reorder').split(',')]
bad_settings = 0
for k, v in self.data.items():

View File

@ -802,7 +802,7 @@ def process_images(p: StableDiffusionProcessing) -> Processed:
if sd_models.checkpoint_aliases.get(p.override_settings.get("sd_model_checkpoint")) is None:
p.override_settings.pop("sd_model_checkpoint", None)
_vae_override: tuple[str, list[str]] = p.override_settings.pop("sd_vae", None)
_vae_override = p.override_settings.pop("sd_vae", None)
# apply any options overrides
set_config(p.override_settings, is_api=True, run_callbacks=False, save_config=False)
@ -814,10 +814,11 @@ def process_images(p: StableDiffusionProcessing) -> Processed:
else:
manage_model_and_prompt_cache(p)
if _vae_override is not None:
override, choices = _vae_override
override: str = _vae_override
all_vae: list[str] = sd_vae.vae_dict.keys()
_orig: list[str] = shared.opts.forge_additional_modules.copy()
for i in range(len(_orig)):
if os.path.basename(_orig[i]) in choices:
if os.path.basename(_orig[i]) in all_vae:
if _orig[i] != override:
shared.opts.forge_additional_modules.pop(i)
else:

View File

@ -91,7 +91,7 @@ def refresh_vae_list():
def reload_vae_weights(vae: str) -> bool:
if vae in (None, "None", "Automatic"):
if vae in (None, "None"):
return False
store_base_vae(shared.sd_model)

View File

@ -263,7 +263,6 @@ image to and from latent space representation. Latent space is what Stable Diffu
to create the resulting image after the sampling is finished. For img2img, VAE is additionally used to process user's input image before the sampling.
"""),
"sd_vae": OptionInfo("Automatic", "SD VAE", gr.Dropdown, {"choices": ("Automatic",), "interactive": False}),
"sd_vae_overrides_per_model_preferences": OptionInfo(True, '"SD VAE" option overrides per-model preference'),
"sd_vae_encode_method": OptionInfo("Full", "VAE for Encoding", gr.Radio, {"choices": ("Full", "TAESD")}, infotext="VAE Encoder").info("method to encode image to latent (img2img / Hires. fix / inpaint)"),
"sd_vae_decode_method": OptionInfo("Full", "VAE for Decoding", gr.Radio, {"choices": ("Full", "TAESD")}, infotext="VAE Decoder").info("method to decode latent to image"),
},

View File

@ -115,8 +115,8 @@ def apply_size(p: StableDiffusionProcessing, x: str, _):
logger.error(f'Invalid Size "{x}" for X/Y/Z Plot')
def apply_vae(p: StableDiffusionProcessing, x: str, xs: list[str]):
p.override_settings["sd_vae"] = (find_vae(x), xs)
def apply_vae(p: StableDiffusionProcessing, x: str, _):
p.override_settings["sd_vae"] = find_vae(x)
def apply_styles(p: StableDiffusionProcessing, x: str, _):
@ -197,10 +197,8 @@ def refresh_loading_params_for_xyz_grid():
def find_vae(name: str) -> str:
if name is None or name.strip().lower() == "none":
if name in (None, "None"):
return "None"
elif name.strip().lower() in ("auto", "automatic"):
return "Automatic"
else:
return sd_vae.vae_dict[name]
@ -301,7 +299,7 @@ axis_options = [
AxisOptionImg2Img("Sampler", str, apply_field("sampler_name"), format_value=format_value, confirm=confirm_samplers, choices=lambda: [x.name for x in sd_samplers.samplers_for_img2img if x.name not in opts.hide_samplers]),
AxisOption("Schedule type", str, apply_field("scheduler"), choices=lambda: [x.label for x in sd_schedulers.schedulers]),
AxisOption("Checkpoint name", str, apply_checkpoint, format_value=format_remove_path, confirm=confirm_checkpoints, cost=1.0, choices=lambda: sorted(sd_models.checkpoints_list, key=str.casefold)),
AxisOption("VAE", str, apply_vae, cost=0.7, choices=lambda: ["Automatic", "None"] + list(sd_vae.vae_dict)),
AxisOption("VAE", str, apply_vae, cost=0.7, choices=lambda: ["None", *sorted(sd_vae.vae_dict.keys())]),
AxisOption("Clip skip", int, apply_override("CLIP_stop_at_last_layers")),
AxisOption("Denoising", float, apply_field("denoising_strength")),
AxisOption("Initial noise multiplier", float, apply_field("initial_noise_multiplier")),