diff --git a/api/onnx_web/chain/blend_img2img.py b/api/onnx_web/chain/blend_img2img.py index e9469226..f74d032f 100644 --- a/api/onnx_web/chain/blend_img2img.py +++ b/api/onnx_web/chain/blend_img2img.py @@ -1,6 +1,7 @@ from logging import getLogger import torch +import numpy as np from diffusers import OnnxStableDiffusionImg2ImgPipeline from PIL import Image @@ -35,8 +36,9 @@ def blend_img2img( ) if params.lpw: pipe = pipe.img2img - - rng = torch.manual_seed(params.seed) + rng = torch.manual_seed(params.seed) + else: + rng = np.random.RandomState(params.seed) result = pipe( prompt, diff --git a/api/onnx_web/chain/blend_inpaint.py b/api/onnx_web/chain/blend_inpaint.py index c83f1ef6..c5205263 100644 --- a/api/onnx_web/chain/blend_inpaint.py +++ b/api/onnx_web/chain/blend_inpaint.py @@ -2,6 +2,7 @@ from logging import getLogger from typing import Callable, Tuple import torch +import numpy as np from diffusers import OnnxStableDiffusionInpaintPipeline from PIL import Image @@ -68,9 +69,11 @@ def blend_inpaint( ) if params.lpw: pipe = pipe.inpaint + rng = torch.manual_seed(params.seed) + else: + rng = np.random.RandomState(params.seed) latents = get_latents_from_seed(params.seed, size) - rng = torch.manual_seed(params.seed) result = pipe( params.prompt, diff --git a/api/onnx_web/chain/source_txt2img.py b/api/onnx_web/chain/source_txt2img.py index 7a904a1e..b2ee3db8 100644 --- a/api/onnx_web/chain/source_txt2img.py +++ b/api/onnx_web/chain/source_txt2img.py @@ -1,6 +1,7 @@ from logging import getLogger import torch +import numpy as np from diffusers import OnnxStableDiffusionPipeline from PIL import Image @@ -36,9 +37,11 @@ def source_txt2img( ) if params.lpw: pipe = pipe.text2img + rng = torch.manual_seed(params.seed) + else: + rng = np.random.RandomState(params.seed) latents = get_latents_from_seed(params.seed, size) - rng = torch.manual_seed(params.seed) result = pipe( prompt, diff --git a/api/onnx_web/chain/upscale_outpaint.py b/api/onnx_web/chain/upscale_outpaint.py index d81efc91..86a62e89 100644 --- a/api/onnx_web/chain/upscale_outpaint.py +++ b/api/onnx_web/chain/upscale_outpaint.py @@ -2,6 +2,7 @@ from logging import getLogger from typing import Callable, Tuple import torch +import numpy as np from diffusers import OnnxStableDiffusionInpaintPipeline from PIL import Image, ImageDraw @@ -73,9 +74,11 @@ def upscale_outpaint( ) if params.lpw: pipe = pipe.inpaint + rng = torch.manual_seed(params.seed) + else: + rng = np.random.RandomState(params.seed) latents = get_tile_latents(full_latents, dims) - rng = torch.manual_seed(params.seed) result = pipe( image, diff --git a/api/onnx_web/diffusion/run.py b/api/onnx_web/diffusion/run.py index 0d5b1f59..8967a4c9 100644 --- a/api/onnx_web/diffusion/run.py +++ b/api/onnx_web/diffusion/run.py @@ -2,6 +2,7 @@ from logging import getLogger from typing import Any import torch +import numpy as np from diffusers import OnnxStableDiffusionImg2ImgPipeline, OnnxStableDiffusionPipeline from PIL import Image, ImageChops @@ -29,9 +30,11 @@ def run_txt2img_pipeline( ) if params.lpw: pipe = pipe.text2img + rng = torch.manual_seed(params.seed) + else: + rng = np.random.RandomState(params.seed) latents = get_latents_from_seed(params.seed, size) - rng = torch.manual_seed(params.seed) progress = job.get_progress_callback() result = pipe( @@ -78,8 +81,10 @@ def run_img2img_pipeline( ) if params.lpw: pipe = pipe.img2img + rng = torch.manual_seed(params.seed) + else: + rng = np.random.RandomState(params.seed) - rng = torch.manual_seed(params.seed) progress = job.get_progress_callback() result = pipe(