You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/en/conceptual/contribution.md
+65-22Lines changed: 65 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -198,38 +198,81 @@ Anything displayed on [the official Diffusers doc page](https://huggingface.co/d
198
198
199
199
Please have a look at [this page](https://github.com/huggingface/diffusers/tree/main/docs) on how to verify changes made to the documentation locally.
200
200
201
-
202
201
### 6. Contribute a community pipeline
203
202
204
-
[Pipelines](https://huggingface.co/docs/diffusers/api/pipelines/overview) are usually the first point of contact between the Diffusers library and the user.
205
-
Pipelines are examples of how to use Diffusers [models](https://huggingface.co/docs/diffusers/api/models/overview) and [schedulers](https://huggingface.co/docs/diffusers/api/schedulers/overview).
206
-
We support two types of pipelines:
203
+
> [!TIP]
204
+
> Read the [Community pipelines](../using-diffusers/custom_pipeline_overview#community-pipelines) guide to learn more about the difference between a GitHub and Hugging Face Hub community pipeline. If you're interested in why we have community pipelines, take a look at GitHub Issue [#841](https://github.com/huggingface/diffusers/issues/841) (basically, we can't maintain all the possible ways diffusion models can be used for inference but we also don't want to prevent the community from building them).
205
+
206
+
Contributing a community pipeline is a great way to share your creativity and work with the community. It lets you build on top of the [`DiffusionPipeline`] so that anyone can load and use it by setting the `custom_pipeline` parameter. This section will walk you through how to create a simple pipeline where the UNet only does a single forward pass and calls the scheduler once (a "one-step" pipeline).
207
+
208
+
1. Create a one_step_unet.py file for your community pipeline. This file can contain whatever package you want to use as long as it's installed by the user. Make sure you only have one pipeline class that inherits from [`DiffusionPipeline`] to load model weights and the scheduler configuration from the Hub. Add a UNet and scheduler to the `__init__` function.
209
+
210
+
You should also add the `register_modules` function to ensure your pipeline and its components can be saved with [`~DiffusionPipeline.save_pretrained`].
1. In the forward pass (which we recommend defining as `__call__`), you can add any feature you'd like. For the "one-step" pipeline, create a random image and call the UNet and scheduler once by setting `timestep=1`.
Official pipelines are tested and maintained by the core maintainers of Diffusers. Their code
214
-
resides in [src/diffusers/pipelines](https://github.com/huggingface/diffusers/tree/main/src/diffusers/pipelines).
215
-
In contrast, community pipelines are contributed and maintained purely by the **community** and are **not** tested.
216
-
They reside in [examples/community](https://github.com/huggingface/diffusers/tree/main/examples/community) and while they can be accessed via the [PyPI diffusers package](https://pypi.org/project/diffusers/), their code is not part of the PyPI distribution.
262
+
You can either share your pipeline as a GitHub community pipeline or Hub community pipeline.
217
263
218
-
The reason for the distinction is that the core maintainers of the Diffusers library cannot maintain and test all
219
-
possible ways diffusion models can be used for inference, but some of them may be of interest to the community.
220
-
Officially released diffusion pipelines,
221
-
such as Stable Diffusion are added to the core src/diffusers/pipelines package which ensures
222
-
high quality of maintenance, no backward-breaking code changes, and testing.
223
-
More bleeding edge pipelines should be added as community pipelines. If usage for a community pipeline is high, the pipeline can be moved to the official pipelines upon request from the community. This is one of the ways we strive to be a community-driven library.
264
+
<hfoptionsid="pipeline type">
265
+
<hfoptionid="GitHub pipeline">
224
266
225
-
To add a community pipeline, one should add a <name-of-the-community>.py file to [examples/community](https://github.com/huggingface/diffusers/tree/main/examples/community) and adapt the [examples/community/README.md](https://github.com/huggingface/diffusers/tree/main/examples/community/README.md) to include an example of the new pipeline.
267
+
Share your GitHub pipeline by opening a pull request on the Diffusers [repository](https://github.com/huggingface/diffusers) and add the one_step_unet.py file to the [examples/community](https://github.com/huggingface/diffusers/tree/main/examples/community) subfolder.
226
268
227
-
An example can be seen [here](https://github.com/huggingface/diffusers/pull/2400).
269
+
</hfoption>
270
+
<hfoptionid="Hub pipeline">
228
271
229
-
Community pipeline PRs are only checked at a superficial level and ideally they should be maintained by their original authors.
272
+
Share your Hub pipeline by creating a model repository on the Hub and uploading the one_step_unet.py file to it.
230
273
231
-
Contributing a community pipeline is a great way to understand how Diffusers models and schedulers work. Having contributed a community pipeline is usually the first stepping stone to contributing an official pipeline to the
0 commit comments