Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
renzhc
diffusers_dcu
Commits
e05ca84f
"git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "82058a5413ca09561cc5cc236c4abc5eeda7b209"
Unverified
Commit
e05ca84f
authored
Nov 17, 2022
by
Anton Lozhkov
Committed by
GitHub
Nov 17, 2022
Browse files
[ONNX] Support Euler schedulers (#1328)
parent
632dacea
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
6 deletions
+12
-6
src/diffusers/pipelines/stable_diffusion/pipeline_onnx_stable_diffusion.py
...elines/stable_diffusion/pipeline_onnx_stable_diffusion.py
+4
-2
src/diffusers/pipelines/stable_diffusion/pipeline_onnx_stable_diffusion_img2img.py
...table_diffusion/pipeline_onnx_stable_diffusion_img2img.py
+4
-2
src/diffusers/pipelines/stable_diffusion/pipeline_onnx_stable_diffusion_inpaint.py
...table_diffusion/pipeline_onnx_stable_diffusion_inpaint.py
+4
-2
No files found.
src/diffusers/pipelines/stable_diffusion/pipeline_onnx_stable_diffusion.py
View file @
e05ca84f
...
@@ -261,8 +261,10 @@ class OnnxStableDiffusionPipeline(DiffusionPipeline):
...
@@ -261,8 +261,10 @@ class OnnxStableDiffusionPipeline(DiffusionPipeline):
noise_pred
=
noise_pred_uncond
+
guidance_scale
*
(
noise_pred_text
-
noise_pred_uncond
)
noise_pred
=
noise_pred_uncond
+
guidance_scale
*
(
noise_pred_text
-
noise_pred_uncond
)
# compute the previous noisy sample x_t -> x_t-1
# compute the previous noisy sample x_t -> x_t-1
latents
=
self
.
scheduler
.
step
(
noise_pred
,
t
,
torch
.
from_numpy
(
latents
),
**
extra_step_kwargs
).
prev_sample
scheduler_output
=
self
.
scheduler
.
step
(
latents
=
np
.
array
(
latents
)
torch
.
from_numpy
(
noise_pred
),
t
,
torch
.
from_numpy
(
latents
),
**
extra_step_kwargs
)
latents
=
scheduler_output
.
prev_sample
.
numpy
()
# 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
:
...
...
src/diffusers/pipelines/stable_diffusion/pipeline_onnx_stable_diffusion_img2img.py
View file @
e05ca84f
...
@@ -401,8 +401,10 @@ class OnnxStableDiffusionImg2ImgPipeline(DiffusionPipeline):
...
@@ -401,8 +401,10 @@ class OnnxStableDiffusionImg2ImgPipeline(DiffusionPipeline):
noise_pred
=
noise_pred_uncond
+
guidance_scale
*
(
noise_pred_text
-
noise_pred_uncond
)
noise_pred
=
noise_pred_uncond
+
guidance_scale
*
(
noise_pred_text
-
noise_pred_uncond
)
# compute the previous noisy sample x_t -> x_t-1
# compute the previous noisy sample x_t -> x_t-1
latents
=
self
.
scheduler
.
step
(
noise_pred
,
t
,
torch
.
from_numpy
(
latents
),
**
extra_step_kwargs
).
prev_sample
scheduler_output
=
self
.
scheduler
.
step
(
latents
=
latents
.
numpy
()
torch
.
from_numpy
(
noise_pred
),
t
,
torch
.
from_numpy
(
latents
),
**
extra_step_kwargs
)
latents
=
scheduler_output
.
prev_sample
.
numpy
()
# 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
:
...
...
src/diffusers/pipelines/stable_diffusion/pipeline_onnx_stable_diffusion_inpaint.py
View file @
e05ca84f
...
@@ -424,8 +424,10 @@ class OnnxStableDiffusionInpaintPipeline(DiffusionPipeline):
...
@@ -424,8 +424,10 @@ class OnnxStableDiffusionInpaintPipeline(DiffusionPipeline):
noise_pred
=
noise_pred_uncond
+
guidance_scale
*
(
noise_pred_text
-
noise_pred_uncond
)
noise_pred
=
noise_pred_uncond
+
guidance_scale
*
(
noise_pred_text
-
noise_pred_uncond
)
# compute the previous noisy sample x_t -> x_t-1
# compute the previous noisy sample x_t -> x_t-1
latents
=
self
.
scheduler
.
step
(
noise_pred
,
t
,
torch
.
from_numpy
(
latents
),
**
extra_step_kwargs
).
prev_sample
scheduler_output
=
self
.
scheduler
.
step
(
latents
=
latents
.
numpy
()
torch
.
from_numpy
(
noise_pred
),
t
,
torch
.
from_numpy
(
latents
),
**
extra_step_kwargs
)
latents
=
scheduler_output
.
prev_sample
.
numpy
()
# 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
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment