diff --git a/api/onnx_web/chain/base.py b/api/onnx_web/chain/base.py index fadce75d..41d36651 100644 --- a/api/onnx_web/chain/base.py +++ b/api/onnx_web/chain/base.py @@ -252,7 +252,8 @@ class ChainPipeline: except Exception: worker.retries = worker.retries - 1 logger.exception( - "error while running stage pipeline, %s retries left", worker.retries + "error while running stage pipeline, %s retries left", + worker.retries, ) server.cache.clear() run_gc([worker.get_device()]) diff --git a/api/onnx_web/chain/persist_disk.py b/api/onnx_web/chain/persist_disk.py index 7d9a0fe6..124f0989 100644 --- a/api/onnx_web/chain/persist_disk.py +++ b/api/onnx_web/chain/persist_disk.py @@ -28,6 +28,10 @@ class PersistDiskStage(BaseStage): stage_source: Optional[Image.Image] = None, **kwargs, ) -> List[Image.Image]: + logger.info( + "persisting images to disk: %s, %s", [s.size for s in sources], output + ) + for source, name in zip(sources, output): dest = save_image(server, name, source, params=params, size=size) logger.info("saved image to %s", dest) diff --git a/api/onnx_web/chain/source_txt2img.py b/api/onnx_web/chain/source_txt2img.py index 13dc70d9..4ad3885c 100644 --- a/api/onnx_web/chain/source_txt2img.py +++ b/api/onnx_web/chain/source_txt2img.py @@ -47,7 +47,10 @@ class SourceTxt2ImgStage(BaseStage): params = params.with_args(prompt=slice_prompt(params.prompt, prompt_index)) logger.info( - "generating image using txt2img, %s steps: %s", params.steps, params.prompt + "generating image using txt2img, %s steps of %s: %s", + params.steps, + params.model, + params.prompt, ) if len(sources): @@ -125,6 +128,7 @@ class SourceTxt2ImgStage(BaseStage): output = list(sources) output.extend(result.images) + logger.debug("produced %s outputs", len(output)) return output def steps( diff --git a/api/onnx_web/convert/diffusion/diffusion_xl.py b/api/onnx_web/convert/diffusion/diffusion_xl.py index 54f37752..f6413cb7 100644 --- a/api/onnx_web/convert/diffusion/diffusion_xl.py +++ b/api/onnx_web/convert/diffusion/diffusion_xl.py @@ -69,7 +69,11 @@ def convert_diffusion_diffusers_xl( else: pipeline.vae = AutoencoderKL.from_pretrained(vae_path) - pipeline.save_pretrained(temp_path) + if path.exists(temp_path): + logger.debug("torch model already exists for %s: %s", source, temp_path) + else: + logger.debug("exporting torch model for %s: %s", source, temp_path) + pipeline.save_pretrained(temp_path) # directory -> onnx using optimum exporters main_export( diff --git a/api/onnx_web/diffusers/load.py b/api/onnx_web/diffusers/load.py index 622ae341..cbbb10d0 100644 --- a/api/onnx_web/diffusers/load.py +++ b/api/onnx_web/diffusers/load.py @@ -264,9 +264,7 @@ def load_pipeline( if hasattr(pipe, vae): vae_model = getattr(pipe, vae) vae_model.set_tiled(tiled=params.tiled_vae) - vae_model.set_window_size( - params.vae_tile // 8, params.vae_overlap - ) + vae_model.set_window_size(params.vae_tile // 8, params.vae_overlap) # update panorama params if params.is_panorama(): diff --git a/api/onnx_web/diffusers/pipelines/panorama_xl.py b/api/onnx_web/diffusers/pipelines/panorama_xl.py index 7b804438..91e8b040 100644 --- a/api/onnx_web/diffusers/pipelines/panorama_xl.py +++ b/api/onnx_web/diffusers/pipelines/panorama_xl.py @@ -330,7 +330,11 @@ class StableDiffusionXLPanoramaPipelineMixin(StableDiffusionXLImg2ImgPipelineMix ) add_region_embeds.append( np.concatenate( - (region_negative_pooled_prompt_embeds, region_pooled_prompt_embeds), axis=0 + ( + region_negative_pooled_prompt_embeds, + region_pooled_prompt_embeds, + ), + axis=0, ) ) @@ -440,7 +444,15 @@ class StableDiffusionXLPanoramaPipelineMixin(StableDiffusionXLImg2ImgPipelineMix for r in range(len(regions)): top, left, bottom, right, mult, prompt = regions[r] - logger.debug("running region prompt: %s, %s, %s, %s, %s, %s", top, left, bottom, right, mult, prompt) + logger.debug( + "running region prompt: %s, %s, %s, %s, %s, %s", + top, + left, + bottom, + right, + mult, + prompt, + ) # convert coordinates to latent space h_start = top // 8 @@ -476,7 +488,9 @@ class StableDiffusionXLPanoramaPipelineMixin(StableDiffusionXLImg2ImgPipelineMix # perform guidance if do_classifier_free_guidance: - region_noise_pred_uncond, region_noise_pred_text = np.split(region_noise_pred, 2) + region_noise_pred_uncond, region_noise_pred_text = np.split( + region_noise_pred, 2 + ) region_noise_pred = region_noise_pred_uncond + guidance_scale * ( region_noise_pred_text - region_noise_pred_uncond ) @@ -501,7 +515,9 @@ class StableDiffusionXLPanoramaPipelineMixin(StableDiffusionXLImg2ImgPipelineMix value[:, :, h_start:h_end, w_start:w_end] = latents_region_denoised count[:, :, h_start:h_end, w_start:w_end] = 1 else: - value[:, :, h_start:h_end, w_start:w_end] += latents_region_denoised * mult + value[:, :, h_start:h_end, w_start:w_end] += ( + latents_region_denoised * mult + ) count[:, :, h_start:h_end, w_start:w_end] += mult # take the MultiDiffusion step. Eq. 5 in MultiDiffusion paper: https://arxiv.org/abs/2302.08113 diff --git a/api/onnx_web/diffusers/utils.py b/api/onnx_web/diffusers/utils.py index f4d1928d..45928a48 100644 --- a/api/onnx_web/diffusers/utils.py +++ b/api/onnx_web/diffusers/utils.py @@ -228,7 +228,7 @@ def parse_float_group(group: Tuple[str, str]) -> Tuple[str, float]: def get_tokens_from_prompt( prompt: str, pattern: Pattern, - parser = parse_float_group, + parser=parse_float_group, ) -> Tuple[str, List[Tuple[str, float]]]: """ TODO: replace with Arpeggio