Skip to content

Commit

Permalink
fix(api): seed rng for each image
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Jan 8, 2023
1 parent 282a7cf commit 8c133e9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion api/onnx_web/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,14 @@ def img2img():
(model, provider, scheduler, prompt, cfg, steps, height,
width, seed, pipe) = pipeline_from_request(OnnxStableDiffusionImg2ImgPipeline)

rng = np.random.RandomState(seed)
image = pipe(
prompt=prompt,
image=input_image,
num_inference_steps=steps,
guidance_scale=cfg,
strength=strength,
generator=rng,
).images[0]

output_file = 'img2img_%s_%s.png' % (seed, spinalcase(prompt[0:64]))
Expand Down Expand Up @@ -274,14 +276,16 @@ def txt2img():
width, seed, pipe) = pipeline_from_request(OnnxStableDiffusionPipeline)

latents = get_latents_from_seed(seed, width, height)
rng = np.random.RandomState(seed)

image = pipe(
prompt,
height,
width,
num_inference_steps=steps,
guidance_scale=cfg,
latents=latents
latents=latents,
generator=rng,
).images[0]

output_file = 'txt2img_%s_%s.png' % (seed, spinalcase(prompt[0:64]))
Expand Down

0 comments on commit 8c133e9

Please sign in to comment.