allow ar config

This commit is contained in:
lllyasviel
2023-10-23 19:42:23 -07:00
parent 504e5478b0
commit 60cb91c406
6 changed files with 37 additions and 50 deletions
+5 -2
View File
@@ -26,7 +26,7 @@ def worker():
import modules.advanced_parameters as advanced_parameters
import fooocus_extras.ip_adapter as ip_adapter
from modules.sdxl_styles import apply_style, apply_wildcards, aspect_ratios, fooocus_expansion
from modules.sdxl_styles import apply_style, apply_wildcards, fooocus_expansion
from modules.private_logger import log
from modules.expansion import safe_str
from modules.util import join_prompts, remove_empty_str, HWC3, resize_image, \
@@ -112,7 +112,10 @@ def worker():
denoising_strength = 1.0
tiled = False
inpaint_worker.current_task = None
width, height = aspect_ratios[aspect_ratios_selection]
width, height = aspect_ratios_selection.split('×')
width, height = int(width), int(height)
skip_prompt_processing = False
refiner_swap_method = advanced_parameters.refiner_swap_method
+11 -3
View File
@@ -163,11 +163,16 @@ embeddings_downloads = get_config_item_or_set_default(
default_value={},
validator=lambda x: isinstance(x, dict) and all(isinstance(k, str) and isinstance(v, str) for k, v in x.items())
)
available_aspect_ratios = get_config_item_or_set_default(
key='available_aspect_ratios',
default_value=['704*1408', '704*1344', '768*1344', '768*1280', '832*1216', '832*1152', '896*1152', '896*1088', '960*1088', '960*1024', '1024*1024', '1024*960', '1088*960', '1088*896', '1152*896', '1152*832', '1216*832', '1280*768', '1344*768', '1344*704', '1408*704', '1472*704', '1536*640', '1600*640', '1664*576', '1728*576'],
validator=lambda x: isinstance(x, list) and all('*' in v for v in x) and len(x) > 1
)
default_aspect_ratio = get_config_item_or_set_default(
key='default_aspect_ratio',
default_value='1152*896',
validator=lambda x: x.replace('*', '×') in modules.sdxl_styles.aspect_ratios
).replace('*', '×')
default_value='1152*896' if '1152*896' in available_aspect_ratios else available_aspect_ratios[0],
validator=lambda x: x in available_aspect_ratios
)
if preset is None:
# Do not overwrite user config if preset is applied.
@@ -179,6 +184,9 @@ os.makedirs(temp_outputs_path, exist_ok=True)
model_filenames = []
lora_filenames = []
available_aspect_ratios = [x.replace('*', '×') for x in available_aspect_ratios]
default_aspect_ratio = default_aspect_ratio.replace('*', '×')
def get_model_filenames(folder_path, name_filter=None):
return get_files_from_folder(folder_path, ['.pth', '.ckpt', '.bin', '.safetensors', '.fooocus.patch'], name_filter)
-42
View File
@@ -51,48 +51,6 @@ fooocus_expansion = "Fooocus V2"
legal_style_names = [fooocus_expansion] + style_keys
SD_XL_BASE_RATIOS = {
"0.5": (704, 1408),
"0.52": (704, 1344),
"0.57": (768, 1344),
"0.6": (768, 1280),
"0.68": (832, 1216),
"0.72": (832, 1152),
"0.78": (896, 1152),
"0.82": (896, 1088),
"0.88": (960, 1088),
"0.94": (960, 1024),
"1.0": (1024, 1024),
"1.07": (1024, 960),
"1.13": (1088, 960),
"1.21": (1088, 896),
"1.29": (1152, 896),
"1.38": (1152, 832),
"1.46": (1216, 832),
"1.67": (1280, 768),
"1.75": (1344, 768),
"1.91": (1344, 704),
"2.0": (1408, 704),
"2.09": (1472, 704),
"2.4": (1536, 640),
"2.5": (1600, 640),
"2.89": (1664, 576),
"3.0": (1728, 576),
}
aspect_ratios = {}
# import math
for k, (w, h) in SD_XL_BASE_RATIOS.items():
txt = f'{w}×{h}'
# gcd = math.gcd(w, h)
# txt += f' {w//gcd}:{h//gcd}'
aspect_ratios[txt] = (w, h)
def apply_style(style, positive):
p, n = styles[style]
return p.replace('{prompt}', positive), n