Skip to content

Commit 0a1daad

Browse files
authored
[docs] Community pipelines (huggingface#6929)
fix
1 parent 371f765 commit 0a1daad

File tree

2 files changed

+56
-3
lines changed

2 files changed

+56
-3
lines changed

docs/source/en/using-diffusers/custom_pipeline_overview.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,60 @@ pipeline = DiffusionPipeline.from_pretrained(
5656
)
5757
```
5858

59+
### Load from a local file
60+
61+
Community pipelines can also be loaded from a local file if you pass a file path instead. The path to the passed directory must contain a `pipeline.py` file that contains the pipeline class in order to successfully load it.
62+
63+
```py
64+
pipeline = DiffusionPipeline.from_pretrained(
65+
"runwayml/stable-diffusion-v1-5",
66+
custom_pipeline="./path/to/pipeline_directory/",
67+
clip_model=clip_model,
68+
feature_extractor=feature_extractor,
69+
use_safetensors=True,
70+
)
71+
```
72+
73+
### Load from a specific version
74+
75+
By default, community pipelines are loaded from the latest stable version of Diffusers. To load a community pipeline from another version, use the `custom_revision` parameter.
76+
77+
<hfoptions id="version">
78+
<hfoption id="main">
79+
80+
For example, to load from the `main` branch:
81+
82+
```py
83+
pipeline = DiffusionPipeline.from_pretrained(
84+
"runwayml/stable-diffusion-v1-5",
85+
custom_pipeline="clip_guided_stable_diffusion",
86+
custom_revision="main",
87+
clip_model=clip_model,
88+
feature_extractor=feature_extractor,
89+
use_safetensors=True,
90+
)
91+
```
92+
93+
</hfoption>
94+
<hfoption id="older version">
95+
96+
For example, to load from a previous version of Diffusers like `v0.25.0`:
97+
98+
```py
99+
pipeline = DiffusionPipeline.from_pretrained(
100+
"runwayml/stable-diffusion-v1-5",
101+
custom_pipeline="clip_guided_stable_diffusion",
102+
custom_revision="v0.25.0",
103+
clip_model=clip_model,
104+
feature_extractor=feature_extractor,
105+
use_safetensors=True,
106+
)
107+
```
108+
109+
</hfoption>
110+
</hfoptions>
111+
112+
59113
For more information about community pipelines, take a look at the [Community pipelines](custom_pipeline_examples) guide for how to use them and if you're interested in adding a community pipeline check out the [How to contribute a community pipeline](contribute_pipeline) guide!
60114

61115
## Community components

src/diffusers/pipelines/pipeline_utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -981,10 +981,9 @@ def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.P
981981
revision (`str`, *optional*, defaults to `"main"`):
982982
The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier
983983
allowed by Git.
984-
custom_revision (`str`, *optional*, defaults to `"main"`):
984+
custom_revision (`str`, *optional*):
985985
The specific model version to use. It can be a branch name, a tag name, or a commit id similar to
986-
`revision` when loading a custom pipeline from the Hub. It can be a 🤗 Diffusers version when loading a
987-
custom pipeline from GitHub, otherwise it defaults to `"main"` when loading from the Hub.
986+
`revision` when loading a custom pipeline from the Hub. Defaults to the latest stable 🤗 Diffusers version.
988987
mirror (`str`, *optional*):
989988
Mirror source to resolve accessibility issues if you’re downloading a model in China. We do not
990989
guarantee the timeliness or safety of the source, and you should refer to the mirror site for more

0 commit comments

Comments
 (0)