fix many resolution problems

This commit is contained in:
lllyasviel
2023-10-20 02:41:04 -07:00
parent a0539c37f5
commit 04066124c2
5 changed files with 40 additions and 54 deletions
+18 -19
View File
@@ -29,7 +29,8 @@ def worker():
from modules.sdxl_styles import apply_style, apply_wildcards, aspect_ratios, 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, image_is_generated_in_current_ui, make_sure_that_image_is_not_too_large
from modules.util import join_prompts, remove_empty_str, HWC3, resize_image, \
get_image_shape_ceil, set_image_shape_ceil, get_shape_ceil
from modules.upscaler import perform_upscale
try:
@@ -287,11 +288,6 @@ def worker():
progressbar(13, 'Image processing ...')
if 'vary' in goals:
if not image_is_generated_in_current_ui(uov_input_image, ui_width=width, ui_height=height):
uov_input_image = resize_image(uov_input_image, width=width, height=height)
print(f'Resolution corrected - users are uploading their own images.')
else:
print(f'Processing images generated by Fooocus.')
if 'subtle' in uov_method:
denoising_strength = 0.5
if 'strong' in uov_method:
@@ -299,7 +295,16 @@ def worker():
if advanced_parameters.overwrite_vary_strength > 0:
denoising_strength = advanced_parameters.overwrite_vary_strength
uov_input_image = make_sure_that_image_is_not_too_large(uov_input_image)
shape_ceil = get_image_shape_ceil(uov_input_image)
if shape_ceil < 1024:
print(f'[Vary] Image is resized because it is too small.')
shape_ceil = 1024
elif shape_ceil > 2048:
print(f'[Vary] Image is resized because it is too big.')
shape_ceil = 2048
uov_input_image = set_image_shape_ceil(uov_input_image, shape_ceil)
initial_pixels = core.numpy_to_pytorch(uov_input_image)
progressbar(13, 'VAE encoding ...')
initial_latent = core.encode_vae(vae=pipeline.final_vae, pixels=initial_pixels)
@@ -324,18 +329,12 @@ def worker():
else:
f = 1.0
width_f = int(width * f)
height_f = int(height * f)
if image_is_generated_in_current_ui(uov_input_image, ui_width=width_f, ui_height=height_f):
uov_input_image = resize_image(uov_input_image, width=int(W * f), height=int(H * f))
print(f'Processing images generated by Fooocus.')
else:
uov_input_image = resize_image(uov_input_image, width=width_f, height=height_f)
print(f'Resolution corrected - users are uploading their own images.')
H, W, C = uov_input_image.shape
image_is_super_large = H * W > 2800 * 2800
shape_ceil = get_shape_ceil(H * f, W * f)
if shape_ceil < 1024:
print(f'[Upscale] Image is resized because it is too small.')
shape_ceil = 1024
uov_input_image = set_image_shape_ceil(uov_input_image, shape_ceil)
image_is_super_large = shape_ceil > 2800
if 'fast' in uov_method:
direct_return = True