1
0
Fork 0

try replacing NaN and clipping large values to reduce noise

This commit is contained in:
Sean Sube 2023-11-12 18:24:30 -06:00
parent f24a3ab287
commit 4460625309
Signed by: ssube
GPG Key ID: 3EED7B957D362AF1
2 changed files with 6 additions and 2 deletions

View File

@ -28,7 +28,7 @@ from transformers import CLIPImageProcessor, CLIPTokenizer
from onnx_web.chain.tile import make_tile_mask from onnx_web.chain.tile import make_tile_mask
from ..utils import LATENT_CHANNELS, LATENT_FACTOR, parse_regions from ..utils import LATENT_CHANNELS, LATENT_FACTOR, parse_regions, repair_nan
logger = logging.get_logger(__name__) logger = logging.get_logger(__name__)
@ -701,6 +701,8 @@ class OnnxStableDiffusionPanoramaPipeline(DiffusionPipeline):
# take the MultiDiffusion step. Eq. 5 in MultiDiffusion paper: https://arxiv.org/abs/2302.08113 # take the MultiDiffusion step. Eq. 5 in MultiDiffusion paper: https://arxiv.org/abs/2302.08113
latents = np.where(count > 0, value / count, value) latents = np.where(count > 0, value / count, value)
latents = repair_nan(latents)
latents = np.clip(latents, -4, +4)
# call the callback, if provided # call the callback, if provided
if callback is not None and i % callback_steps == 0: if callback is not None and i % callback_steps == 0:

View File

@ -14,7 +14,7 @@ from optimum.pipelines.diffusers.pipeline_utils import preprocess, rescale_noise
from onnx_web.chain.tile import make_tile_mask from onnx_web.chain.tile import make_tile_mask
from ..utils import LATENT_FACTOR, parse_regions from ..utils import LATENT_FACTOR, parse_regions, repair_nan
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -550,6 +550,8 @@ class StableDiffusionXLPanoramaPipelineMixin(StableDiffusionXLImg2ImgPipelineMix
# take the MultiDiffusion step. Eq. 5 in MultiDiffusion paper: https://arxiv.org/abs/2302.08113 # take the MultiDiffusion step. Eq. 5 in MultiDiffusion paper: https://arxiv.org/abs/2302.08113
latents = np.where(count > 0, value / count, value) latents = np.where(count > 0, value / count, value)
latents = repair_nan(latents)
latents = np.clip(latents, -4, +4)
# call the callback, if provided # call the callback, if provided
if i == len(timesteps) - 1 or ( if i == len(timesteps) - 1 or (