Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
diffusers
Commits
cb9d77af
Unverified
Commit
cb9d77af
authored
Apr 11, 2023
by
Steven Liu
Committed by
GitHub
Apr 11, 2023
Browse files
[docs] Reusing components (#3000)
* reuse-components * format
parent
8b451eb6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
1 deletion
+20
-1
docs/source/en/using-diffusers/loading.mdx
docs/source/en/using-diffusers/loading.mdx
+20
-1
No files found.
docs/source/en/using-diffusers/loading.mdx
View file @
cb9d77af
...
...
@@ -123,7 +123,7 @@ stable_diffusion = DiffusionPipeline.from_pretrained(repo_id, safety_checker=Non
###
Reuse
components
across
pipelines
You
can
also
reuse
the
same
components
in
multiple
pipelines
without
loading
the
weights
into
RAM
twice
.
Use
the
[`
DiffusionPipeline
.
components
`]
method
to
save
the
components
in
`
components
`
:
You
can
also
reuse
the
same
components
in
multiple
pipelines
to
avoid
loading
the
weights
into
RAM
twice
.
Use
the
[`
~
DiffusionPipeline
.
components
`]
method
to
save
the
components
:
```
python
from
diffusers
import
StableDiffusionPipeline
,
StableDiffusionImg2ImgPipeline
...
...
@@ -140,6 +140,25 @@ Then you can pass the `components` to another pipeline without reloading the wei
stable_diffusion_img2img
=
StableDiffusionImg2ImgPipeline
(**
components
)
```
You
can
also
pass
the
components
individually
to
the
pipeline
if
you
want
more
flexibility
over
which
components
to
reuse
or
disable
.
For
example
,
to
reuse
the
same
components
in
the
text
-
to
-
image
pipeline
,
except
for
the
safety
checker
and
feature
extractor
,
in
the
image
-
to
-
image
pipeline
:
```
py
from
diffusers
import
StableDiffusionPipeline
,
StableDiffusionImg2ImgPipeline
model_id
=
"runwayml/stable-diffusion-v1-5"
stable_diffusion_txt2img
=
StableDiffusionPipeline
.
from_pretrained
(
model_id
)
stable_diffusion_img2img
=
StableDiffusionImg2ImgPipeline
(
vae
=
stable_diffusion_txt2img
.
vae
,
text_encoder
=
stable_diffusion_txt2img
.
text_encoder
,
tokenizer
=
stable_diffusion_txt2img
.
tokenizer
,
unet
=
stable_diffusion_txt2img
.
unet
,
scheduler
=
stable_diffusion_txt2img
.
scheduler
,
safety_checker
=
None
,
feature_extractor
=
None
,
requires_safety_checker
=
False
,
)
```
##
Checkpoint
variants
A
checkpoint
variant
is
usually
a
checkpoint
where
it
's weights are:
...
...
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