mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 17:24:32 +02:00
fix flux hires
This commit is contained in:
@@ -56,6 +56,15 @@ import diffusers.loaders.single_file # pylint: disable=W0611,C0411
|
||||
logging.getLogger("diffusers.loaders.single_file").setLevel(logging.ERROR)
|
||||
from tqdm.rich import tqdm # pylint: disable=W0611,C0411
|
||||
diffusers.loaders.single_file.logging.tqdm = partial(tqdm, unit='C')
|
||||
|
||||
import tqdm as tqdm_lib
|
||||
class _tqdm_cls:
|
||||
def __call__(self, *args, **kwargs):
|
||||
bar_format = 'Diffusers {rate_fmt}{postfix} {bar} {percentage:3.0f}% {n_fmt}/{total_fmt} {elapsed} {remaining} ' + '\x1b[38;5;71m' + '{desc}' + '\x1b[0m'
|
||||
return tqdm_lib.tqdm(*args, bar_format=bar_format, ncols=80, colour='#327fba', **kwargs)
|
||||
|
||||
transformers.utils.logging.tqdm = _tqdm_cls()
|
||||
diffusers.pipelines.pipeline_utils.logging.tqdm = _tqdm_cls()
|
||||
timer.startup.record("diffusers")
|
||||
|
||||
def get_packages():
|
||||
|
||||
@@ -85,7 +85,7 @@ def diffusers_callback(pipe, step: int, timestep: int, kwargs: dict):
|
||||
kwargs[key] = kwargs[key].chunk(2)[-1]
|
||||
try:
|
||||
if hasattr(pipe, "_unpack_latents") and hasattr(pipe, "vae_scale_factor"): # FLUX
|
||||
if p.hr_resize_mode > 0 and (p.hr_upscaler != 'None' or p.hr_resize_mode == 5):
|
||||
if p.hr_resize_mode > 0 and (p.hr_upscaler != 'None' or p.hr_resize_mode == 5) and p.is_hr_pass:
|
||||
width = max(getattr(p, 'width', 0), getattr(p, 'hr_upscale_to_x', 0))
|
||||
height = max(getattr(p, 'height', 0), getattr(p, 'hr_upscale_to_y', 0))
|
||||
else:
|
||||
|
||||
@@ -313,7 +313,7 @@ class StableDiffusionProcessingImg2Img(StableDiffusionProcessing):
|
||||
self.script_args = []
|
||||
|
||||
def init(self, all_prompts=None, all_seeds=None, all_subseeds=None):
|
||||
if self.init_images is not None and len(self.init_images) > 0:
|
||||
if hasattr(self, 'init_images') and self.init_images is not None and len(self.init_images) > 0:
|
||||
if self.width is None or self.width == 0:
|
||||
self.width = int(8 * (self.init_images[0].width * self.scale_by // 8))
|
||||
if self.height is None or self.height == 0:
|
||||
|
||||
@@ -179,6 +179,8 @@ def process_diffusers(p: processing.StableDiffusionProcessing):
|
||||
shared.state.job_count = 2 * p.n_iter
|
||||
shared.sd_model = sd_models.set_diffuser_pipe(shared.sd_model, sd_models.DiffusersTaskType.IMAGE_2_IMAGE)
|
||||
shared.log.info(f'HiRes: class={shared.sd_model.__class__.__name__} sampler="{p.hr_sampler_name}"')
|
||||
if 'Upscale' in shared.sd_model.__class__.__name__ or 'Flux in shared.sd_refiner.__class__.__name__':
|
||||
output.images = processing_vae.vae_decode(latents=output.images, model=shared.sd_model, full_quality=p.full_quality, output_type='pil', width=p.width, height=p.height)
|
||||
if p.is_control and hasattr(p, 'task_args') and p.task_args.get('image', None) is not None:
|
||||
if hasattr(shared.sd_model, "vae") and output.images is not None and len(output.images) > 0:
|
||||
output.images = processing_vae.vae_decode(latents=output.images, model=shared.sd_model, full_quality=p.full_quality, output_type='pil', width=p.hr_upscale_to_x, height=p.hr_upscale_to_y) # controlnet cannnot deal with latent input
|
||||
|
||||
Reference in New Issue
Block a user