fix refiner

This commit is contained in:
lllyasviel 2023-10-26 19:42:50 -07:00
parent 5cbefa821f
commit f07f7693d3
5 changed files with 14 additions and 6 deletions

View File

@ -1 +1 @@
version = '2.1.751' version = '2.1.752'

View File

@ -80,6 +80,7 @@ def worker():
guidance_scale = args.pop() guidance_scale = args.pop()
base_model_name = args.pop() base_model_name = args.pop()
refiner_model_name = args.pop() refiner_model_name = args.pop()
refiner_switch = args.pop()
loras = [(args.pop(), args.pop()) for _ in range(5)] loras = [(args.pop(), args.pop()) for _ in range(5)]
input_image_checkbox = args.pop() input_image_checkbox = args.pop()
current_tab = args.pop() current_tab = args.pop()
@ -147,10 +148,8 @@ def worker():
if performance_selection == 'Speed': if performance_selection == 'Speed':
steps = 30 steps = 30
switch = 20
else: else:
steps = 60 steps = 60
switch = 40
sampler_name = advanced_parameters.sampler_name sampler_name = advanced_parameters.sampler_name
scheduler_name = advanced_parameters.scheduler_name scheduler_name = advanced_parameters.scheduler_name
@ -171,10 +170,8 @@ def worker():
else: else:
if performance_selection == 'Speed': if performance_selection == 'Speed':
steps = 18 steps = 18
switch = 12
else: else:
steps = 36 steps = 36
switch = 24
progressbar(1, 'Downloading upscale models ...') progressbar(1, 'Downloading upscale models ...')
modules.path.downloading_upscale_model() modules.path.downloading_upscale_model()
if (current_tab == 'inpaint' or (current_tab == 'ip' and advanced_parameters.mixing_image_prompt_and_inpaint))\ if (current_tab == 'inpaint' or (current_tab == 'ip' and advanced_parameters.mixing_image_prompt_and_inpaint))\
@ -206,6 +203,8 @@ def worker():
pipeline.refresh_controlnets([controlnet_canny_path, controlnet_cpds_path]) pipeline.refresh_controlnets([controlnet_canny_path, controlnet_cpds_path])
ip_adapter.load_ip_adapter(clip_vision_path, ip_negative_path, ip_adapter_path) ip_adapter.load_ip_adapter(clip_vision_path, ip_negative_path, ip_adapter_path)
switch = int(round(steps * refiner_switch))
if advanced_parameters.overwrite_step > 0: if advanced_parameters.overwrite_step > 0:
steps = advanced_parameters.overwrite_step steps = advanced_parameters.overwrite_step

View File

@ -91,6 +91,11 @@ default_refiner_model_name = get_config_item_or_set_default(
default_value='sd_xl_refiner_1.0_0.9vae.safetensors', default_value='sd_xl_refiner_1.0_0.9vae.safetensors',
validator=lambda x: isinstance(x, str) validator=lambda x: isinstance(x, str)
) )
default_refiner_switch = get_config_item_or_set_default(
key='default_refiner_switch',
default_value=0.8,
validator=lambda x: isinstance(x, float)
)
default_lora_name = get_config_item_or_set_default( default_lora_name = get_config_item_or_set_default(
key='default_lora', key='default_lora',
default_value='sd_xl_offset_example-lora_1.0.safetensors', default_value='sd_xl_offset_example-lora_1.0.safetensors',

View File

@ -2,6 +2,7 @@
"default_model": "bluePencilXL_v050.safetensors", "default_model": "bluePencilXL_v050.safetensors",
"default_refiner": "DreamShaper_8_pruned.safetensors", "default_refiner": "DreamShaper_8_pruned.safetensors",
"default_lora": "sd_xl_offset_example-lora_1.0.safetensors", "default_lora": "sd_xl_offset_example-lora_1.0.safetensors",
"default_refiner_switch": 0.667,
"default_lora_weight": 0.5, "default_lora_weight": 0.5,
"default_cfg_scale": 7.0, "default_cfg_scale": 7.0,
"default_sampler": "dpmpp_2m_sde_gpu", "default_sampler": "dpmpp_2m_sde_gpu",

View File

@ -253,6 +253,9 @@ with shared.gradio_root:
info='Higher value means image and texture are sharper.') info='Higher value means image and texture are sharper.')
guidance_scale = gr.Slider(label='Guidance Scale', minimum=1.0, maximum=30.0, step=0.01, value=modules.path.default_cfg_scale, guidance_scale = gr.Slider(label='Guidance Scale', minimum=1.0, maximum=30.0, step=0.01, value=modules.path.default_cfg_scale,
info='Higher value means style is cleaner, vivider, and more artistic.') info='Higher value means style is cleaner, vivider, and more artistic.')
refiner_switch = gr.Slider(label='Refiner Switch At', minimum=0.0, maximum=1.0, step=0.0001,
info='When to switch from base model to the refiner (if refiner is used).',
value=modules.path.default_refiner_switch)
gr.HTML('<a href="https://github.com/lllyasviel/Fooocus/discussions/117" target="_blank">\U0001F4D4 Document</a>') gr.HTML('<a href="https://github.com/lllyasviel/Fooocus/discussions/117" target="_blank">\U0001F4D4 Document</a>')
dev_mode = gr.Checkbox(label='Developer Debug Mode', value=False, container=False) dev_mode = gr.Checkbox(label='Developer Debug Mode', value=False, container=False)
@ -361,7 +364,7 @@ with shared.gradio_root:
performance_selection, aspect_ratios_selection, image_number, image_seed, sharpness, guidance_scale performance_selection, aspect_ratios_selection, image_number, image_seed, sharpness, guidance_scale
] ]
ctrls += [base_model, refiner_model] + lora_ctrls ctrls += [base_model, refiner_model, refiner_switch] + lora_ctrls
ctrls += [input_image_checkbox, current_tab] ctrls += [input_image_checkbox, current_tab]
ctrls += [uov_method, uov_input_image] ctrls += [uov_method, uov_input_image]
ctrls += [outpaint_selections, inpaint_input_image] ctrls += [outpaint_selections, inpaint_input_image]