ini preset

This commit is contained in:
lvmin 2023-10-13 06:42:08 -07:00
parent 739a8a592a
commit 7d4b635460
4 changed files with 44 additions and 3 deletions

View File

@ -4,6 +4,7 @@ import fcbh.cli_args as fcbh_cli
fcbh_cli.parser.add_argument("--share", action='store_true', help="Set whether to share on Gradio.")
fcbh_cli.parser.add_argument("--preset", type=str, default=None, help="Apply specified UI preset.")
fcbh_cli.args = fcbh_cli.parser.parse_args()
fcbh_cli.args.disable_cuda_malloc = True

View File

@ -1 +1 @@
version = '2.1.56'
version = '2.1.57'

View File

@ -1,5 +1,6 @@
import os
import json
import args_manager
import modules.flags
import modules.sdxl_styles
@ -16,6 +17,23 @@ except Exception as e:
print('Load path config failed')
print(e)
preset = args_manager.args.preset
if preset is not None:
preset = os.path.abspath(f'./presets/{preset}.json')
try:
if os.path.exists(preset):
with open(preset, "r", encoding="utf-8") as json_file:
preset = json.load(json_file)
except Exception as e:
print('Load preset config failed')
print(e)
preset = preset if isinstance(preset, dict) else None
if preset is not None:
config_dict.update(preset)
def get_dir_or_set_default(key, default_value):
global config_dict
@ -125,8 +143,10 @@ default_aspect_ratio = get_config_item_or_set_default(
validator=lambda x: x.replace('*', '×') in modules.sdxl_styles.aspect_ratios
).replace('*', '×')
with open(config_path, "w", encoding="utf-8") as json_file:
json.dump(config_dict, json_file, indent=4)
if preset is None:
# Do not overwrite user config if preset is applied.
with open(config_path, "w", encoding="utf-8") as json_file:
json.dump(config_dict, json_file, indent=4)
os.makedirs(temp_outputs_path, exist_ok=True)

20
presets/sdxl.json Normal file
View File

@ -0,0 +1,20 @@
{
"default_model": "sd_xl_base_1.0_0.9vae.safetensors",
"default_refiner": "sd_xl_refiner_1.0_0.9vae.safetensors",
"default_lora": "sd_xl_offset_example-lora_1.0.safetensors",
"default_lora_weight": 0.5,
"default_cfg_scale": 7.0,
"default_sampler": "dpmpp_2m_sde_gpu",
"default_scheduler": "karras",
"default_styles": [
"Fooocus V2",
"Default (Slightly Cinematic)"
],
"default_negative_prompt": "low quality, bad hands, bad eyes, cropped, missing fingers, extra digit",
"default_positive_prompt": "",
"checkpoint_downloads": {
"sd_xl_base_1.0_0.9vae.safetensors": "https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0_0.9vae.safetensors",
"sd_xl_refiner_1.0_0.9vae.safetensors": "https://huggingface.co/stabilityai/stable-diffusion-xl-refiner-1.0/resolve/main/sd_xl_refiner_1.0_0.9vae.safetensors"
},
"default_aspect_ratio": "1152*896"
}