jacob-c commited on
Commit
b106354
·
1 Parent(s): b48ceed

diffuserfix

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. diffus/CITATION.cff +0 -40
  2. diffus/CODE_OF_CONDUCT.md +0 -130
  3. diffus/CONTRIBUTING.md +0 -498
  4. diffus/LICENSE +0 -201
  5. diffus/MANIFEST.in +0 -2
  6. diffus/Makefile +0 -96
  7. diffus/PHILOSOPHY.md +0 -110
  8. diffus/README.md +0 -185
  9. diffus/_typos.toml +0 -13
  10. diffus/docker/diffusers-flax-cpu/Dockerfile +0 -44
  11. diffus/docker/diffusers-flax-tpu/Dockerfile +0 -46
  12. diffus/docker/diffusers-onnxruntime-cpu/Dockerfile +0 -44
  13. diffus/docker/diffusers-onnxruntime-cuda/Dockerfile +0 -44
  14. diffus/docker/diffusers-pytorch-cpu/Dockerfile +0 -43
  15. diffus/docker/diffusers-pytorch-cuda/Dockerfile +0 -42
  16. diffus/docs/README.md +0 -271
  17. diffus/docs/TRANSLATING.md +0 -57
  18. diffus/docs/source/_config.py +0 -9
  19. diffus/docs/source/en/_toctree.yml +0 -264
  20. diffus/docs/source/en/api/configuration.mdx +0 -25
  21. diffus/docs/source/en/api/diffusion_pipeline.mdx +0 -47
  22. diffus/docs/source/en/api/experimental/rl.mdx +0 -15
  23. diffus/docs/source/en/api/loaders.mdx +0 -30
  24. diffus/docs/source/en/api/logging.mdx +0 -98
  25. diffus/docs/source/en/api/models.mdx +0 -107
  26. diffus/docs/source/en/api/outputs.mdx +0 -55
  27. diffus/docs/source/en/api/pipelines/alt_diffusion.mdx +0 -83
  28. diffus/docs/source/en/api/pipelines/audio_diffusion.mdx +0 -98
  29. diffus/docs/source/en/api/pipelines/audioldm.mdx +0 -82
  30. diffus/docs/source/en/api/pipelines/cycle_diffusion.mdx +0 -100
  31. diffus/docs/source/en/api/pipelines/dance_diffusion.mdx +0 -34
  32. diffus/docs/source/en/api/pipelines/ddim.mdx +0 -36
  33. diffus/docs/source/en/api/pipelines/ddpm.mdx +0 -37
  34. diffus/docs/source/en/api/pipelines/dit.mdx +0 -59
  35. diffus/docs/source/en/api/pipelines/latent_diffusion.mdx +0 -49
  36. diffus/docs/source/en/api/pipelines/latent_diffusion_uncond.mdx +0 -42
  37. diffus/docs/source/en/api/pipelines/overview.mdx +0 -213
  38. diffus/docs/source/en/api/pipelines/paint_by_example.mdx +0 -74
  39. diffus/docs/source/en/api/pipelines/pndm.mdx +0 -35
  40. diffus/docs/source/en/api/pipelines/repaint.mdx +0 -77
  41. diffus/docs/source/en/api/pipelines/score_sde_ve.mdx +0 -36
  42. diffus/docs/source/en/api/pipelines/semantic_stable_diffusion.mdx +0 -79
  43. diffus/docs/source/en/api/pipelines/spectrogram_diffusion.mdx +0 -54
  44. diffus/docs/source/en/api/pipelines/stable_diffusion/attend_and_excite.mdx +0 -75
  45. diffus/docs/source/en/api/pipelines/stable_diffusion/controlnet.mdx +0 -280
  46. diffus/docs/source/en/api/pipelines/stable_diffusion/depth2img.mdx +0 -33
  47. diffus/docs/source/en/api/pipelines/stable_diffusion/image_variation.mdx +0 -31
  48. diffus/docs/source/en/api/pipelines/stable_diffusion/img2img.mdx +0 -36
  49. diffus/docs/source/en/api/pipelines/stable_diffusion/inpaint.mdx +0 -37
  50. diffus/docs/source/en/api/pipelines/stable_diffusion/latent_upscale.mdx +0 -33
diffus/CITATION.cff DELETED
@@ -1,40 +0,0 @@
1
- cff-version: 1.2.0
2
- title: 'Diffusers: State-of-the-art diffusion models'
3
- message: >-
4
- If you use this software, please cite it using the
5
- metadata from this file.
6
- type: software
7
- authors:
8
- - given-names: Patrick
9
- family-names: von Platen
10
- - given-names: Suraj
11
- family-names: Patil
12
- - given-names: Anton
13
- family-names: Lozhkov
14
- - given-names: Pedro
15
- family-names: Cuenca
16
- - given-names: Nathan
17
- family-names: Lambert
18
- - given-names: Kashif
19
- family-names: Rasul
20
- - given-names: Mishig
21
- family-names: Davaadorj
22
- - given-names: Thomas
23
- family-names: Wolf
24
- repository-code: 'https://github.com/huggingface/diffusers'
25
- abstract: >-
26
- Diffusers provides pretrained diffusion models across
27
- multiple modalities, such as vision and audio, and serves
28
- as a modular toolbox for inference and training of
29
- diffusion models.
30
- keywords:
31
- - deep-learning
32
- - pytorch
33
- - image-generation
34
- - diffusion
35
- - text2image
36
- - image2image
37
- - score-based-generative-modeling
38
- - stable-diffusion
39
- license: Apache-2.0
40
- version: 0.12.1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/CODE_OF_CONDUCT.md DELETED
@@ -1,130 +0,0 @@
1
-
2
- # Contributor Covenant Code of Conduct
3
-
4
- ## Our Pledge
5
-
6
- We as members, contributors, and leaders pledge to make participation in our
7
- community a harassment-free experience for everyone, regardless of age, body
8
- size, visible or invisible disability, ethnicity, sex characteristics, gender
9
- identity and expression, level of experience, education, socio-economic status,
10
- nationality, personal appearance, race, religion, or sexual identity
11
- and orientation.
12
-
13
- We pledge to act and interact in ways that contribute to an open, welcoming,
14
- diverse, inclusive, and healthy community.
15
-
16
- ## Our Standards
17
-
18
- Examples of behavior that contributes to a positive environment for our
19
- community include:
20
-
21
- * Demonstrating empathy and kindness toward other people
22
- * Being respectful of differing opinions, viewpoints, and experiences
23
- * Giving and gracefully accepting constructive feedback
24
- * Accepting responsibility and apologizing to those affected by our mistakes,
25
- and learning from the experience
26
- * Focusing on what is best not just for us as individuals, but for the
27
- overall diffusers community
28
-
29
- Examples of unacceptable behavior include:
30
-
31
- * The use of sexualized language or imagery, and sexual attention or
32
- advances of any kind
33
- * Trolling, insulting or derogatory comments, and personal or political attacks
34
- * Public or private harassment
35
- * Publishing others' private information, such as a physical or email
36
- address, without their explicit permission
37
- * Spamming issues or PRs with links to projects unrelated to this library
38
- * Other conduct which could reasonably be considered inappropriate in a
39
- professional setting
40
-
41
- ## Enforcement Responsibilities
42
-
43
- Community leaders are responsible for clarifying and enforcing our standards of
44
- acceptable behavior and will take appropriate and fair corrective action in
45
- response to any behavior that they deem inappropriate, threatening, offensive,
46
- or harmful.
47
-
48
- Community leaders have the right and responsibility to remove, edit, or reject
49
- comments, commits, code, wiki edits, issues, and other contributions that are
50
- not aligned to this Code of Conduct, and will communicate reasons for moderation
51
- decisions when appropriate.
52
-
53
- ## Scope
54
-
55
- This Code of Conduct applies within all community spaces, and also applies when
56
- an individual is officially representing the community in public spaces.
57
- Examples of representing our community include using an official e-mail address,
58
- posting via an official social media account, or acting as an appointed
59
- representative at an online or offline event.
60
-
61
- ## Enforcement
62
-
63
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
64
- reported to the community leaders responsible for enforcement at
65
66
- All complaints will be reviewed and investigated promptly and fairly.
67
-
68
- All community leaders are obligated to respect the privacy and security of the
69
- reporter of any incident.
70
-
71
- ## Enforcement Guidelines
72
-
73
- Community leaders will follow these Community Impact Guidelines in determining
74
- the consequences for any action they deem in violation of this Code of Conduct:
75
-
76
- ### 1. Correction
77
-
78
- **Community Impact**: Use of inappropriate language or other behavior deemed
79
- unprofessional or unwelcome in the community.
80
-
81
- **Consequence**: A private, written warning from community leaders, providing
82
- clarity around the nature of the violation and an explanation of why the
83
- behavior was inappropriate. A public apology may be requested.
84
-
85
- ### 2. Warning
86
-
87
- **Community Impact**: A violation through a single incident or series
88
- of actions.
89
-
90
- **Consequence**: A warning with consequences for continued behavior. No
91
- interaction with the people involved, including unsolicited interaction with
92
- those enforcing the Code of Conduct, for a specified period of time. This
93
- includes avoiding interactions in community spaces as well as external channels
94
- like social media. Violating these terms may lead to a temporary or
95
- permanent ban.
96
-
97
- ### 3. Temporary Ban
98
-
99
- **Community Impact**: A serious violation of community standards, including
100
- sustained inappropriate behavior.
101
-
102
- **Consequence**: A temporary ban from any sort of interaction or public
103
- communication with the community for a specified period of time. No public or
104
- private interaction with the people involved, including unsolicited interaction
105
- with those enforcing the Code of Conduct, is allowed during this period.
106
- Violating these terms may lead to a permanent ban.
107
-
108
- ### 4. Permanent Ban
109
-
110
- **Community Impact**: Demonstrating a pattern of violation of community
111
- standards, including sustained inappropriate behavior, harassment of an
112
- individual, or aggression toward or disparagement of classes of individuals.
113
-
114
- **Consequence**: A permanent ban from any sort of public interaction within
115
- the community.
116
-
117
- ## Attribution
118
-
119
- This Code of Conduct is adapted from the [Contributor Covenant][homepage],
120
- version 2.0, available at
121
- https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
122
-
123
- Community Impact Guidelines were inspired by [Mozilla's code of conduct
124
- enforcement ladder](https://github.com/mozilla/diversity).
125
-
126
- [homepage]: https://www.contributor-covenant.org
127
-
128
- For answers to common questions about this code of conduct, see the FAQ at
129
- https://www.contributor-covenant.org/faq. Translations are available at
130
- https://www.contributor-covenant.org/translations.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/CONTRIBUTING.md DELETED
@@ -1,498 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # How to contribute to Diffusers 🧨
14
-
15
- We ❤️ contributions from the open-source community! Everyone is welcome, and all types of participation –not just code– are valued and appreciated. Answering questions, helping others, reaching out, and improving the documentation are all immensely valuable to the community, so don't be afraid and get involved if you're up for it!
16
-
17
- Everyone is encouraged to start by saying 👋 in our public Discord channel. We discuss the latest trends in diffusion models, ask questions, show off personal projects, help each other with contributions, or just hang out ☕. <a href="https://Discord.gg/G7tWnz98XR"><img alt="Join us on Discord" src="https://img.shields.io/Discord/823813159592001537?color=5865F2&logo=Discord&logoColor=white"></a>
18
-
19
- Whichever way you choose to contribute, we strive to be part of an open, welcoming, and kind community. Please, read our [code of conduct](https://github.com/huggingface/diffusers/blob/main/CODE_OF_CONDUCT.md) and be mindful to respect it during your interactions. We also recommend you become familiar with the [ethical guidelines](https://huggingface.co/docs/diffusers/conceptual/ethical_guidelines) that guide our project and ask you to adhere to the same principles of transparency and responsibility.
20
-
21
- We enormously value feedback from the community, so please do not be afraid to speak up if you believe you have valuable feedback that can help improve the library - every message, comment, issue, and pull request (PR) is read and considered.
22
-
23
- ## Overview
24
-
25
- You can contribute in many ways ranging from answering questions on issues to adding new diffusion models to
26
- the core library.
27
-
28
- In the following, we give an overview of different ways to contribute, ranked by difficulty in ascending order. All of them are valuable to the community.
29
-
30
- * 1. Asking and answering questions on [the Diffusers discussion forum](https://discuss.huggingface.co/c/discussion-related-to-httpsgithubcomhuggingfacediffusers) or on [Discord](https://discord.gg/G7tWnz98XR).
31
- * 2. Opening new issues on [the GitHub Issues tab](https://github.com/huggingface/diffusers/issues/new/choose)
32
- * 3. Answering issues on [the GitHub Issues tab](https://github.com/huggingface/diffusers/issues)
33
- * 4. Fix a simple issue, marked by the "Good first issue" label, see [here](https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22).
34
- * 5. Contribute to the [documentation](https://github.com/huggingface/diffusers/tree/main/docs/source).
35
- * 6. Contribute a [Community Pipeline](https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3Acommunity-examples)
36
- * 7. Contribute to the [examples](https://github.com/huggingface/diffusers/tree/main/examples).
37
- * 8. Fix a more difficult issue, marked by the "Good second issue" label, see [here](https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22Good+second+issue%22).
38
- * 9. Add a new pipeline, model, or scheduler, see ["New Pipeline/Model"](https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22New+pipeline%2Fmodel%22) and ["New scheduler"](https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22New+scheduler%22) issues. For this contribution, please have a look at [Design Philosophy](https://github.com/huggingface/diffusers/blob/main/PHILOSOPHY.md).
39
-
40
- As said before, **all contributions are valuable to the community**.
41
- In the following, we will explain each contribution a bit more in detail.
42
-
43
- For all contributions 4.-9. you will need to open a PR. It is explained in detail how to do so in [Opening a pull requst](#how-to-open-a-pr)
44
-
45
- ### 1. Asking and answering questions on the Diffusers discussion forum or on the Diffusers Discord
46
-
47
- Any question or comment related to the Diffusers library can be asked on the [discussion forum](https://discuss.huggingface.co/c/discussion-related-to-httpsgithubcomhuggingfacediffusers/) or on [Discord](https://discord.gg/G7tWnz98XR). Such questions and comments include (but are not limited to):
48
- - Reports of training or inference experiments in an attempt to share knowledge
49
- - Presentation of personal projects
50
- - Questions to non-official training examples
51
- - Project proposals
52
- - General feedback
53
- - Paper summaries
54
- - Asking for help on personal projects that build on top of the Diffusers library
55
- - General questions
56
- - Ethical questions regarding diffusion models
57
- - ...
58
-
59
- Every question that is asked on the forum or on Discord actively encourages the community to publicly
60
- share knowledge and might very well help a beginner in the future that has the same question you're
61
- having. Please do pose any questions you might have.
62
- In the same spirit, you are of immense help to the community by answering such questions because this way you are publicly documenting knowledge for everybody to learn from.
63
-
64
- **Please** keep in mind that the more effort you put into asking or answering a question, the higher
65
- the quality of the publicly documented knowledge. In the same way, well-posed and well-answered questions create a high-quality knowledge database accessible to everybody, while badly posed questions or answers reduce the overall quality of the public knowledge database.
66
- In short, a high quality question or answer is *precise*, *concise*, *relevant*, *easy-to-understand*, *accesible*, and *well-formated/well-posed*. For more information, please have a look through the [How to write a good issue](#how-to-write-a-good-issue) section.
67
-
68
- **NOTE about channels**:
69
- [*The forum*](https://discuss.huggingface.co/c/discussion-related-to-httpsgithubcomhuggingfacediffusers/63) is much better indexed by search engines, such as Google. Posts are ranked by popularity rather than chronologically. Hence, it's easier to look up questions and answers that we posted some time ago.
70
- In addition, questions and answers posted in the forum can easily be linked to.
71
- In contrast, *Discord* has a chat-like format that invites fast back-and-forth communication.
72
- While it will most likely take less time for you to get an answer to your question on Discord, your
73
- question won't be visible anymore over time. Also, it's much harder to find information that was posted a while back on Discord. We therefore strongly recommend using the forum for high-quality questions and answers in an attempt to create long-lasting knowledge for the community. If discussions on Discord lead to very interesting answers and conclusions, we recommend posting the results on the forum to make the information more available for future readers.
74
-
75
- ### 2. Opening new issues on the GitHub issues tab
76
-
77
- The 🧨 Diffusers library is robust and reliable thanks to the users who notify us of
78
- the problems they encounter. So thank you for reporting an issue.
79
-
80
- Remember, GitHub issues are reserved for technical questions directly related to the Diffusers library, bug reports, feature requests, or feedback on the library design.
81
-
82
- In a nutshell, this means that everything that is **not** related to the **code of the Diffusers library** (including the documentation) should **not** be asked on GitHub, but rather on either the [forum](https://discuss.huggingface.co/c/discussion-related-to-httpsgithubcomhuggingfacediffusers/63) or [Discord](https://discord.gg/G7tWnz98XR).
83
-
84
- **Please consider the following guidelines when opening a new issue**:
85
- - Make sure you have searched whether your issue has already been asked before (use the search bar on GitHub under Issues).
86
- - Please never report a new issue on another (related) issue. If another issue is highly related, please
87
- open a new issue nevertheless and link to the related issue.
88
- - Make sure your issue is written in English. Please use one of the great, free online translation services, such as [DeepL](https://www.deepl.com/translator) to translate from your native language to English if you are not comfortable in English.
89
- - Check whether your issue might be solved by updating to the newest Diffusers version. Before posting your issue, please make sure that `python -c "import diffusers; print(diffusers.__version__)"` is higher or matches the latest Diffusers version.
90
- - Remember that the more effort you put into opening a new issue, the higher the quality of your answer will be and the better the overall quality of the Diffusers issues.
91
-
92
- New issues usually include the following.
93
-
94
- #### 2.1. Reproducible, minimal bug reports.
95
-
96
- A bug report should always have a reproducible code snippet and be as minimal and concise as possible.
97
- This means in more detail:
98
- - Narrow the bug down as much as you can, **do not just dump your whole code file**
99
- - Format your code
100
- - Do not include any external libraries except for Diffusers depending on them.
101
- - **Always** provide all necessary information about your environment; for this, you can run: `diffusers-cli env` in your shell and copy-paste the displayed information to the issue.
102
- - Explain the issue. If the reader doesn't know what the issue is and why it is an issue, she cannot solve it.
103
- - **Always** make sure the reader can reproduce your issue with as little effort as possible. If your code snippet cannot be run because of missing libraries or undefined variables, the reader cannot help you. Make sure your reproducible code snippet is as minimal as possible and can be copy-pasted into a simple Python shell.
104
- - If in order to reproduce your issue a model and/or dataset is required, make sure the reader has access to that model or dataset. You can always upload your model or dataset to the [Hub](https://huggingface.co) to make it easily downloadable. Try to keep your model and dataset as small as possible, to make the reproduction of your issue as effortless as possible.
105
-
106
- For more information, please have a look through the [How to write a good issue](#how-to-write-a-good-issue) section.
107
-
108
- You can open a bug report [here](https://github.com/huggingface/diffusers/issues/new/choose).
109
-
110
- #### 2.2. Feature requests.
111
-
112
- A world-class feature request addresses the following points:
113
-
114
- 1. Motivation first:
115
- * Is it related to a problem/frustration with the library? If so, please explain
116
- why. Providing a code snippet that demonstrates the problem is best.
117
- * Is it related to something you would need for a project? We'd love to hear
118
- about it!
119
- * Is it something you worked on and think could benefit the community?
120
- Awesome! Tell us what problem it solved for you.
121
- 2. Write a *full paragraph* describing the feature;
122
- 3. Provide a **code snippet** that demonstrates its future use;
123
- 4. In case this is related to a paper, please attach a link;
124
- 5. Attach any additional information (drawings, screenshots, etc.) you think may help.
125
-
126
- You can open a feature request [here](https://github.com/huggingface/diffusers/issues/new?assignees=&labels=&template=feature_request.md&title=).
127
-
128
- #### 2.3 Feedback.
129
-
130
- Feedback about the library design and why it is good or not good helps the core maintainers immensely to build a user-friendly library. To understand the philosophy behind the current design philosophy, please have a look [here](https://huggingface.co/docs/diffusers/conceptual/philosophy). If you feel like a certain design choice does not fit with the current design philosophy, please explain why and how it should be changed. If a certain design choice follows the design philosophy too much, hence restricting use cases, explain why and how it should be changed.
131
- If a certain design choice is very useful for you, please also leave a note as this is great feedback for future design decisions.
132
-
133
- You can open an issue about feedback [here](https://github.com/huggingface/diffusers/issues/new?assignees=&labels=&template=feedback.md&title=).
134
-
135
- #### 2.4 Technical questions.
136
-
137
- Technical questions are mainly about why certain code of the library was written in a certain way, or what a certain part of the code does. Please make sure to link to the code in question and please provide detail on
138
- why this part of the code is difficult to understand.
139
-
140
- You can open an issue about a technical question [here](https://github.com/huggingface/diffusers/issues/new?assignees=&labels=bug&template=bug-report.yml).
141
-
142
- #### 2.5 Proposal to add a new model, scheduler, or pipeline.
143
-
144
- If the diffusion model community released a new model, pipeline, or scheduler that you would like to see in the Diffusers library, please provide the following information:
145
-
146
- * Short description of the diffusion pipeline, model, or scheduler and link to the paper or public release.
147
- * Link to any of its open-source implementation.
148
- * Link to the model weights if they are available.
149
-
150
- If you are willing to contribute to the model yourself, let us know so we can best guide you. Also, don't forget
151
- to tag the original author of the component (model, scheduler, pipeline, etc.) by GitHub handle if you can find it.
152
-
153
- You can open a request for a model/pipeline/scheduler [here](https://github.com/huggingface/diffusers/issues/new?assignees=&labels=New+model%2Fpipeline%2Fscheduler&template=new-model-addition.yml).
154
-
155
- ### 3. Answering issues on the GitHub issues tab
156
-
157
- Answering issues on GitHub might require some technical knowledge of Diffusers, but we encourage everybody to give it a try even if you are not 100% certain that your answer is correct.
158
- Some tips to give a high-quality answer to an issue:
159
- - Be as concise and minimal as possible
160
- - Stay on topic. An answer to the issue should concern the issue and only the issue.
161
- - Provide links to code, papers, or other sources that prove or encourage your point.
162
- - Answer in code. If a simple code snippet is the answer to the issue or shows how the issue can be solved, please provide a fully reproducible code snippet.
163
-
164
- Also, many issues tend to be simply off-topic, duplicates of other issues, or irrelevant. It is of great
165
- help to the maintainers if you can answer such issues, encouraging the author of the issue to be
166
- more precise, provide the link to a duplicated issue or redirect them to [the forum](https://discuss.huggingface.co/c/discussion-related-to-httpsgithubcomhuggingfacediffusers/63) or [Discord](https://discord.gg/G7tWnz98XR)
167
-
168
- If you have verified that the issued bug report is correct and requires a correction in the source code,
169
- please have a look at the next sections.
170
-
171
- For all of the following contributions, you will need to open a PR. It is explained in detail how to do so in the [Opening a pull requst](#how-to-open-a-pr) section.
172
-
173
- ### 4. Fixing a "Good first issue"
174
-
175
- *Good first issues* are marked by the [Good first issue](https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) label. Usually, the issue already
176
- explains how a potential solution should look so that it is easier to fix.
177
- If the issue hasn't been closed and you would like to try to fix this issue, you can just leave a message "I would like to try this issue.". There are usually three scenarios:
178
- - a.) The issue description already proposes a fix. In this case and if the solution makes sense to you, you can open a PR or draft PR to fix it.
179
- - b.) The issue description does not propose a fix. In this case, you can ask what a proposed fix could look like and someone from the Diffusers team should answer shortly. If you have a good idea of how to fix it, feel free to directly open a PR.
180
- - c.) There is already an open PR to fix the issue, but the issue hasn't been closed yet. If the PR has gone stale, you can simply open a new PR and link to the stale PR. PRs often go stale if the original contributor who wanted to fix the issue suddenly cannot find the time anymore to proceed. This often happens in open-source and is very normal. In this case, the community will be very happy if you give it a new try and leverage the knowledge of the existing PR. If there is already a PR and it is active, you can help the author by giving suggestions, reviewing the PR or even asking whether you can contribute to the PR.
181
-
182
-
183
- ### 5. Contribute to the documentation
184
-
185
- A good library **always** has good documentation! The official documentation is often one of the first points of contact for new users of the library, and therefore contributing to the documentation is a **highly
186
- valuable contribution**.
187
-
188
- Contributing to the library can have many forms:
189
-
190
- - Correcting spelling or grammatical errors.
191
- - Correct incorrect formatting of the docstring. If you see that the official documentation is weirdly displayed or a link is broken, we are very happy if you take some time to correct it.
192
- - Correct the shape or dimensions of a docstring input or output tensor.
193
- - Clarify documentation that is hard to understand or incorrect.
194
- - Update outdated code examples.
195
- - Translating the documentation to another language.
196
-
197
- Anything displayed on [the official Diffusers doc page](https://huggingface.co/docs/diffusers/index) is part of the official documentation and can be corrected, adjusted in the respective [documentation source](https://github.com/huggingface/diffusers/tree/main/docs/source).
198
-
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
-
201
-
202
- ### 6. Contribute a community pipeline
203
-
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) and [schedulers](https://huggingface.co/docs/diffusers/api/schedulers/overview).
206
- We support two types of pipelines:
207
-
208
- - Official Pipelines
209
- - Community Pipelines
210
-
211
- Both official and community pipelines follow the same design and consist of the same type of components.
212
-
213
- 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.
217
-
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.
224
-
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.
226
-
227
- An example can be seen [here](https://github.com/huggingface/diffusers/pull/2400).
228
-
229
- Community pipeline PRs are only checked at a superficial level and ideally they should be maintained by their original authors.
230
-
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
232
- core package.
233
-
234
- ### 7. Contribute to training examples
235
-
236
- Diffusers examples are a collection of training scripts that reside in [examples](https://github.com/huggingface/diffusers/tree/main/examples).
237
-
238
- We support two types of training examples:
239
-
240
- - Official training examples
241
- - Research training examples
242
-
243
- Research training examples are located in [examples/research_projects](https://github.com/huggingface/diffusers/tree/main/examples/research_projects) whereas official training examples include all folders under [examples](https://github.com/huggingface/diffusers/tree/main/examples) except the `research_projects` and `community` folders.
244
- The official training examples are maintained by the Diffusers' core maintainers whereas the research training examples are maintained by the community.
245
- This is because of the same reasons put forward in [6. Contribute a community pipeline](#contribute-a-community-pipeline) for official pipelines vs. community pipelines: It is not feasible for the core maintainers to maintain all possible training methods for diffusion models.
246
- If the Diffusers core maintainers and the community consider a certain training paradigm to be too experimental or not popular enough, the corresponding training code should be put in the `research_projects` folder and maintained by the author.
247
-
248
- Both official training and research examples consist of a directory that contains one or more training scripts, a requirements.txt file, and a README.md file. In order for the user to make use of the
249
- training examples, it is required to clone the repository:
250
-
251
- ```
252
- git clone https://github.com/huggingface/diffusers
253
- ```
254
-
255
- as well as to install all additional dependencies required for training:
256
-
257
- ```
258
- pip install -r /examples/<your-example-folder>/requirements.txt
259
- ```
260
-
261
- Therefore when adding an example, the `requirements.txt` file shall define all pip dependencies required for your training example so that once all those are installed, the user can run the example's training script. See, for example, the [DreamBooth `requirements.txt` file](https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/requirements.txt).
262
-
263
- Training examples of the Diffusers library should adhere to the following philosophy:
264
- - All the code necessary to run the examples should be found in a single Python file
265
- - One should be able to run the example from the command line with `python <your-example>.py --args`
266
- - Examples should be kept simple and serve as **an example** on how to use Diffusers for training. The purpose of example scripts is **not** to create state-of-the-art diffusion models, but rather to reproduce known training schemes without adding too much custom logic. As a byproduct of this point, our examples also strive to serve as good educational materials.
267
-
268
- To contribute an example, it is highly recommended to look at already existing examples such as [dreambooth](https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/train_dreambooth.py) to get an idea of how they should look like.
269
- We strongly advise contributors to make use of the [Accelerate library](https://github.com/huggingface/accelerate) as it's tightly integrated
270
- with Diffusers.
271
- Once an example script works, please make sure to add a comprehensive `README.md` that states how to use the example exactly. This README should include:
272
- - An example command on how to run the example script as shown [here e.g.](https://github.com/huggingface/diffusers/tree/main/examples/dreambooth#running-locally-with-pytorch).
273
- - A link to some training results (logs, models, ...) that show what the user can expect as shown [here e.g.](https://api.wandb.ai/report/patrickvonplaten/xm6cd5q5).
274
- - If you are adding a non-official/research training example, **please don't forget** to add a sentence that you are maintaining this training example which includes your git handle as shown [here](https://github.com/huggingface/diffusers/tree/main/examples/research_projects/intel_opts#diffusers-examples-with-intel-optimizations).
275
-
276
- If you are contributing to the official training examples, please also make sure to add a test to [examples/test_examples.py](https://github.com/huggingface/diffusers/blob/main/examples/test_examples.py). This is not necessary for non-official training examples.
277
-
278
- ### 8. Fixing a "Good second issue"
279
-
280
- *Good second issues* are marked by the [Good second issue](https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22Good+second+issue%22) label. Good second issues are
281
- usually more complicated to solve than [Good first issues](https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22).
282
- The issue description usually gives less guidance on how to fix the issue and requires
283
- a decent understanding of the library by the interested contributor.
284
- If you are interested in tackling a second good issue, feel free to open a PR to fix it and link the PR to the issue. If you see that a PR has already been opened for this issue but did not get merged, have a look to understand why it wasn't merged and try to open an improved PR.
285
- Good second issues are usually more difficult to get merged compared to good first issues, so don't hesitate to ask for help from the core maintainers. If your PR is almost finished the core maintainers can also jump into your PR and commit to it in order to get it merged.
286
-
287
- ### 9. Adding pipelines, models, schedulers
288
-
289
- Pipelines, models, and schedulers are the most important pieces of the Diffusers library.
290
- They provide easy access to state-of-the-art diffusion technologies and thus allow the community to
291
- build powerful generative AI applications.
292
-
293
- By adding a new model, pipeline, or scheduler you might enable a new powerful use case for any of the user interfaces relying on Diffusers which can be of immense value for the whole generative AI ecosystem.
294
-
295
- Diffusers has a couple of open feature requests for all three components - feel free to gloss over them
296
- if you don't know yet what specific component you would like to add:
297
- - [Model or pipeline](https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22New+pipeline%2Fmodel%22)
298
- - [Scheduler](https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22New+scheduler%22)
299
-
300
- Before adding any of the three components, it is strongly recommended that you give the [Philosophy guide](https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22Good+second+issue%22) a read to better understand the design of any of the three components. Please be aware that
301
- we cannot merge model, scheduler, or pipeline additions that strongly diverge from our design philosophy
302
- as it will lead to API inconsistencies. If you fundamentally disagree with a design choice, please
303
- open a [Feedback issue](https://github.com/huggingface/diffusers/issues/new?assignees=&labels=&template=feedback.md&title=) instead so that it can be discussed whether a certain design
304
- pattern/design choice shall be changed everywhere in the library and whether we shall update our design philosophy. Consistency across the library is very important for us.
305
-
306
- Please make sure to add links to the original codebase/paper to the PR and ideally also ping the
307
- original author directly on the PR so that they can follow the progress and potentially help with questions.
308
-
309
- If you are unsure or stuck in the PR, don't hesitate to leave a message to ask for a first review or help.
310
-
311
- ## How to write a good issue
312
-
313
- **The better your issue is written, the higher the chances that it will be quickly resolved.**
314
-
315
- 1. Make sure that you've used the correct template for your issue. You can pick between *Bug Report*, *Feature Request*, *Feedback about API Design*, *New model/pipeline/scheduler addition*, *Forum*, or a blank issue. Make sure to pick the correct one when opening [a new issue](https://github.com/huggingface/diffusers/issues/new/choose).
316
- 2. **Be precise**: Give your issue a fitting title. Try to formulate your issue description as simple as possible. The more precise you are when submitting an issue, the less time it takes to understand the issue and potentially solve it. Make sure to open an issue for one issue only and not for multiple issues. If you found multiple issues, simply open multiple issues. If your issue is a bug, try to be as precise as possible about what bug it is - you should not just write "Error in diffusers".
317
- 3. **Reproducibility**: No reproducible code snippet == no solution. If you encounter a bug, maintainers **have to be able to reproduce** it. Make sure that you include a code snippet that can be copy-pasted into a Python interpreter to reproduce the issue. Make sure that your code snippet works, *i.e.* that there are no missing imports or missing links to images, ... Your issue should contain an error message **and** a code snippet that can be copy-pasted without any changes to reproduce the exact same error message. If your issue is using local model weights or local data that cannot be accessed by the reader, the issue cannot be solved. If you cannot share your data or model, try to make a dummy model or dummy data.
318
- 4. **Minimalistic**: Try to help the reader as much as you can to understand the issue as quickly as possible by staying as concise as possible. Remove all code / all information that is irrelevant to the issue. If you have found a bug, try to create the easiest code example you can to demonstrate your issue, do not just dump your whole workflow into the issue as soon as you have found a bug. E.g., if you train a model and get an error at some point during the training, you should first try to understand what part of the training code is responsible for the error and try to reproduce it with a couple of lines. Try to use dummy data instead of full datasets.
319
- 5. Add links. If you are referring to a certain naming, method, or model make sure to provide a link so that the reader can better understand what you mean. If you are referring to a specific PR or issue, make sure to link it to your issue. Do not assume that the reader knows what you are talking about. The more links you add to your issue the better.
320
- 6. Formatting. Make sure to nicely format your issue by formatting code into Python code syntax, and error messages into normal code syntax. See the [official GitHub formatting docs](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax) for more information.
321
- 7. Think of your issue not as a ticket to be solved, but rather as a beautiful entry to a well-written encyclopedia. Every added issue is a contribution to publicly available knowledge. By adding a nicely written issue you not only make it easier for maintainers to solve your issue, but you are helping the whole community to better understand a certain aspect of the library.
322
-
323
- ## How to write a good PR
324
-
325
- 1. Be a chameleon. Understand existing design patterns and syntax and make sure your code additions flow seamlessly into the existing code base. Pull requests that significantly diverge from existing design patterns or user interfaces will not be merged.
326
- 2. Be laser focused. A pull request should solve one problem and one problem only. Make sure to not fall into the trap of "also fixing another problem while we're adding it". It is much more difficult to review pull requests that solve multiple, unrelated problems at once.
327
- 3. If helpful, try to add a code snippet that displays an example of how your addition can be used.
328
- 4. The title of your pull request should be a summary of its contribution.
329
- 5. If your pull request addresses an issue, please mention the issue number in
330
- the pull request description to make sure they are linked (and people
331
- consulting the issue know you are working on it);
332
- 6. To indicate a work in progress please prefix the title with `[WIP]`. These
333
- are useful to avoid duplicated work, and to differentiate it from PRs ready
334
- to be merged;
335
- 7. Try to formulate and format your text as explained in [How to write a good issue](#how-to-write-a-good-issue).
336
- 8. Make sure existing tests pass;
337
- 9. Add high-coverage tests. No quality testing = no merge.
338
- - If you are adding new `@slow` tests, make sure they pass using
339
- `RUN_SLOW=1 python -m pytest tests/test_my_new_model.py`.
340
- CircleCI does not run the slow tests, but GitHub actions does every night!
341
- 10. All public methods must have informative docstrings that work nicely with markdown. See `[pipeline_latent_diffusion.py](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/latent_diffusion/pipeline_latent_diffusion.py)` for an example.
342
- 11. Due to the rapidly growing repository, it is important to make sure that no files that would significantly weigh down the repository are added. This includes images, videos, and other non-text files. We prefer to leverage a hf.co hosted `dataset` like
343
- [`hf-internal-testing`](https://huggingface.co/hf-internal-testing) or [huggingface/documentation-images](https://huggingface.co/datasets/huggingface/documentation-images) to place these files.
344
- If an external contribution, feel free to add the images to your PR and ask a Hugging Face member to migrate your images
345
- to this dataset.
346
-
347
- ## How to open a PR
348
-
349
- Before writing code, we strongly advise you to search through the existing PRs or
350
- issues to make sure that nobody is already working on the same thing. If you are
351
- unsure, it is always a good idea to open an issue to get some feedback.
352
-
353
- You will need basic `git` proficiency to be able to contribute to
354
- 🧨 Diffusers. `git` is not the easiest tool to use but it has the greatest
355
- manual. Type `git --help` in a shell and enjoy. If you prefer books, [Pro
356
- Git](https://git-scm.com/book/en/v2) is a very good reference.
357
-
358
- Follow these steps to start contributing ([supported Python versions](https://github.com/huggingface/diffusers/blob/main/setup.py#L244)):
359
-
360
- 1. Fork the [repository](https://github.com/huggingface/diffusers) by
361
- clicking on the 'Fork' button on the repository's page. This creates a copy of the code
362
- under your GitHub user account.
363
-
364
- 2. Clone your fork to your local disk, and add the base repository as a remote:
365
-
366
- ```bash
367
- $ git clone [email protected]:<your Github handle>/diffusers.git
368
- $ cd diffusers
369
- $ git remote add upstream https://github.com/huggingface/diffusers.git
370
- ```
371
-
372
- 3. Create a new branch to hold your development changes:
373
-
374
- ```bash
375
- $ git checkout -b a-descriptive-name-for-my-changes
376
- ```
377
-
378
- **Do not** work on the `main` branch.
379
-
380
- 4. Set up a development environment by running the following command in a virtual environment:
381
-
382
- ```bash
383
- $ pip install -e ".[dev]"
384
- ```
385
-
386
- If you have already cloned the repo, you might need to `git pull` to get the most recent changes in the
387
- library.
388
-
389
- 5. Develop the features on your branch.
390
-
391
- As you work on the features, you should make sure that the test suite
392
- passes. You should run the tests impacted by your changes like this:
393
-
394
- ```bash
395
- $ pytest tests/<TEST_TO_RUN>.py
396
- ```
397
-
398
- You can also run the full suite with the following command, but it takes
399
- a beefy machine to produce a result in a decent amount of time now that
400
- Diffusers has grown a lot. Here is the command for it:
401
-
402
- ```bash
403
- $ make test
404
- ```
405
-
406
- 🧨 Diffusers relies on `black` and `isort` to format its source code
407
- consistently. After you make changes, apply automatic style corrections and code verifications
408
- that can't be automated in one go with:
409
-
410
- ```bash
411
- $ make style
412
- ```
413
-
414
- 🧨 Diffusers also uses `ruff` and a few custom scripts to check for coding mistakes. Quality
415
- control runs in CI, however, you can also run the same checks with:
416
-
417
- ```bash
418
- $ make quality
419
- ```
420
-
421
- Once you're happy with your changes, add changed files using `git add` and
422
- make a commit with `git commit` to record your changes locally:
423
-
424
- ```bash
425
- $ git add modified_file.py
426
- $ git commit
427
- ```
428
-
429
- It is a good idea to sync your copy of the code with the original
430
- repository regularly. This way you can quickly account for changes:
431
-
432
- ```bash
433
- $ git pull upstream main
434
- ```
435
-
436
- Push the changes to your account using:
437
-
438
- ```bash
439
- $ git push -u origin a-descriptive-name-for-my-changes
440
- ```
441
-
442
- 6. Once you are satisfied, go to the
443
- webpage of your fork on GitHub. Click on 'Pull request' to send your changes
444
- to the project maintainers for review.
445
-
446
- 7. It's ok if maintainers ask you for changes. It happens to core contributors
447
- too! So everyone can see the changes in the Pull request, work in your local
448
- branch and push the changes to your fork. They will automatically appear in
449
- the pull request.
450
-
451
- ### Tests
452
-
453
- An extensive test suite is included to test the library behavior and several examples. Library tests can be found in
454
- the [tests folder](https://github.com/huggingface/diffusers/tree/main/tests).
455
-
456
- We like `pytest` and `pytest-xdist` because it's faster. From the root of the
457
- repository, here's how to run tests with `pytest` for the library:
458
-
459
- ```bash
460
- $ python -m pytest -n auto --dist=loadfile -s -v ./tests/
461
- ```
462
-
463
- In fact, that's how `make test` is implemented!
464
-
465
- You can specify a smaller set of tests in order to test only the feature
466
- you're working on.
467
-
468
- By default, slow tests are skipped. Set the `RUN_SLOW` environment variable to
469
- `yes` to run them. This will download many gigabytes of models — make sure you
470
- have enough disk space and a good Internet connection, or a lot of patience!
471
-
472
- ```bash
473
- $ RUN_SLOW=yes python -m pytest -n auto --dist=loadfile -s -v ./tests/
474
- ```
475
-
476
- `unittest` is fully supported, here's how to run tests with it:
477
-
478
- ```bash
479
- $ python -m unittest discover -s tests -t . -v
480
- $ python -m unittest discover -s examples -t examples -v
481
- ```
482
-
483
- ### Syncing forked main with upstream (HuggingFace) main
484
-
485
- To avoid pinging the upstream repository which adds reference notes to each upstream PR and sends unnecessary notifications to the developers involved in these PRs,
486
- when syncing the main branch of a forked repository, please, follow these steps:
487
- 1. When possible, avoid syncing with the upstream using a branch and PR on the forked repository. Instead, merge directly into the forked main.
488
- 2. If a PR is absolutely necessary, use the following steps after checking out your branch:
489
- ```
490
- $ git checkout -b your-branch-for-syncing
491
- $ git pull --squash --no-commit upstream main
492
- $ git commit -m '<your message without GitHub references>'
493
- $ git push --set-upstream origin your-branch-for-syncing
494
- ```
495
-
496
- ### Style guide
497
-
498
- For documentation strings, 🧨 Diffusers follows the [google style](https://google.github.io/styleguide/pyguide.html).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/LICENSE DELETED
@@ -1,201 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright [yyyy] [name of copyright owner]
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/MANIFEST.in DELETED
@@ -1,2 +0,0 @@
1
- include LICENSE
2
- include src/diffusers/utils/model_card_template.md
 
 
 
diffus/Makefile DELETED
@@ -1,96 +0,0 @@
1
- .PHONY: deps_table_update modified_only_fixup extra_style_checks quality style fixup fix-copies test test-examples
2
-
3
- # make sure to test the local checkout in scripts and not the pre-installed one (don't use quotes!)
4
- export PYTHONPATH = src
5
-
6
- check_dirs := examples scripts src tests utils
7
-
8
- modified_only_fixup:
9
- $(eval modified_py_files := $(shell python utils/get_modified_files.py $(check_dirs)))
10
- @if test -n "$(modified_py_files)"; then \
11
- echo "Checking/fixing $(modified_py_files)"; \
12
- black $(modified_py_files); \
13
- ruff $(modified_py_files); \
14
- else \
15
- echo "No library .py files were modified"; \
16
- fi
17
-
18
- # Update src/diffusers/dependency_versions_table.py
19
-
20
- deps_table_update:
21
- @python setup.py deps_table_update
22
-
23
- deps_table_check_updated:
24
- @md5sum src/diffusers/dependency_versions_table.py > md5sum.saved
25
- @python setup.py deps_table_update
26
- @md5sum -c --quiet md5sum.saved || (printf "\nError: the version dependency table is outdated.\nPlease run 'make fixup' or 'make style' and commit the changes.\n\n" && exit 1)
27
- @rm md5sum.saved
28
-
29
- # autogenerating code
30
-
31
- autogenerate_code: deps_table_update
32
-
33
- # Check that the repo is in a good state
34
-
35
- repo-consistency:
36
- python utils/check_dummies.py
37
- python utils/check_repo.py
38
- python utils/check_inits.py
39
-
40
- # this target runs checks on all files
41
-
42
- quality:
43
- black --check $(check_dirs)
44
- ruff $(check_dirs)
45
- doc-builder style src/diffusers docs/source --max_len 119 --check_only --path_to_docs docs/source
46
- python utils/check_doc_toc.py
47
-
48
- # Format source code automatically and check is there are any problems left that need manual fixing
49
-
50
- extra_style_checks:
51
- python utils/custom_init_isort.py
52
- doc-builder style src/diffusers docs/source --max_len 119 --path_to_docs docs/source
53
- python utils/check_doc_toc.py --fix_and_overwrite
54
-
55
- # this target runs checks on all files and potentially modifies some of them
56
-
57
- style:
58
- black $(check_dirs)
59
- ruff $(check_dirs) --fix
60
- ${MAKE} autogenerate_code
61
- ${MAKE} extra_style_checks
62
-
63
- # Super fast fix and check target that only works on relevant modified files since the branch was made
64
-
65
- fixup: modified_only_fixup extra_style_checks autogenerate_code repo-consistency
66
-
67
- # Make marked copies of snippets of codes conform to the original
68
-
69
- fix-copies:
70
- python utils/check_copies.py --fix_and_overwrite
71
- python utils/check_dummies.py --fix_and_overwrite
72
-
73
- # Run tests for the library
74
-
75
- test:
76
- python -m pytest -n auto --dist=loadfile -s -v ./tests/
77
-
78
- # Run tests for examples
79
-
80
- test-examples:
81
- python -m pytest -n auto --dist=loadfile -s -v ./examples/pytorch/
82
-
83
-
84
- # Release stuff
85
-
86
- pre-release:
87
- python utils/release.py
88
-
89
- pre-patch:
90
- python utils/release.py --patch
91
-
92
- post-release:
93
- python utils/release.py --post_release
94
-
95
- post-patch:
96
- python utils/release.py --post_release --patch
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/PHILOSOPHY.md DELETED
@@ -1,110 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # Philosophy
14
-
15
- 🧨 Diffusers provides **state-of-the-art** pretrained diffusion models across multiple modalities.
16
- Its purpose is to serve as a **modular toolbox** for both inference and training.
17
-
18
- We aim at building a library that stands the test of time and therefore take API design very seriously.
19
-
20
- In a nutshell, Diffusers is built to be a natural extension of PyTorch. Therefore, most of our design choices are based on [PyTorch's Design Principles](https://pytorch.org/docs/stable/community/design.html#pytorch-design-philosophy). Let's go over the most important ones:
21
-
22
- ## Usability over Performance
23
-
24
- - While Diffusers has many built-in performance-enhancing features (see [Memory and Speed](https://huggingface.co/docs/diffusers/optimization/fp16)), models are always loaded with the highest precision and lowest optimization. Therefore, by default diffusion pipelines are always instantiated on CPU with float32 precision if not otherwise defined by the user. This ensures usability across different platforms and accelerators and means that no complex installations are required to run the library.
25
- - Diffusers aim at being a **light-weight** package and therefore has very few required dependencies, but many soft dependencies that can improve performance (such as `accelerate`, `safetensors`, `onnx`, etc...). We strive to keep the library as lightweight as possible so that it can be added without much concern as a dependency on other packages.
26
- - Diffusers prefers simple, self-explainable code over condensed, magic code. This means that short-hand code syntaxes such as lambda functions, and advanced PyTorch operators are often not desired.
27
-
28
- ## Simple over easy
29
-
30
- As PyTorch states, **explicit is better than implicit** and **simple is better than complex**. This design philosophy is reflected in multiple parts of the library:
31
- - We follow PyTorch's API with methods like [`DiffusionPipeline.to`](https://huggingface.co/docs/diffusers/main/en/api/diffusion_pipeline#diffusers.DiffusionPipeline.to) to let the user handle device management.
32
- - Raising concise error messages is preferred to silently correct erroneous input. Diffusers aims at teaching the user, rather than making the library as easy to use as possible.
33
- - Complex model vs. scheduler logic is exposed instead of magically handled inside. Schedulers/Samplers are separated from diffusion models with minimal dependencies on each other. This forces the user to write the unrolled denoising loop. However, the separation allows for easier debugging and gives the user more control over adapting the denoising process or switching out diffusion models or schedulers.
34
- - Separately trained components of the diffusion pipeline, *e.g.* the text encoder, the unet, and the variational autoencoder, each have their own model class. This forces the user to handle the interaction between the different model components, and the serialization format separates the model components into different files. However, this allows for easier debugging and customization. Dreambooth or textual inversion training
35
- is very simple thanks to diffusers' ability to separate single components of the diffusion pipeline.
36
-
37
- ## Tweakable, contributor-friendly over abstraction
38
-
39
- For large parts of the library, Diffusers adopts an important design principle of the [Transformers library](https://github.com/huggingface/transformers), which is to prefer copy-pasted code over hasty abstractions. This design principle is very opinionated and stands in stark contrast to popular design principles such as [Don't repeat yourself (DRY)](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself).
40
- In short, just like Transformers does for modeling files, diffusers prefers to keep an extremely low level of abstraction and very self-contained code for pipelines and schedulers.
41
- Functions, long code blocks, and even classes can be copied across multiple files which at first can look like a bad, sloppy design choice that makes the library unmaintainable.
42
- **However**, this design has proven to be extremely successful for Transformers and makes a lot of sense for community-driven, open-source machine learning libraries because:
43
- - Machine Learning is an extremely fast-moving field in which paradigms, model architectures, and algorithms are changing rapidly, which therefore makes it very difficult to define long-lasting code abstractions.
44
- - Machine Learning practitioners like to be able to quickly tweak existing code for ideation and research and therefore prefer self-contained code over one that contains many abstractions.
45
- - Open-source libraries rely on community contributions and therefore must build a library that is easy to contribute to. The more abstract the code, the more dependencies, the harder to read, and the harder to contribute to. Contributors simply stop contributing to very abstract libraries out of fear of breaking vital functionality. If contributing to a library cannot break other fundamental code, not only is it more inviting for potential new contributors, but it is also easier to review and contribute to multiple parts in parallel.
46
-
47
- At Hugging Face, we call this design the **single-file policy** which means that almost all of the code of a certain class should be written in a single, self-contained file. To read more about the philosophy, you can have a look
48
- at [this blog post](https://huggingface.co/blog/transformers-design-philosophy).
49
-
50
- In diffusers, we follow this philosophy for both pipelines and schedulers, but only partly for diffusion models. The reason we don't follow this design fully for diffusion models is because almost all diffusion pipelines, such
51
- as [DDPM](https://huggingface.co/docs/diffusers/v0.12.0/en/api/pipelines/ddpm), [Stable Diffusion](https://huggingface.co/docs/diffusers/v0.12.0/en/api/pipelines/stable_diffusion/overview#stable-diffusion-pipelines), [UnCLIP (Dalle-2)](https://huggingface.co/docs/diffusers/v0.12.0/en/api/pipelines/unclip#overview) and [Imagen](https://imagen.research.google/) all rely on the same diffusion model, the [UNet](https://huggingface.co/docs/diffusers/api/models#diffusers.UNet2DConditionModel).
52
-
53
- Great, now you should have generally understood why 🧨 Diffusers is designed the way it is 🤗.
54
- We try to apply these design principles consistently across the library. Nevertheless, there are some minor exceptions to the philosophy or some unlucky design choices. If you have feedback regarding the design, we would ❤️ to hear it [directly on GitHub](https://github.com/huggingface/diffusers/issues/new?assignees=&labels=&template=feedback.md&title=).
55
-
56
- ## Design Philosophy in Details
57
-
58
- Now, let's look a bit into the nitty-gritty details of the design philosophy. Diffusers essentially consist of three major classes, [pipelines](https://github.com/huggingface/diffusers/tree/main/src/diffusers/pipelines), [models](https://github.com/huggingface/diffusers/tree/main/src/diffusers/models), and [schedulers](https://github.com/huggingface/diffusers/tree/main/src/diffusers/schedulers).
59
- Let's walk through more in-detail design decisions for each class.
60
-
61
- ### Pipelines
62
-
63
- Pipelines are designed to be easy to use (therefore do not follow [*Simple over easy*](#simple-over-easy) 100%)), are not feature complete, and should loosely be seen as examples of how to use [models](#models) and [schedulers](#schedulers) for inference.
64
-
65
- The following design principles are followed:
66
- - Pipelines follow the single-file policy. All pipelines can be found in individual directories under src/diffusers/pipelines. One pipeline folder corresponds to one diffusion paper/project/release. Multiple pipeline files can be gathered in one pipeline folder, as it’s done for [`src/diffusers/pipelines/stable-diffusion`](https://github.com/huggingface/diffusers/tree/main/src/diffusers/pipelines/stable_diffusion). If pipelines share similar functionality, one can make use of the [#Copied from mechanism](https://github.com/huggingface/diffusers/blob/125d783076e5bd9785beb05367a2d2566843a271/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py#L251).
67
- - Pipelines all inherit from [`DiffusionPipeline`]
68
- - Every pipeline consists of different model and scheduler components, that are documented in the [`model_index.json` file](https://huggingface.co/runwayml/stable-diffusion-v1-5/blob/main/model_index.json), are accessible under the same name as attributes of the pipeline and can be shared between pipelines with [`DiffusionPipeline.components`](https://huggingface.co/docs/diffusers/main/en/api/diffusion_pipeline#diffusers.DiffusionPipeline.components) function.
69
- - Every pipeline should be loadable via the [`DiffusionPipeline.from_pretrained`](https://huggingface.co/docs/diffusers/main/en/api/diffusion_pipeline#diffusers.DiffusionPipeline.from_pretrained) function.
70
- - Pipelines should be used **only** for inference.
71
- - Pipelines should be very readable, self-explanatory, and easy to tweak.
72
- - Pipelines should be designed to build on top of each other and be easy to integrate into higher-level APIs.
73
- - Pipelines are **not** intended to be feature-complete user interfaces. For future complete user interfaces one should rather have a look at [InvokeAI](https://github.com/invoke-ai/InvokeAI), [Diffuzers](https://github.com/abhishekkrthakur/diffuzers), and [lama-cleaner](https://github.com/Sanster/lama-cleaner)
74
- - Every pipeline should have one and only one way to run it via a `__call__` method. The naming of the `__call__` arguments should be shared across all pipelines.
75
- - Pipelines should be named after the task they are intended to solve.
76
- - In almost all cases, novel diffusion pipelines shall be implemented in a new pipeline folder/file.
77
-
78
- ### Models
79
-
80
- Models are designed as configurable toolboxes that are natural extensions of [PyTorch's Module class](https://pytorch.org/docs/stable/generated/torch.nn.Module.html). They only partly follow the **single-file policy**.
81
-
82
- The following design principles are followed:
83
- - Models correspond to **a type of model architecture**. *E.g.* the [`UNet2DConditionModel`] class is used for all UNet variations that expect 2D image inputs and are conditioned on some context.
84
- - All models can be found in [`src/diffusers/models`](https://github.com/huggingface/diffusers/tree/main/src/diffusers/models) and every model architecture shall be defined in its file, e.g. [`unet_2d_condition.py`](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/unet_2d_condition.py), [`transformer_2d.py`](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/transformer_2d.py), etc...
85
- - Models **do not** follow the single-file policy and should make use of smaller model building blocks, such as [`attention.py`](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention.py), [`resnet.py`](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/resnet.py), [`embeddings.py`](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/embeddings.py), etc... **Note**: This is in stark contrast to Transformers' modeling files and shows that models do not really follow the single-file policy.
86
- - Models intend to expose complexity, just like PyTorch's module does, and give clear error messages.
87
- - Models all inherit from `ModelMixin` and `ConfigMixin`.
88
- - Models can be optimized for performance when it doesn’t demand major code changes, keeps backward compatibility, and gives significant memory or compute gain.
89
- - Models should by default have the highest precision and lowest performance setting.
90
- - To integrate new model checkpoints whose general architecture can be classified as an architecture that already exists in Diffusers, the existing model architecture shall be adapted to make it work with the new checkpoint. One should only create a new file if the model architecture is fundamentally different.
91
- - Models should be designed to be easily extendable to future changes. This can be achieved by limiting public function arguments, configuration arguments, and "foreseeing" future changes, *e.g.* it is usually better to add `string` "...type" arguments that can easily be extended to new future types instead of boolean `is_..._type` arguments. Only the minimum amount of changes shall be made to existing architectures to make a new model checkpoint work.
92
- - The model design is a difficult trade-off between keeping code readable and concise and supporting many model checkpoints. For most parts of the modeling code, classes shall be adapted for new model checkpoints, while there are some exceptions where it is preferred to add new classes to make sure the code is kept concise and
93
- readable longterm, such as [UNet blocks](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/unet_2d_blocks.py) and [Attention processors](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/cross_attention.py).
94
-
95
- ### Schedulers
96
-
97
- Schedulers are responsible to guide the denoising process for inference as well as to define a noise schedule for training. They are designed as individual classes with loadable configuration files and strongly follow the **single-file policy**.
98
-
99
- The following design principles are followed:
100
- - All schedulers are found in [`src/diffusers/schedulers`](https://github.com/huggingface/diffusers/tree/main/src/diffusers/schedulers).
101
- - Schedulers are **not** allowed to import from large utils files and shall be kept very self-contained.
102
- - One scheduler python file corresponds to one scheduler algorithm (as might be defined in a paper).
103
- - If schedulers share similar functionalities, we can make use of the `#Copied from` mechanism.
104
- - Schedulers all inherit from `SchedulerMixin` and `ConfigMixin`.
105
- - Schedulers can be easily swapped out with the [`ConfigMixin.from_config`](https://huggingface.co/docs/diffusers/main/en/api/configuration#diffusers.ConfigMixin.from_config) method as explained in detail [here](./using-diffusers/schedulers.mdx).
106
- - Every scheduler has to have a `set_num_inference_steps`, and a `step` function. `set_num_inference_steps(...)` has to be called before every denoising process, *i.e.* before `step(...)` is called.
107
- - Every scheduler exposes the timesteps to be "looped over" via a `timesteps` attribute, which is an array of timesteps the model will be called upon
108
- - The `step(...)` function takes a predicted model output and the "current" sample (x_t) and returns the "previous", slightly more denoised sample (x_t-1).
109
- - Given the complexity of diffusion schedulers, the `step` function does not expose all the complexity and can be a bit of a "black box".
110
- - In almost all cases, novel schedulers shall be implemented in a new scheduling file.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/README.md DELETED
@@ -1,185 +0,0 @@
1
- <p align="center">
2
- <br>
3
- <img src="./docs/source/en/imgs/diffusers_library.jpg" width="400"/>
4
- <br>
5
- <p>
6
- <p align="center">
7
- <a href="https://github.com/huggingface/diffusers/blob/main/LICENSE">
8
- <img alt="GitHub" src="https://img.shields.io/github/license/huggingface/datasets.svg?color=blue">
9
- </a>
10
- <a href="https://github.com/huggingface/diffusers/releases">
11
- <img alt="GitHub release" src="https://img.shields.io/github/release/huggingface/diffusers.svg">
12
- </a>
13
- <a href="CODE_OF_CONDUCT.md">
14
- <img alt="Contributor Covenant" src="https://img.shields.io/badge/Contributor%20Covenant-2.0-4baaaa.svg">
15
- </a>
16
- </p>
17
-
18
- 🤗 Diffusers is the go-to library for state-of-the-art pretrained diffusion models for generating images, audio, and even 3D structures of molecules. Whether you're looking for a simple inference solution or training your own diffusion models, 🤗 Diffusers is a modular toolbox that supports both. Our library is designed with a focus on [usability over performance](https://huggingface.co/docs/diffusers/conceptual/philosophy#usability-over-performance), [simple over easy](https://huggingface.co/docs/diffusers/conceptual/philosophy#simple-over-easy), and [customizability over abstractions](https://huggingface.co/docs/diffusers/conceptual/philosophy#tweakable-contributorfriendly-over-abstraction).
19
-
20
- 🤗 Diffusers offers three core components:
21
-
22
- - State-of-the-art [diffusion pipelines](https://huggingface.co/docs/diffusers/api/pipelines/overview) that can be run in inference with just a few lines of code.
23
- - Interchangeable noise [schedulers](https://huggingface.co/docs/diffusers/api/schedulers/overview) for different diffusion speeds and output quality.
24
- - Pretrained [models](https://huggingface.co/docs/diffusers/api/models) that can be used as building blocks, and combined with schedulers, for creating your own end-to-end diffusion systems.
25
-
26
- ## Installation
27
-
28
- We recommend installing 🤗 Diffusers in a virtual environment from PyPi or Conda. For more details about installing [PyTorch](https://pytorch.org/get-started/locally/) and [Flax](https://flax.readthedocs.io/en/latest/installation.html), please refer to their official documentation.
29
-
30
- ### PyTorch
31
-
32
- With `pip` (official package):
33
-
34
- ```bash
35
- pip install --upgrade diffusers[torch]
36
- ```
37
-
38
- With `conda` (maintained by the community):
39
-
40
- ```sh
41
- conda install -c conda-forge diffusers
42
- ```
43
-
44
- ### Flax
45
-
46
- With `pip` (official package):
47
-
48
- ```bash
49
- pip install --upgrade diffusers[flax]
50
- ```
51
-
52
- ### Apple Silicon (M1/M2) support
53
-
54
- Please refer to the [How to use Stable Diffusion in Apple Silicon](https://huggingface.co/docs/diffusers/optimization/mps) guide.
55
-
56
- ## Quickstart
57
-
58
- Generating outputs is super easy with 🤗 Diffusers. To generate an image from text, use the `from_pretrained` method to load any pretrained diffusion model (browse the [Hub](https://huggingface.co/models?library=diffusers&sort=downloads) for 4000+ checkpoints):
59
-
60
- ```python
61
- from diffusers import DiffusionPipeline
62
-
63
- pipeline = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5")
64
- pipeline.to("cuda")
65
- pipeline("An image of a squirrel in Picasso style").images[0]
66
- ```
67
-
68
- You can also dig into the models and schedulers toolbox to build your own diffusion system:
69
-
70
- ```python
71
- from diffusers import DDPMScheduler, UNet2DModel
72
- from PIL import Image
73
- import torch
74
- import numpy as np
75
-
76
- scheduler = DDPMScheduler.from_pretrained("google/ddpm-cat-256")
77
- model = UNet2DModel.from_pretrained("google/ddpm-cat-256").to("cuda")
78
- scheduler.set_timesteps(50)
79
-
80
- sample_size = model.config.sample_size
81
- noise = torch.randn((1, 3, sample_size, sample_size)).to("cuda")
82
- input = noise
83
-
84
- for t in scheduler.timesteps:
85
- with torch.no_grad():
86
- noisy_residual = model(input, t).sample
87
- prev_noisy_sample = scheduler.step(noisy_residual, t, input).prev_sample
88
- input = prev_noisy_sample
89
-
90
- image = (input / 2 + 0.5).clamp(0, 1)
91
- image = image.cpu().permute(0, 2, 3, 1).numpy()[0]
92
- image = Image.fromarray((image * 255).round().astype("uint8"))
93
- image
94
- ```
95
-
96
- Check out the [Quickstart](https://huggingface.co/docs/diffusers/quicktour) to launch your diffusion journey today!
97
-
98
- ## How to navigate the documentation
99
-
100
- | **Documentation** | **What can I learn?** |
101
- |---------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
102
- | Tutorial | A basic crash course for learning how to use the library's most important features like using models and schedulers to build your own diffusion system, and training your own diffusion model. |
103
- | Loading | Guides for how to load and configure all the components (pipelines, models, and schedulers) of the library, as well as how to use different schedulers. |
104
- | Pipelines for inference | Guides for how to use pipelines for different inference tasks, batched generation, controlling generated outputs and randomness, and how to contribute a pipeline to the library. |
105
- | Optimization | Guides for how to optimize your diffusion model to run faster and consume less memory. |
106
- | [Training](https://huggingface.co/docs/diffusers/training/overview) | Guides for how to train a diffusion model for different tasks with different training techniques. |
107
-
108
- ## Supported pipelines
109
-
110
- | Pipeline | Paper | Tasks |
111
- |---|---|:---:|
112
- | [alt_diffusion](./api/pipelines/alt_diffusion) | [**AltDiffusion**](https://arxiv.org/abs/2211.06679) | Image-to-Image Text-Guided Generation |
113
- | [audio_diffusion](./api/pipelines/audio_diffusion) | [**Audio Diffusion**](https://github.com/teticio/audio-diffusion.git) | Unconditional Audio Generation |
114
- | [controlnet](./api/pipelines/stable_diffusion/controlnet) | [**ControlNet with Stable Diffusion**](https://arxiv.org/abs/2302.05543) | Image-to-Image Text-Guided Generation |
115
- | [cycle_diffusion](./api/pipelines/cycle_diffusion) | [**Cycle Diffusion**](https://arxiv.org/abs/2210.05559) | Image-to-Image Text-Guided Generation |
116
- | [dance_diffusion](./api/pipelines/dance_diffusion) | [**Dance Diffusion**](https://github.com/williamberman/diffusers.git) | Unconditional Audio Generation |
117
- | [ddpm](./api/pipelines/ddpm) | [**Denoising Diffusion Probabilistic Models**](https://arxiv.org/abs/2006.11239) | Unconditional Image Generation |
118
- | [ddim](./api/pipelines/ddim) | [**Denoising Diffusion Implicit Models**](https://arxiv.org/abs/2010.02502) | Unconditional Image Generation |
119
- | [latent_diffusion](./api/pipelines/latent_diffusion) | [**High-Resolution Image Synthesis with Latent Diffusion Models**](https://arxiv.org/abs/2112.10752)| Text-to-Image Generation |
120
- | [latent_diffusion](./api/pipelines/latent_diffusion) | [**High-Resolution Image Synthesis with Latent Diffusion Models**](https://arxiv.org/abs/2112.10752)| Super Resolution Image-to-Image |
121
- | [latent_diffusion_uncond](./api/pipelines/latent_diffusion_uncond) | [**High-Resolution Image Synthesis with Latent Diffusion Models**](https://arxiv.org/abs/2112.10752) | Unconditional Image Generation |
122
- | [paint_by_example](./api/pipelines/paint_by_example) | [**Paint by Example: Exemplar-based Image Editing with Diffusion Models**](https://arxiv.org/abs/2211.13227) | Image-Guided Image Inpainting |
123
- | [pndm](./api/pipelines/pndm) | [**Pseudo Numerical Methods for Diffusion Models on Manifolds**](https://arxiv.org/abs/2202.09778) | Unconditional Image Generation |
124
- | [score_sde_ve](./api/pipelines/score_sde_ve) | [**Score-Based Generative Modeling through Stochastic Differential Equations**](https://openreview.net/forum?id=PxTIG12RRHS) | Unconditional Image Generation |
125
- | [score_sde_vp](./api/pipelines/score_sde_vp) | [**Score-Based Generative Modeling through Stochastic Differential Equations**](https://openreview.net/forum?id=PxTIG12RRHS) | Unconditional Image Generation |
126
- | [semantic_stable_diffusion](./api/pipelines/semantic_stable_diffusion) | [**Semantic Guidance**](https://arxiv.org/abs/2301.12247) | Text-Guided Generation |
127
- | [stable_diffusion_text2img](./api/pipelines/stable_diffusion/text2img) | [**Stable Diffusion**](https://stability.ai/blog/stable-diffusion-public-release) | Text-to-Image Generation |
128
- | [stable_diffusion_img2img](./api/pipelines/stable_diffusion/img2img) | [**Stable Diffusion**](https://stability.ai/blog/stable-diffusion-public-release) | Image-to-Image Text-Guided Generation |
129
- | [stable_diffusion_inpaint](./api/pipelines/stable_diffusion/inpaint) | [**Stable Diffusion**](https://stability.ai/blog/stable-diffusion-public-release) | Text-Guided Image Inpainting |
130
- | [stable_diffusion_panorama](./api/pipelines/stable_diffusion/panorama) | [**MultiDiffusion**](https://multidiffusion.github.io/) | Text-to-Panorama Generation |
131
- | [stable_diffusion_pix2pix](./api/pipelines/stable_diffusion/pix2pix) | [**InstructPix2Pix**](https://github.com/timothybrooks/instruct-pix2pix) | Text-Guided Image Editing|
132
- | [stable_diffusion_pix2pix_zero](./api/pipelines/stable_diffusion/pix2pix_zero) | [**Zero-shot Image-to-Image Translation**](https://pix2pixzero.github.io/) | Text-Guided Image Editing |
133
- | [stable_diffusion_attend_and_excite](./api/pipelines/stable_diffusion/attend_and_excite) | [**Attend and Excite for Stable Diffusion**](https://attendandexcite.github.io/Attend-and-Excite/) | Text-to-Image Generation |
134
- | [stable_diffusion_self_attention_guidance](./api/pipelines/stable_diffusion/self_attention_guidance) | [**Self-Attention Guidance**](https://ku-cvlab.github.io/Self-Attention-Guidance) | Text-to-Image Generation |
135
- | [stable_diffusion_image_variation](./stable_diffusion/image_variation) | [**Stable Diffusion Image Variations**](https://github.com/LambdaLabsML/lambda-diffusers#stable-diffusion-image-variations) | Image-to-Image Generation |
136
- | [stable_diffusion_latent_upscale](./stable_diffusion/latent_upscale) | [**Stable Diffusion Latent Upscaler**](https://twitter.com/StabilityAI/status/1590531958815064065) | Text-Guided Super Resolution Image-to-Image |
137
- | [stable_diffusion_2](./api/pipelines/stable_diffusion_2) | [**Stable Diffusion 2**](https://stability.ai/blog/stable-diffusion-v2-release) | Text-to-Image Generation |
138
- | [stable_diffusion_2](./api/pipelines/stable_diffusion_2) | [**Stable Diffusion 2**](https://stability.ai/blog/stable-diffusion-v2-release) | Text-Guided Image Inpainting |
139
- | [stable_diffusion_2](./api/pipelines/stable_diffusion_2) | [**Depth-Conditional Stable Diffusion**](https://github.com/Stability-AI/stablediffusion#depth-conditional-stable-diffusion) | Depth-to-Image Generation |
140
- | [stable_diffusion_2](./api/pipelines/stable_diffusion_2) | [**Stable Diffusion 2**](https://stability.ai/blog/stable-diffusion-v2-release) | Text-Guided Super Resolution Image-to-Image |
141
- | [stable_diffusion_safe](./api/pipelines/stable_diffusion_safe) | [**Safe Stable Diffusion**](https://arxiv.org/abs/2211.05105) | Text-Guided Generation |
142
- | [stable_unclip](./stable_unclip) | **Stable unCLIP** | Text-to-Image Generation |
143
- | [stable_unclip](./stable_unclip) | **Stable unCLIP** | Image-to-Image Text-Guided Generation |
144
- | [stochastic_karras_ve](./api/pipelines/stochastic_karras_ve) | [**Elucidating the Design Space of Diffusion-Based Generative Models**](https://arxiv.org/abs/2206.00364) | Unconditional Image Generation |
145
- | [unclip](./api/pipelines/unclip) | [Hierarchical Text-Conditional Image Generation with CLIP Latents](https://arxiv.org/abs/2204.06125) | Text-to-Image Generation |
146
- | [versatile_diffusion](./api/pipelines/versatile_diffusion) | [Versatile Diffusion: Text, Images and Variations All in One Diffusion Model](https://arxiv.org/abs/2211.08332) | Text-to-Image Generation |
147
- | [versatile_diffusion](./api/pipelines/versatile_diffusion) | [Versatile Diffusion: Text, Images and Variations All in One Diffusion Model](https://arxiv.org/abs/2211.08332) | Image Variations Generation |
148
- | [versatile_diffusion](./api/pipelines/versatile_diffusion) | [Versatile Diffusion: Text, Images and Variations All in One Diffusion Model](https://arxiv.org/abs/2211.08332) | Dual Image and Text Guided Generation |
149
- | [vq_diffusion](./api/pipelines/vq_diffusion) | [Vector Quantized Diffusion Model for Text-to-Image Synthesis](https://arxiv.org/abs/2111.14822) | Text-to-Image Generation |
150
-
151
- ## Contribution
152
-
153
- We ❤️ contributions from the open-source community!
154
- If you want to contribute to this library, please check out our [Contribution guide](https://github.com/huggingface/diffusers/blob/main/CONTRIBUTING.md).
155
- You can look out for [issues](https://github.com/huggingface/diffusers/issues) you'd like to tackle to contribute to the library.
156
- - See [Good first issues](https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) for general opportunities to contribute
157
- - See [New model/pipeline](https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22New+pipeline%2Fmodel%22) to contribute exciting new diffusion models / diffusion pipelines
158
- - See [New scheduler](https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22New+scheduler%22)
159
-
160
- Also, say 👋 in our public Discord channel <a href="https://discord.gg/G7tWnz98XR"><img alt="Join us on Discord" src="https://img.shields.io/discord/823813159592001537?color=5865F2&logo=discord&logoColor=white"></a>. We discuss the hottest trends about diffusion models, help each other with contributions, personal projects or
161
- just hang out ☕.
162
-
163
- ## Credits
164
-
165
- This library concretizes previous work by many different authors and would not have been possible without their great research and implementations. We'd like to thank, in particular, the following implementations which have helped us in our development and without which the API could not have been as polished today:
166
-
167
- - @CompVis' latent diffusion models library, available [here](https://github.com/CompVis/latent-diffusion)
168
- - @hojonathanho original DDPM implementation, available [here](https://github.com/hojonathanho/diffusion) as well as the extremely useful translation into PyTorch by @pesser, available [here](https://github.com/pesser/pytorch_diffusion)
169
- - @ermongroup's DDIM implementation, available [here](https://github.com/ermongroup/ddim)
170
- - @yang-song's Score-VE and Score-VP implementations, available [here](https://github.com/yang-song/score_sde_pytorch)
171
-
172
- We also want to thank @heejkoo for the very helpful overview of papers, code and resources on diffusion models, available [here](https://github.com/heejkoo/Awesome-Diffusion-Models) as well as @crowsonkb and @rromb for useful discussions and insights.
173
-
174
- ## Citation
175
-
176
- ```bibtex
177
- @misc{von-platen-etal-2022-diffusers,
178
- author = {Patrick von Platen and Suraj Patil and Anton Lozhkov and Pedro Cuenca and Nathan Lambert and Kashif Rasul and Mishig Davaadorj and Thomas Wolf},
179
- title = {Diffusers: State-of-the-art diffusion models},
180
- year = {2022},
181
- publisher = {GitHub},
182
- journal = {GitHub repository},
183
- howpublished = {\url{https://github.com/huggingface/diffusers}}
184
- }
185
- ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/_typos.toml DELETED
@@ -1,13 +0,0 @@
1
- # Files for typos
2
- # Instruction: https://github.com/marketplace/actions/typos-action#getting-started
3
-
4
- [default.extend-identifiers]
5
-
6
- [default.extend-words]
7
- NIN="NIN" # NIN is used in scripts/convert_ncsnpp_original_checkpoint_to_diffusers.py
8
- nd="np" # nd may be np (numpy)
9
- parms="parms" # parms is used in scripts/convert_original_stable_diffusion_to_diffusers.py
10
-
11
-
12
- [files]
13
- extend-exclude = ["_typos.toml"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docker/diffusers-flax-cpu/Dockerfile DELETED
@@ -1,44 +0,0 @@
1
- FROM ubuntu:20.04
2
- LABEL maintainer="Hugging Face"
3
- LABEL repository="diffusers"
4
-
5
- ENV DEBIAN_FRONTEND=noninteractive
6
-
7
- RUN apt update && \
8
- apt install -y bash \
9
- build-essential \
10
- git \
11
- git-lfs \
12
- curl \
13
- ca-certificates \
14
- libsndfile1-dev \
15
- python3.8 \
16
- python3-pip \
17
- python3.8-venv && \
18
- rm -rf /var/lib/apt/lists
19
-
20
- # make sure to use venv
21
- RUN python3 -m venv /opt/venv
22
- ENV PATH="/opt/venv/bin:$PATH"
23
-
24
- # pre-install the heavy dependencies (these can later be overridden by the deps from setup.py)
25
- # follow the instructions here: https://cloud.google.com/tpu/docs/run-in-container#train_a_jax_model_in_a_docker_container
26
- RUN python3 -m pip install --no-cache-dir --upgrade pip && \
27
- python3 -m pip install --upgrade --no-cache-dir \
28
- clu \
29
- "jax[cpu]>=0.2.16,!=0.3.2" \
30
- "flax>=0.4.1" \
31
- "jaxlib>=0.1.65" && \
32
- python3 -m pip install --no-cache-dir \
33
- accelerate \
34
- datasets \
35
- hf-doc-builder \
36
- huggingface-hub \
37
- Jinja2 \
38
- librosa \
39
- numpy \
40
- scipy \
41
- tensorboard \
42
- transformers
43
-
44
- CMD ["/bin/bash"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docker/diffusers-flax-tpu/Dockerfile DELETED
@@ -1,46 +0,0 @@
1
- FROM ubuntu:20.04
2
- LABEL maintainer="Hugging Face"
3
- LABEL repository="diffusers"
4
-
5
- ENV DEBIAN_FRONTEND=noninteractive
6
-
7
- RUN apt update && \
8
- apt install -y bash \
9
- build-essential \
10
- git \
11
- git-lfs \
12
- curl \
13
- ca-certificates \
14
- libsndfile1-dev \
15
- python3.8 \
16
- python3-pip \
17
- python3.8-venv && \
18
- rm -rf /var/lib/apt/lists
19
-
20
- # make sure to use venv
21
- RUN python3 -m venv /opt/venv
22
- ENV PATH="/opt/venv/bin:$PATH"
23
-
24
- # pre-install the heavy dependencies (these can later be overridden by the deps from setup.py)
25
- # follow the instructions here: https://cloud.google.com/tpu/docs/run-in-container#train_a_jax_model_in_a_docker_container
26
- RUN python3 -m pip install --no-cache-dir --upgrade pip && \
27
- python3 -m pip install --no-cache-dir \
28
- "jax[tpu]>=0.2.16,!=0.3.2" \
29
- -f https://storage.googleapis.com/jax-releases/libtpu_releases.html && \
30
- python3 -m pip install --upgrade --no-cache-dir \
31
- clu \
32
- "flax>=0.4.1" \
33
- "jaxlib>=0.1.65" && \
34
- python3 -m pip install --no-cache-dir \
35
- accelerate \
36
- datasets \
37
- hf-doc-builder \
38
- huggingface-hub \
39
- Jinja2 \
40
- librosa \
41
- numpy \
42
- scipy \
43
- tensorboard \
44
- transformers
45
-
46
- CMD ["/bin/bash"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docker/diffusers-onnxruntime-cpu/Dockerfile DELETED
@@ -1,44 +0,0 @@
1
- FROM ubuntu:20.04
2
- LABEL maintainer="Hugging Face"
3
- LABEL repository="diffusers"
4
-
5
- ENV DEBIAN_FRONTEND=noninteractive
6
-
7
- RUN apt update && \
8
- apt install -y bash \
9
- build-essential \
10
- git \
11
- git-lfs \
12
- curl \
13
- ca-certificates \
14
- libsndfile1-dev \
15
- python3.8 \
16
- python3-pip \
17
- python3.8-venv && \
18
- rm -rf /var/lib/apt/lists
19
-
20
- # make sure to use venv
21
- RUN python3 -m venv /opt/venv
22
- ENV PATH="/opt/venv/bin:$PATH"
23
-
24
- # pre-install the heavy dependencies (these can later be overridden by the deps from setup.py)
25
- RUN python3 -m pip install --no-cache-dir --upgrade pip && \
26
- python3 -m pip install --no-cache-dir \
27
- torch \
28
- torchvision \
29
- torchaudio \
30
- onnxruntime \
31
- --extra-index-url https://download.pytorch.org/whl/cpu && \
32
- python3 -m pip install --no-cache-dir \
33
- accelerate \
34
- datasets \
35
- hf-doc-builder \
36
- huggingface-hub \
37
- Jinja2 \
38
- librosa \
39
- numpy \
40
- scipy \
41
- tensorboard \
42
- transformers
43
-
44
- CMD ["/bin/bash"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docker/diffusers-onnxruntime-cuda/Dockerfile DELETED
@@ -1,44 +0,0 @@
1
- FROM nvidia/cuda:11.6.2-cudnn8-devel-ubuntu20.04
2
- LABEL maintainer="Hugging Face"
3
- LABEL repository="diffusers"
4
-
5
- ENV DEBIAN_FRONTEND=noninteractive
6
-
7
- RUN apt update && \
8
- apt install -y bash \
9
- build-essential \
10
- git \
11
- git-lfs \
12
- curl \
13
- ca-certificates \
14
- libsndfile1-dev \
15
- python3.8 \
16
- python3-pip \
17
- python3.8-venv && \
18
- rm -rf /var/lib/apt/lists
19
-
20
- # make sure to use venv
21
- RUN python3 -m venv /opt/venv
22
- ENV PATH="/opt/venv/bin:$PATH"
23
-
24
- # pre-install the heavy dependencies (these can later be overridden by the deps from setup.py)
25
- RUN python3 -m pip install --no-cache-dir --upgrade pip && \
26
- python3 -m pip install --no-cache-dir \
27
- torch \
28
- torchvision \
29
- torchaudio \
30
- "onnxruntime-gpu>=1.13.1" \
31
- --extra-index-url https://download.pytorch.org/whl/cu117 && \
32
- python3 -m pip install --no-cache-dir \
33
- accelerate \
34
- datasets \
35
- hf-doc-builder \
36
- huggingface-hub \
37
- Jinja2 \
38
- librosa \
39
- numpy \
40
- scipy \
41
- tensorboard \
42
- transformers
43
-
44
- CMD ["/bin/bash"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docker/diffusers-pytorch-cpu/Dockerfile DELETED
@@ -1,43 +0,0 @@
1
- FROM ubuntu:20.04
2
- LABEL maintainer="Hugging Face"
3
- LABEL repository="diffusers"
4
-
5
- ENV DEBIAN_FRONTEND=noninteractive
6
-
7
- RUN apt update && \
8
- apt install -y bash \
9
- build-essential \
10
- git \
11
- git-lfs \
12
- curl \
13
- ca-certificates \
14
- libsndfile1-dev \
15
- python3.8 \
16
- python3-pip \
17
- python3.8-venv && \
18
- rm -rf /var/lib/apt/lists
19
-
20
- # make sure to use venv
21
- RUN python3 -m venv /opt/venv
22
- ENV PATH="/opt/venv/bin:$PATH"
23
-
24
- # pre-install the heavy dependencies (these can later be overridden by the deps from setup.py)
25
- RUN python3 -m pip install --no-cache-dir --upgrade pip && \
26
- python3 -m pip install --no-cache-dir \
27
- torch \
28
- torchvision \
29
- torchaudio \
30
- --extra-index-url https://download.pytorch.org/whl/cpu && \
31
- python3 -m pip install --no-cache-dir \
32
- accelerate \
33
- datasets \
34
- hf-doc-builder \
35
- huggingface-hub \
36
- Jinja2 \
37
- librosa \
38
- numpy \
39
- scipy \
40
- tensorboard \
41
- transformers
42
-
43
- CMD ["/bin/bash"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docker/diffusers-pytorch-cuda/Dockerfile DELETED
@@ -1,42 +0,0 @@
1
- FROM nvidia/cuda:11.7.1-cudnn8-runtime-ubuntu20.04
2
- LABEL maintainer="Hugging Face"
3
- LABEL repository="diffusers"
4
-
5
- ENV DEBIAN_FRONTEND=noninteractive
6
-
7
- RUN apt update && \
8
- apt install -y bash \
9
- build-essential \
10
- git \
11
- git-lfs \
12
- curl \
13
- ca-certificates \
14
- libsndfile1-dev \
15
- python3.8 \
16
- python3-pip \
17
- python3.8-venv && \
18
- rm -rf /var/lib/apt/lists
19
-
20
- # make sure to use venv
21
- RUN python3 -m venv /opt/venv
22
- ENV PATH="/opt/venv/bin:$PATH"
23
-
24
- # pre-install the heavy dependencies (these can later be overridden by the deps from setup.py)
25
- RUN python3 -m pip install --no-cache-dir --upgrade pip && \
26
- python3 -m pip install --no-cache-dir \
27
- torch \
28
- torchvision \
29
- torchaudio \
30
- python3 -m pip install --no-cache-dir \
31
- accelerate \
32
- datasets \
33
- hf-doc-builder \
34
- huggingface-hub \
35
- Jinja2 \
36
- librosa \
37
- numpy \
38
- scipy \
39
- tensorboard \
40
- transformers
41
-
42
- CMD ["/bin/bash"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/README.md DELETED
@@ -1,271 +0,0 @@
1
- <!---
2
- Copyright 2023- The HuggingFace Team. All rights reserved.
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- -->
16
-
17
- # Generating the documentation
18
-
19
- To generate the documentation, you first have to build it. Several packages are necessary to build the doc,
20
- you can install them with the following command, at the root of the code repository:
21
-
22
- ```bash
23
- pip install -e ".[docs]"
24
- ```
25
-
26
- Then you need to install our open source documentation builder tool:
27
-
28
- ```bash
29
- pip install git+https://github.com/huggingface/doc-builder
30
- ```
31
-
32
- ---
33
- **NOTE**
34
-
35
- You only need to generate the documentation to inspect it locally (if you're planning changes and want to
36
- check how they look before committing for instance). You don't have to commit the built documentation.
37
-
38
- ---
39
-
40
- ## Previewing the documentation
41
-
42
- To preview the docs, first install the `watchdog` module with:
43
-
44
- ```bash
45
- pip install watchdog
46
- ```
47
-
48
- Then run the following command:
49
-
50
- ```bash
51
- doc-builder preview {package_name} {path_to_docs}
52
- ```
53
-
54
- For example:
55
-
56
- ```bash
57
- doc-builder preview diffusers docs/source/en
58
- ```
59
-
60
- The docs will be viewable at [http://localhost:3000](http://localhost:3000). You can also preview the docs once you have opened a PR. You will see a bot add a comment to a link where the documentation with your changes lives.
61
-
62
- ---
63
- **NOTE**
64
-
65
- The `preview` command only works with existing doc files. When you add a completely new file, you need to update `_toctree.yml` & restart `preview` command (`ctrl-c` to stop it & call `doc-builder preview ...` again).
66
-
67
- ---
68
-
69
- ## Adding a new element to the navigation bar
70
-
71
- Accepted files are Markdown (.md or .mdx).
72
-
73
- Create a file with its extension and put it in the source directory. You can then link it to the toc-tree by putting
74
- the filename without the extension in the [`_toctree.yml`](https://github.com/huggingface/diffusers/blob/main/docs/source/_toctree.yml) file.
75
-
76
- ## Renaming section headers and moving sections
77
-
78
- It helps to keep the old links working when renaming the section header and/or moving sections from one document to another. This is because the old links are likely to be used in Issues, Forums, and Social media and it'd make for a much more superior user experience if users reading those months later could still easily navigate to the originally intended information.
79
-
80
- Therefore, we simply keep a little map of moved sections at the end of the document where the original section was. The key is to preserve the original anchor.
81
-
82
- So if you renamed a section from: "Section A" to "Section B", then you can add at the end of the file:
83
-
84
- ```
85
- Sections that were moved:
86
-
87
- [ <a href="#section-b">Section A</a><a id="section-a"></a> ]
88
- ```
89
- and of course, if you moved it to another file, then:
90
-
91
- ```
92
- Sections that were moved:
93
-
94
- [ <a href="../new-file#section-b">Section A</a><a id="section-a"></a> ]
95
- ```
96
-
97
- Use the relative style to link to the new file so that the versioned docs continue to work.
98
-
99
- For an example of a rich moved section set please see the very end of [the transformers Trainer doc](https://github.com/huggingface/transformers/blob/main/docs/source/en/main_classes/trainer.mdx).
100
-
101
-
102
- ## Writing Documentation - Specification
103
-
104
- The `huggingface/diffusers` documentation follows the
105
- [Google documentation](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html) style for docstrings,
106
- although we can write them directly in Markdown.
107
-
108
- ### Adding a new tutorial
109
-
110
- Adding a new tutorial or section is done in two steps:
111
-
112
- - Add a new file under `docs/source`. This file can either be ReStructuredText (.rst) or Markdown (.md).
113
- - Link that file in `docs/source/_toctree.yml` on the correct toc-tree.
114
-
115
- Make sure to put your new file under the proper section. It's unlikely to go in the first section (*Get Started*), so
116
- depending on the intended targets (beginners, more advanced users, or researchers) it should go in sections two, three, or four.
117
-
118
- ### Adding a new pipeline/scheduler
119
-
120
- When adding a new pipeline:
121
-
122
- - create a file `xxx.mdx` under `docs/source/api/pipelines` (don't hesitate to copy an existing file as template).
123
- - Link that file in (*Diffusers Summary*) section in `docs/source/api/pipelines/overview.mdx`, along with the link to the paper, and a colab notebook (if available).
124
- - Write a short overview of the diffusion model:
125
- - Overview with paper & authors
126
- - Paper abstract
127
- - Tips and tricks and how to use it best
128
- - Possible an end-to-end example of how to use it
129
- - Add all the pipeline classes that should be linked in the diffusion model. These classes should be added using our Markdown syntax. By default as follows:
130
-
131
- ```
132
- ## XXXPipeline
133
-
134
- [[autodoc]] XXXPipeline
135
- - all
136
- - __call__
137
- ```
138
-
139
- This will include every public method of the pipeline that is documented, as well as the `__call__` method that is not documented by default. If you just want to add additional methods that are not documented, you can put the list of all methods to add in a list that contains `all`.
140
-
141
- ```
142
- [[autodoc]] XXXPipeline
143
- - all
144
- - __call__
145
- - enable_attention_slicing
146
- - disable_attention_slicing
147
- - enable_xformers_memory_efficient_attention
148
- - disable_xformers_memory_efficient_attention
149
- ```
150
-
151
- You can follow the same process to create a new scheduler under the `docs/source/api/schedulers` folder
152
-
153
- ### Writing source documentation
154
-
155
- Values that should be put in `code` should either be surrounded by backticks: \`like so\`. Note that argument names
156
- and objects like True, None, or any strings should usually be put in `code`.
157
-
158
- When mentioning a class, function, or method, it is recommended to use our syntax for internal links so that our tool
159
- adds a link to its documentation with this syntax: \[\`XXXClass\`\] or \[\`function\`\]. This requires the class or
160
- function to be in the main package.
161
-
162
- If you want to create a link to some internal class or function, you need to
163
- provide its path. For instance: \[\`pipelines.ImagePipelineOutput\`\]. This will be converted into a link with
164
- `pipelines.ImagePipelineOutput` in the description. To get rid of the path and only keep the name of the object you are
165
- linking to in the description, add a ~: \[\`~pipelines.ImagePipelineOutput\`\] will generate a link with `ImagePipelineOutput` in the description.
166
-
167
- The same works for methods so you can either use \[\`XXXClass.method\`\] or \[~\`XXXClass.method\`\].
168
-
169
- #### Defining arguments in a method
170
-
171
- Arguments should be defined with the `Args:` (or `Arguments:` or `Parameters:`) prefix, followed by a line return and
172
- an indentation. The argument should be followed by its type, with its shape if it is a tensor, a colon, and its
173
- description:
174
-
175
- ```
176
- Args:
177
- n_layers (`int`): The number of layers of the model.
178
- ```
179
-
180
- If the description is too long to fit in one line, another indentation is necessary before writing the description
181
- after the argument.
182
-
183
- Here's an example showcasing everything so far:
184
-
185
- ```
186
- Args:
187
- input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
188
- Indices of input sequence tokens in the vocabulary.
189
-
190
- Indices can be obtained using [`AlbertTokenizer`]. See [`~PreTrainedTokenizer.encode`] and
191
- [`~PreTrainedTokenizer.__call__`] for details.
192
-
193
- [What are input IDs?](../glossary#input-ids)
194
- ```
195
-
196
- For optional arguments or arguments with defaults we follow the following syntax: imagine we have a function with the
197
- following signature:
198
-
199
- ```
200
- def my_function(x: str = None, a: float = 1):
201
- ```
202
-
203
- then its documentation should look like this:
204
-
205
- ```
206
- Args:
207
- x (`str`, *optional*):
208
- This argument controls ...
209
- a (`float`, *optional*, defaults to 1):
210
- This argument is used to ...
211
- ```
212
-
213
- Note that we always omit the "defaults to \`None\`" when None is the default for any argument. Also note that even
214
- if the first line describing your argument type and its default gets long, you can't break it on several lines. You can
215
- however write as many lines as you want in the indented description (see the example above with `input_ids`).
216
-
217
- #### Writing a multi-line code block
218
-
219
- Multi-line code blocks can be useful for displaying examples. They are done between two lines of three backticks as usual in Markdown:
220
-
221
-
222
- ````
223
- ```
224
- # first line of code
225
- # second line
226
- # etc
227
- ```
228
- ````
229
-
230
- #### Writing a return block
231
-
232
- The return block should be introduced with the `Returns:` prefix, followed by a line return and an indentation.
233
- The first line should be the type of the return, followed by a line return. No need to indent further for the elements
234
- building the return.
235
-
236
- Here's an example of a single value return:
237
-
238
- ```
239
- Returns:
240
- `List[int]`: A list of integers in the range [0, 1] --- 1 for a special token, 0 for a sequence token.
241
- ```
242
-
243
- Here's an example of a tuple return, comprising several objects:
244
-
245
- ```
246
- Returns:
247
- `tuple(torch.FloatTensor)` comprising various elements depending on the configuration ([`BertConfig`]) and inputs:
248
- - ** loss** (*optional*, returned when `masked_lm_labels` is provided) `torch.FloatTensor` of shape `(1,)` --
249
- Total loss is the sum of the masked language modeling loss and the next sequence prediction (classification) loss.
250
- - **prediction_scores** (`torch.FloatTensor` of shape `(batch_size, sequence_length, config.vocab_size)`) --
251
- Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).
252
- ```
253
-
254
- #### Adding an image
255
-
256
- Due to the rapidly growing repository, it is important to make sure that no files that would significantly weigh down the repository are added. This includes images, videos, and other non-text files. We prefer to leverage a hf.co hosted `dataset` like
257
- the ones hosted on [`hf-internal-testing`](https://huggingface.co/hf-internal-testing) in which to place these files and reference
258
- them by URL. We recommend putting them in the following dataset: [huggingface/documentation-images](https://huggingface.co/datasets/huggingface/documentation-images).
259
- If an external contribution, feel free to add the images to your PR and ask a Hugging Face member to migrate your images
260
- to this dataset.
261
-
262
- ## Styling the docstring
263
-
264
- We have an automatic script running with the `make style` command that will make sure that:
265
- - the docstrings fully take advantage of the line width
266
- - all code examples are formatted using black, like the code of the Transformers library
267
-
268
- This script may have some weird failures if you made a syntax mistake or if you uncover a bug. Therefore, it's
269
- recommended to commit your changes before running `make style`, so you can revert the changes done by that script
270
- easily.
271
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/TRANSLATING.md DELETED
@@ -1,57 +0,0 @@
1
- ### Translating the Diffusers documentation into your language
2
-
3
- As part of our mission to democratize machine learning, we'd love to make the Diffusers library available in many more languages! Follow the steps below if you want to help translate the documentation into your language 🙏.
4
-
5
- **🗞️ Open an issue**
6
-
7
- To get started, navigate to the [Issues](https://github.com/huggingface/diffusers/issues) page of this repo and check if anyone else has opened an issue for your language. If not, open a new issue by selecting the "Translation template" from the "New issue" button.
8
-
9
- Once an issue exists, post a comment to indicate which chapters you'd like to work on, and we'll add your name to the list.
10
-
11
-
12
- **🍴 Fork the repository**
13
-
14
- First, you'll need to [fork the Diffusers repo](https://docs.github.com/en/get-started/quickstart/fork-a-repo). You can do this by clicking on the **Fork** button on the top-right corner of this repo's page.
15
-
16
- Once you've forked the repo, you'll want to get the files on your local machine for editing. You can do that by cloning the fork with Git as follows:
17
-
18
- ```bash
19
- git clone https://github.com/YOUR-USERNAME/diffusers.git
20
- ```
21
-
22
- **📋 Copy-paste the English version with a new language code**
23
-
24
- The documentation files are in one leading directory:
25
-
26
- - [`docs/source`](https://github.com/huggingface/diffusers/tree/main/docs/source): All the documentation materials are organized here by language.
27
-
28
- You'll only need to copy the files in the [`docs/source/en`](https://github.com/huggingface/diffusers/tree/main/docs/source/en) directory, so first navigate to your fork of the repo and run the following:
29
-
30
- ```bash
31
- cd ~/path/to/diffusers/docs
32
- cp -r source/en source/LANG-ID
33
- ```
34
-
35
- Here, `LANG-ID` should be one of the ISO 639-1 or ISO 639-2 language codes -- see [here](https://www.loc.gov/standards/iso639-2/php/code_list.php) for a handy table.
36
-
37
- **✍️ Start translating**
38
-
39
- The fun part comes - translating the text!
40
-
41
- The first thing we recommend is translating the part of the `_toctree.yml` file that corresponds to your doc chapter. This file is used to render the table of contents on the website.
42
-
43
- > 🙋 If the `_toctree.yml` file doesn't yet exist for your language, you can create one by copy-pasting from the English version and deleting the sections unrelated to your chapter. Just make sure it exists in the `docs/source/LANG-ID/` directory!
44
-
45
- The fields you should add are `local` (with the name of the file containing the translation; e.g. `autoclass_tutorial`), and `title` (with the title of the doc in your language; e.g. `Load pretrained instances with an AutoClass`) -- as a reference, here is the `_toctree.yml` for [English](https://github.com/huggingface/diffusers/blob/main/docs/source/en/_toctree.yml):
46
-
47
- ```yaml
48
- - sections:
49
- - local: pipeline_tutorial # Do not change this! Use the same name for your .md file
50
- title: Pipelines for inference # Translate this!
51
- ...
52
- title: Tutorials # Translate this!
53
- ```
54
-
55
- Once you have translated the `_toctree.yml` file, you can start translating the [MDX](https://mdxjs.com/) files associated with your docs chapter.
56
-
57
- > 🙋 If you'd like others to help you with the translation, you should [open an issue](https://github.com/huggingface/diffusers/issues) and tag @patrickvonplaten.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/source/_config.py DELETED
@@ -1,9 +0,0 @@
1
- # docstyle-ignore
2
- INSTALL_CONTENT = """
3
- # Diffusers installation
4
- ! pip install diffusers transformers datasets accelerate
5
- # To install from source instead of the last release, comment the command above and uncomment the following one.
6
- # ! pip install git+https://github.com/huggingface/diffusers.git
7
- """
8
-
9
- notebook_first_cells = [{"type": "code", "content": INSTALL_CONTENT}]
 
 
 
 
 
 
 
 
 
 
diffus/docs/source/en/_toctree.yml DELETED
@@ -1,264 +0,0 @@
1
- - sections:
2
- - local: index
3
- title: 🧨 Diffusers
4
- - local: quicktour
5
- title: Quicktour
6
- - local: stable_diffusion
7
- title: Effective and efficient diffusion
8
- - local: installation
9
- title: Installation
10
- title: Get started
11
- - sections:
12
- - local: tutorials/tutorial_overview
13
- title: Overview
14
- - local: using-diffusers/write_own_pipeline
15
- title: Understanding models and schedulers
16
- - local: tutorials/basic_training
17
- title: Train a diffusion model
18
- title: Tutorials
19
- - sections:
20
- - sections:
21
- - local: using-diffusers/loading_overview
22
- title: Overview
23
- - local: using-diffusers/loading
24
- title: Load pipelines, models, and schedulers
25
- - local: using-diffusers/schedulers
26
- title: Load and compare different schedulers
27
- - local: using-diffusers/custom_pipeline_overview
28
- title: Load and add custom pipelines
29
- - local: using-diffusers/kerascv
30
- title: Load KerasCV Stable Diffusion checkpoints
31
- title: Loading & Hub
32
- - sections:
33
- - local: using-diffusers/pipeline_overview
34
- title: Overview
35
- - local: using-diffusers/unconditional_image_generation
36
- title: Unconditional image generation
37
- - local: using-diffusers/conditional_image_generation
38
- title: Text-to-image generation
39
- - local: using-diffusers/img2img
40
- title: Text-guided image-to-image
41
- - local: using-diffusers/inpaint
42
- title: Text-guided image-inpainting
43
- - local: using-diffusers/depth2img
44
- title: Text-guided depth-to-image
45
- - local: using-diffusers/reusing_seeds
46
- title: Improve image quality with deterministic generation
47
- - local: using-diffusers/reproducibility
48
- title: Create reproducible pipelines
49
- - local: using-diffusers/custom_pipeline_examples
50
- title: Community Pipelines
51
- - local: using-diffusers/contribute_pipeline
52
- title: How to contribute a Pipeline
53
- - local: using-diffusers/using_safetensors
54
- title: Using safetensors
55
- - local: using-diffusers/stable_diffusion_jax_how_to
56
- title: Stable Diffusion in JAX/Flax
57
- - local: using-diffusers/weighted_prompts
58
- title: Weighting Prompts
59
- title: Pipelines for Inference
60
- - sections:
61
- - local: training/overview
62
- title: Overview
63
- - local: training/unconditional_training
64
- title: Unconditional image generation
65
- - local: training/text_inversion
66
- title: Textual Inversion
67
- - local: training/dreambooth
68
- title: DreamBooth
69
- - local: training/text2image
70
- title: Text-to-image
71
- - local: training/lora
72
- title: Low-Rank Adaptation of Large Language Models (LoRA)
73
- - local: training/controlnet
74
- title: ControlNet
75
- - local: training/instructpix2pix
76
- title: InstructPix2Pix Training
77
- title: Training
78
- - sections:
79
- - local: using-diffusers/rl
80
- title: Reinforcement Learning
81
- - local: using-diffusers/audio
82
- title: Audio
83
- - local: using-diffusers/other-modalities
84
- title: Other Modalities
85
- title: Taking Diffusers Beyond Images
86
- title: Using Diffusers
87
- - sections:
88
- - local: optimization/opt_overview
89
- title: Overview
90
- - local: optimization/fp16
91
- title: Memory and Speed
92
- - local: optimization/torch2.0
93
- title: Torch2.0 support
94
- - local: optimization/xformers
95
- title: xFormers
96
- - local: optimization/onnx
97
- title: ONNX
98
- - local: optimization/open_vino
99
- title: OpenVINO
100
- - local: optimization/mps
101
- title: MPS
102
- - local: optimization/habana
103
- title: Habana Gaudi
104
- title: Optimization/Special Hardware
105
- - sections:
106
- - local: conceptual/philosophy
107
- title: Philosophy
108
- - local: using-diffusers/controlling_generation
109
- title: Controlled generation
110
- - local: conceptual/contribution
111
- title: How to contribute?
112
- - local: conceptual/ethical_guidelines
113
- title: Diffusers' Ethical Guidelines
114
- - local: conceptual/evaluation
115
- title: Evaluating Diffusion Models
116
- title: Conceptual Guides
117
- - sections:
118
- - sections:
119
- - local: api/models
120
- title: Models
121
- - local: api/diffusion_pipeline
122
- title: Diffusion Pipeline
123
- - local: api/logging
124
- title: Logging
125
- - local: api/configuration
126
- title: Configuration
127
- - local: api/outputs
128
- title: Outputs
129
- - local: api/loaders
130
- title: Loaders
131
- title: Main Classes
132
- - sections:
133
- - local: api/pipelines/overview
134
- title: Overview
135
- - local: api/pipelines/alt_diffusion
136
- title: AltDiffusion
137
- - local: api/pipelines/audio_diffusion
138
- title: Audio Diffusion
139
- - local: api/pipelines/audioldm
140
- title: AudioLDM
141
- - local: api/pipelines/cycle_diffusion
142
- title: Cycle Diffusion
143
- - local: api/pipelines/dance_diffusion
144
- title: Dance Diffusion
145
- - local: api/pipelines/ddim
146
- title: DDIM
147
- - local: api/pipelines/ddpm
148
- title: DDPM
149
- - local: api/pipelines/dit
150
- title: DiT
151
- - local: api/pipelines/latent_diffusion
152
- title: Latent Diffusion
153
- - local: api/pipelines/paint_by_example
154
- title: PaintByExample
155
- - local: api/pipelines/pndm
156
- title: PNDM
157
- - local: api/pipelines/repaint
158
- title: RePaint
159
- - local: api/pipelines/stable_diffusion_safe
160
- title: Safe Stable Diffusion
161
- - local: api/pipelines/score_sde_ve
162
- title: Score SDE VE
163
- - local: api/pipelines/semantic_stable_diffusion
164
- title: Semantic Guidance
165
- - local: api/pipelines/spectrogram_diffusion
166
- title: "Spectrogram Diffusion"
167
- - sections:
168
- - local: api/pipelines/stable_diffusion/overview
169
- title: Overview
170
- - local: api/pipelines/stable_diffusion/text2img
171
- title: Text-to-Image
172
- - local: api/pipelines/stable_diffusion/img2img
173
- title: Image-to-Image
174
- - local: api/pipelines/stable_diffusion/inpaint
175
- title: Inpaint
176
- - local: api/pipelines/stable_diffusion/depth2img
177
- title: Depth-to-Image
178
- - local: api/pipelines/stable_diffusion/image_variation
179
- title: Image-Variation
180
- - local: api/pipelines/stable_diffusion/upscale
181
- title: Super-Resolution
182
- - local: api/pipelines/stable_diffusion/latent_upscale
183
- title: Stable-Diffusion-Latent-Upscaler
184
- - local: api/pipelines/stable_diffusion/pix2pix
185
- title: InstructPix2Pix
186
- - local: api/pipelines/stable_diffusion/attend_and_excite
187
- title: Attend and Excite
188
- - local: api/pipelines/stable_diffusion/pix2pix_zero
189
- title: Pix2Pix Zero
190
- - local: api/pipelines/stable_diffusion/self_attention_guidance
191
- title: Self-Attention Guidance
192
- - local: api/pipelines/stable_diffusion/panorama
193
- title: MultiDiffusion Panorama
194
- - local: api/pipelines/stable_diffusion/controlnet
195
- title: Text-to-Image Generation with ControlNet Conditioning
196
- - local: api/pipelines/stable_diffusion/model_editing
197
- title: Text-to-Image Model Editing
198
- title: Stable Diffusion
199
- - local: api/pipelines/stable_diffusion_2
200
- title: Stable Diffusion 2
201
- - local: api/pipelines/stable_unclip
202
- title: Stable unCLIP
203
- - local: api/pipelines/stochastic_karras_ve
204
- title: Stochastic Karras VE
205
- - local: api/pipelines/text_to_video
206
- title: Text-to-Video
207
- - local: api/pipelines/unclip
208
- title: UnCLIP
209
- - local: api/pipelines/latent_diffusion_uncond
210
- title: Unconditional Latent Diffusion
211
- - local: api/pipelines/versatile_diffusion
212
- title: Versatile Diffusion
213
- - local: api/pipelines/vq_diffusion
214
- title: VQ Diffusion
215
- title: Pipelines
216
- - sections:
217
- - local: api/schedulers/overview
218
- title: Overview
219
- - local: api/schedulers/ddim
220
- title: DDIM
221
- - local: api/schedulers/ddim_inverse
222
- title: DDIMInverse
223
- - local: api/schedulers/ddpm
224
- title: DDPM
225
- - local: api/schedulers/deis
226
- title: DEIS
227
- - local: api/schedulers/dpm_discrete
228
- title: DPM Discrete Scheduler
229
- - local: api/schedulers/dpm_discrete_ancestral
230
- title: DPM Discrete Scheduler with ancestral sampling
231
- - local: api/schedulers/euler_ancestral
232
- title: Euler Ancestral Scheduler
233
- - local: api/schedulers/euler
234
- title: Euler scheduler
235
- - local: api/schedulers/heun
236
- title: Heun Scheduler
237
- - local: api/schedulers/ipndm
238
- title: IPNDM
239
- - local: api/schedulers/lms_discrete
240
- title: Linear Multistep
241
- - local: api/schedulers/multistep_dpm_solver
242
- title: Multistep DPM-Solver
243
- - local: api/schedulers/pndm
244
- title: PNDM
245
- - local: api/schedulers/repaint
246
- title: RePaint Scheduler
247
- - local: api/schedulers/singlestep_dpm_solver
248
- title: Singlestep DPM-Solver
249
- - local: api/schedulers/stochastic_karras_ve
250
- title: Stochastic Kerras VE
251
- - local: api/schedulers/unipc
252
- title: UniPCMultistepScheduler
253
- - local: api/schedulers/score_sde_ve
254
- title: VE-SDE
255
- - local: api/schedulers/score_sde_vp
256
- title: VP-SDE
257
- - local: api/schedulers/vq_diffusion
258
- title: VQDiffusionScheduler
259
- title: Schedulers
260
- - sections:
261
- - local: api/experimental/rl
262
- title: RL Planning
263
- title: Experimental Features
264
- title: API
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/source/en/api/configuration.mdx DELETED
@@ -1,25 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # Configuration
14
-
15
- Schedulers from [`~schedulers.scheduling_utils.SchedulerMixin`] and models from [`ModelMixin`] inherit from [`ConfigMixin`] which conveniently takes care of storing all the parameters that are
16
- passed to their respective `__init__` methods in a JSON-configuration file.
17
-
18
- ## ConfigMixin
19
-
20
- [[autodoc]] ConfigMixin
21
- - load_config
22
- - from_config
23
- - save_config
24
- - to_json_file
25
- - to_json_string
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/source/en/api/diffusion_pipeline.mdx DELETED
@@ -1,47 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # Pipelines
14
-
15
- The [`DiffusionPipeline`] is the easiest way to load any pretrained diffusion pipeline from the [Hub](https://huggingface.co/models?library=diffusers) and to use it in inference.
16
-
17
- <Tip>
18
-
19
- One should not use the Diffusion Pipeline class for training or fine-tuning a diffusion model. Individual
20
- components of diffusion pipelines are usually trained individually, so we suggest to directly work
21
- with [`UNetModel`] and [`UNetConditionModel`].
22
-
23
- </Tip>
24
-
25
- Any diffusion pipeline that is loaded with [`~DiffusionPipeline.from_pretrained`] will automatically
26
- detect the pipeline type, *e.g.* [`StableDiffusionPipeline`] and consequently load each component of the
27
- pipeline and pass them into the `__init__` function of the pipeline, *e.g.* [`~StableDiffusionPipeline.__init__`].
28
-
29
- Any pipeline object can be saved locally with [`~DiffusionPipeline.save_pretrained`].
30
-
31
- ## DiffusionPipeline
32
- [[autodoc]] DiffusionPipeline
33
- - all
34
- - __call__
35
- - device
36
- - to
37
- - components
38
-
39
- ## ImagePipelineOutput
40
- By default diffusion pipelines return an object of class
41
-
42
- [[autodoc]] pipelines.ImagePipelineOutput
43
-
44
- ## AudioPipelineOutput
45
- By default diffusion pipelines return an object of class
46
-
47
- [[autodoc]] pipelines.AudioPipelineOutput
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/source/en/api/experimental/rl.mdx DELETED
@@ -1,15 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # TODO
14
-
15
- Coming soon!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/source/en/api/loaders.mdx DELETED
@@ -1,30 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # Loaders
14
-
15
- There are many ways to train adapter neural networks for diffusion models, such as
16
- - [Textual Inversion](./training/text_inversion.mdx)
17
- - [LoRA](https://github.com/cloneofsimo/lora)
18
- - [Hypernetworks](https://arxiv.org/abs/1609.09106)
19
-
20
- Such adapter neural networks often only consist of a fraction of the number of weights compared
21
- to the pretrained model and as such are very portable. The Diffusers library offers an easy-to-use
22
- API to load such adapter neural networks via the [`loaders.py` module](https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders.py).
23
-
24
- **Note**: This module is still highly experimental and prone to future changes.
25
-
26
- ## LoaderMixins
27
-
28
- ### UNet2DConditionLoadersMixin
29
-
30
- [[autodoc]] loaders.UNet2DConditionLoadersMixin
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/source/en/api/logging.mdx DELETED
@@ -1,98 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # Logging
14
-
15
- 🧨 Diffusers has a centralized logging system, so that you can setup the verbosity of the library easily.
16
-
17
- Currently the default verbosity of the library is `WARNING`.
18
-
19
- To change the level of verbosity, just use one of the direct setters. For instance, here is how to change the verbosity
20
- to the INFO level.
21
-
22
- ```python
23
- import diffusers
24
-
25
- diffusers.logging.set_verbosity_info()
26
- ```
27
-
28
- You can also use the environment variable `DIFFUSERS_VERBOSITY` to override the default verbosity. You can set it
29
- to one of the following: `debug`, `info`, `warning`, `error`, `critical`. For example:
30
-
31
- ```bash
32
- DIFFUSERS_VERBOSITY=error ./myprogram.py
33
- ```
34
-
35
- Additionally, some `warnings` can be disabled by setting the environment variable
36
- `DIFFUSERS_NO_ADVISORY_WARNINGS` to a true value, like *1*. This will disable any warning that is logged using
37
- [`logger.warning_advice`]. For example:
38
-
39
- ```bash
40
- DIFFUSERS_NO_ADVISORY_WARNINGS=1 ./myprogram.py
41
- ```
42
-
43
- Here is an example of how to use the same logger as the library in your own module or script:
44
-
45
- ```python
46
- from diffusers.utils import logging
47
-
48
- logging.set_verbosity_info()
49
- logger = logging.get_logger("diffusers")
50
- logger.info("INFO")
51
- logger.warning("WARN")
52
- ```
53
-
54
-
55
- All the methods of this logging module are documented below, the main ones are
56
- [`logging.get_verbosity`] to get the current level of verbosity in the logger and
57
- [`logging.set_verbosity`] to set the verbosity to the level of your choice. In order (from the least
58
- verbose to the most verbose), those levels (with their corresponding int values in parenthesis) are:
59
-
60
- - `diffusers.logging.CRITICAL` or `diffusers.logging.FATAL` (int value, 50): only report the most
61
- critical errors.
62
- - `diffusers.logging.ERROR` (int value, 40): only report errors.
63
- - `diffusers.logging.WARNING` or `diffusers.logging.WARN` (int value, 30): only reports error and
64
- warnings. This the default level used by the library.
65
- - `diffusers.logging.INFO` (int value, 20): reports error, warnings and basic information.
66
- - `diffusers.logging.DEBUG` (int value, 10): report all information.
67
-
68
- By default, `tqdm` progress bars will be displayed during model download. [`logging.disable_progress_bar`] and [`logging.enable_progress_bar`] can be used to suppress or unsuppress this behavior.
69
-
70
- ## Base setters
71
-
72
- [[autodoc]] logging.set_verbosity_error
73
-
74
- [[autodoc]] logging.set_verbosity_warning
75
-
76
- [[autodoc]] logging.set_verbosity_info
77
-
78
- [[autodoc]] logging.set_verbosity_debug
79
-
80
- ## Other functions
81
-
82
- [[autodoc]] logging.get_verbosity
83
-
84
- [[autodoc]] logging.set_verbosity
85
-
86
- [[autodoc]] logging.get_logger
87
-
88
- [[autodoc]] logging.enable_default_handler
89
-
90
- [[autodoc]] logging.disable_default_handler
91
-
92
- [[autodoc]] logging.enable_explicit_format
93
-
94
- [[autodoc]] logging.reset_format
95
-
96
- [[autodoc]] logging.enable_progress_bar
97
-
98
- [[autodoc]] logging.disable_progress_bar
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/source/en/api/models.mdx DELETED
@@ -1,107 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # Models
14
-
15
- Diffusers contains pretrained models for popular algorithms and modules for creating the next set of diffusion models.
16
- The primary function of these models is to denoise an input sample, by modeling the distribution $p_\theta(\mathbf{x}_{t-1}|\mathbf{x}_t)$.
17
- The models are built on the base class ['ModelMixin'] that is a `torch.nn.module` with basic functionality for saving and loading models both locally and from the HuggingFace hub.
18
-
19
- ## ModelMixin
20
- [[autodoc]] ModelMixin
21
-
22
- ## UNet2DOutput
23
- [[autodoc]] models.unet_2d.UNet2DOutput
24
-
25
- ## UNet2DModel
26
- [[autodoc]] UNet2DModel
27
-
28
- ## UNet1DOutput
29
- [[autodoc]] models.unet_1d.UNet1DOutput
30
-
31
- ## UNet1DModel
32
- [[autodoc]] UNet1DModel
33
-
34
- ## UNet2DConditionOutput
35
- [[autodoc]] models.unet_2d_condition.UNet2DConditionOutput
36
-
37
- ## UNet2DConditionModel
38
- [[autodoc]] UNet2DConditionModel
39
-
40
- ## UNet3DConditionOutput
41
- [[autodoc]] models.unet_3d_condition.UNet3DConditionOutput
42
-
43
- ## UNet3DConditionModel
44
- [[autodoc]] UNet3DConditionModel
45
-
46
- ## DecoderOutput
47
- [[autodoc]] models.vae.DecoderOutput
48
-
49
- ## VQEncoderOutput
50
- [[autodoc]] models.vq_model.VQEncoderOutput
51
-
52
- ## VQModel
53
- [[autodoc]] VQModel
54
-
55
- ## AutoencoderKLOutput
56
- [[autodoc]] models.autoencoder_kl.AutoencoderKLOutput
57
-
58
- ## AutoencoderKL
59
- [[autodoc]] AutoencoderKL
60
-
61
- ## Transformer2DModel
62
- [[autodoc]] Transformer2DModel
63
-
64
- ## Transformer2DModelOutput
65
- [[autodoc]] models.transformer_2d.Transformer2DModelOutput
66
-
67
- ## TransformerTemporalModel
68
- [[autodoc]] models.transformer_temporal.TransformerTemporalModel
69
-
70
- ## Transformer2DModelOutput
71
- [[autodoc]] models.transformer_temporal.TransformerTemporalModelOutput
72
-
73
- ## PriorTransformer
74
- [[autodoc]] models.prior_transformer.PriorTransformer
75
-
76
- ## PriorTransformerOutput
77
- [[autodoc]] models.prior_transformer.PriorTransformerOutput
78
-
79
- ## ControlNetOutput
80
- [[autodoc]] models.controlnet.ControlNetOutput
81
-
82
- ## ControlNetModel
83
- [[autodoc]] ControlNetModel
84
-
85
- ## FlaxModelMixin
86
- [[autodoc]] FlaxModelMixin
87
-
88
- ## FlaxUNet2DConditionOutput
89
- [[autodoc]] models.unet_2d_condition_flax.FlaxUNet2DConditionOutput
90
-
91
- ## FlaxUNet2DConditionModel
92
- [[autodoc]] FlaxUNet2DConditionModel
93
-
94
- ## FlaxDecoderOutput
95
- [[autodoc]] models.vae_flax.FlaxDecoderOutput
96
-
97
- ## FlaxAutoencoderKLOutput
98
- [[autodoc]] models.vae_flax.FlaxAutoencoderKLOutput
99
-
100
- ## FlaxAutoencoderKL
101
- [[autodoc]] FlaxAutoencoderKL
102
-
103
- ## FlaxControlNetOutput
104
- [[autodoc]] models.controlnet_flax.FlaxControlNetOutput
105
-
106
- ## FlaxControlNetModel
107
- [[autodoc]] FlaxControlNetModel
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/source/en/api/outputs.mdx DELETED
@@ -1,55 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # BaseOutputs
14
-
15
- All models have outputs that are instances of subclasses of [`~utils.BaseOutput`]. Those are
16
- data structures containing all the information returned by the model, but that can also be used as tuples or
17
- dictionaries.
18
-
19
- Let's see how this looks in an example:
20
-
21
- ```python
22
- from diffusers import DDIMPipeline
23
-
24
- pipeline = DDIMPipeline.from_pretrained("google/ddpm-cifar10-32")
25
- outputs = pipeline()
26
- ```
27
-
28
- The `outputs` object is a [`~pipelines.ImagePipelineOutput`], as we can see in the
29
- documentation of that class below, it means it has an image attribute.
30
-
31
- You can access each attribute as you would usually do, and if that attribute has not been returned by the model, you will get `None`:
32
-
33
- ```python
34
- outputs.images
35
- ```
36
-
37
- or via keyword lookup
38
-
39
- ```python
40
- outputs["images"]
41
- ```
42
-
43
- When considering our `outputs` object as tuple, it only considers the attributes that don't have `None` values.
44
- Here for instance, we could retrieve images via indexing:
45
-
46
- ```python
47
- outputs[:1]
48
- ```
49
-
50
- which will return the tuple `(outputs.images)` for instance.
51
-
52
- ## BaseOutput
53
-
54
- [[autodoc]] utils.BaseOutput
55
- - to_tuple
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/source/en/api/pipelines/alt_diffusion.mdx DELETED
@@ -1,83 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # AltDiffusion
14
-
15
- AltDiffusion was proposed in [AltCLIP: Altering the Language Encoder in CLIP for Extended Language Capabilities](https://arxiv.org/abs/2211.06679) by Zhongzhi Chen, Guang Liu, Bo-Wen Zhang, Fulong Ye, Qinghong Yang, Ledell Wu.
16
-
17
- The abstract of the paper is the following:
18
-
19
- *In this work, we present a conceptually simple and effective method to train a strong bilingual multimodal representation model. Starting from the pretrained multimodal representation model CLIP released by OpenAI, we switched its text encoder with a pretrained multilingual text encoder XLM-R, and aligned both languages and image representations by a two-stage training schema consisting of teacher learning and contrastive learning. We validate our method through evaluations of a wide range of tasks. We set new state-of-the-art performances on a bunch of tasks including ImageNet-CN, Flicker30k- CN, and COCO-CN. Further, we obtain very close performances with CLIP on almost all tasks, suggesting that one can simply alter the text encoder in CLIP for extended capabilities such as multilingual understanding.*
20
-
21
-
22
- *Overview*:
23
-
24
- | Pipeline | Tasks | Colab | Demo
25
- |---|---|:---:|:---:|
26
- | [pipeline_alt_diffusion.py](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/alt_diffusion/pipeline_alt_diffusion.py) | *Text-to-Image Generation* | - | -
27
- | [pipeline_alt_diffusion_img2img.py](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/alt_diffusion/pipeline_alt_diffusion_img2img.py) | *Image-to-Image Text-Guided Generation* | - |-
28
-
29
- ## Tips
30
-
31
- - AltDiffusion is conceptually exactly the same as [Stable Diffusion](./api/pipelines/stable_diffusion/overview).
32
-
33
- - *Run AltDiffusion*
34
-
35
- AltDiffusion can be tested very easily with the [`AltDiffusionPipeline`], [`AltDiffusionImg2ImgPipeline`] and the `"BAAI/AltDiffusion-m9"` checkpoint exactly in the same way it is shown in the [Conditional Image Generation Guide](./using-diffusers/conditional_image_generation) and the [Image-to-Image Generation Guide](./using-diffusers/img2img).
36
-
37
- - *How to load and use different schedulers.*
38
-
39
- The alt diffusion pipeline uses [`DDIMScheduler`] scheduler by default. But `diffusers` provides many other schedulers that can be used with the alt diffusion pipeline such as [`PNDMScheduler`], [`LMSDiscreteScheduler`], [`EulerDiscreteScheduler`], [`EulerAncestralDiscreteScheduler`] etc.
40
- To use a different scheduler, you can either change it via the [`ConfigMixin.from_config`] method or pass the `scheduler` argument to the `from_pretrained` method of the pipeline. For example, to use the [`EulerDiscreteScheduler`], you can do the following:
41
-
42
- ```python
43
- >>> from diffusers import AltDiffusionPipeline, EulerDiscreteScheduler
44
-
45
- >>> pipeline = AltDiffusionPipeline.from_pretrained("BAAI/AltDiffusion-m9")
46
- >>> pipeline.scheduler = EulerDiscreteScheduler.from_config(pipeline.scheduler.config)
47
-
48
- >>> # or
49
- >>> euler_scheduler = EulerDiscreteScheduler.from_pretrained("BAAI/AltDiffusion-m9", subfolder="scheduler")
50
- >>> pipeline = AltDiffusionPipeline.from_pretrained("BAAI/AltDiffusion-m9", scheduler=euler_scheduler)
51
- ```
52
-
53
-
54
- - *How to convert all use cases with multiple or single pipeline*
55
-
56
- If you want to use all possible use cases in a single `DiffusionPipeline` we recommend using the `components` functionality to instantiate all components in the most memory-efficient way:
57
-
58
- ```python
59
- >>> from diffusers import (
60
- ... AltDiffusionPipeline,
61
- ... AltDiffusionImg2ImgPipeline,
62
- ... )
63
-
64
- >>> text2img = AltDiffusionPipeline.from_pretrained("BAAI/AltDiffusion-m9")
65
- >>> img2img = AltDiffusionImg2ImgPipeline(**text2img.components)
66
-
67
- >>> # now you can use text2img(...) and img2img(...) just like the call methods of each respective pipeline
68
- ```
69
-
70
- ## AltDiffusionPipelineOutput
71
- [[autodoc]] pipelines.alt_diffusion.AltDiffusionPipelineOutput
72
- - all
73
- - __call__
74
-
75
- ## AltDiffusionPipeline
76
- [[autodoc]] AltDiffusionPipeline
77
- - all
78
- - __call__
79
-
80
- ## AltDiffusionImg2ImgPipeline
81
- [[autodoc]] AltDiffusionImg2ImgPipeline
82
- - all
83
- - __call__
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/source/en/api/pipelines/audio_diffusion.mdx DELETED
@@ -1,98 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # Audio Diffusion
14
-
15
- ## Overview
16
-
17
- [Audio Diffusion](https://github.com/teticio/audio-diffusion) by Robert Dargavel Smith.
18
-
19
- Audio Diffusion leverages the recent advances in image generation using diffusion models by converting audio samples to
20
- and from mel spectrogram images.
21
-
22
- The original codebase of this implementation can be found [here](https://github.com/teticio/audio-diffusion), including
23
- training scripts and example notebooks.
24
-
25
- ## Available Pipelines:
26
-
27
- | Pipeline | Tasks | Colab
28
- |---|---|:---:|
29
- | [pipeline_audio_diffusion.py](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/audio_diffusion/pipeline_audio_diffusion.py) | *Unconditional Audio Generation* | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/teticio/audio-diffusion/blob/master/notebooks/audio_diffusion_pipeline.ipynb) |
30
-
31
-
32
- ## Examples:
33
-
34
- ### Audio Diffusion
35
-
36
- ```python
37
- import torch
38
- from IPython.display import Audio
39
- from diffusers import DiffusionPipeline
40
-
41
- device = "cuda" if torch.cuda.is_available() else "cpu"
42
- pipe = DiffusionPipeline.from_pretrained("teticio/audio-diffusion-256").to(device)
43
-
44
- output = pipe()
45
- display(output.images[0])
46
- display(Audio(output.audios[0], rate=mel.get_sample_rate()))
47
- ```
48
-
49
- ### Latent Audio Diffusion
50
-
51
- ```python
52
- import torch
53
- from IPython.display import Audio
54
- from diffusers import DiffusionPipeline
55
-
56
- device = "cuda" if torch.cuda.is_available() else "cpu"
57
- pipe = DiffusionPipeline.from_pretrained("teticio/latent-audio-diffusion-256").to(device)
58
-
59
- output = pipe()
60
- display(output.images[0])
61
- display(Audio(output.audios[0], rate=pipe.mel.get_sample_rate()))
62
- ```
63
-
64
- ### Audio Diffusion with DDIM (faster)
65
-
66
- ```python
67
- import torch
68
- from IPython.display import Audio
69
- from diffusers import DiffusionPipeline
70
-
71
- device = "cuda" if torch.cuda.is_available() else "cpu"
72
- pipe = DiffusionPipeline.from_pretrained("teticio/audio-diffusion-ddim-256").to(device)
73
-
74
- output = pipe()
75
- display(output.images[0])
76
- display(Audio(output.audios[0], rate=pipe.mel.get_sample_rate()))
77
- ```
78
-
79
- ### Variations, in-painting, out-painting etc.
80
-
81
- ```python
82
- output = pipe(
83
- raw_audio=output.audios[0, 0],
84
- start_step=int(pipe.get_default_steps() / 2),
85
- mask_start_secs=1,
86
- mask_end_secs=1,
87
- )
88
- display(output.images[0])
89
- display(Audio(output.audios[0], rate=pipe.mel.get_sample_rate()))
90
- ```
91
-
92
- ## AudioDiffusionPipeline
93
- [[autodoc]] AudioDiffusionPipeline
94
- - all
95
- - __call__
96
-
97
- ## Mel
98
- [[autodoc]] Mel
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/source/en/api/pipelines/audioldm.mdx DELETED
@@ -1,82 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # AudioLDM
14
-
15
- ## Overview
16
-
17
- AudioLDM was proposed in [AudioLDM: Text-to-Audio Generation with Latent Diffusion Models](https://arxiv.org/abs/2301.12503) by Haohe Liu et al.
18
-
19
- Inspired by [Stable Diffusion](https://huggingface.co/docs/diffusers/api/pipelines/stable_diffusion/overview), AudioLDM
20
- is a text-to-audio _latent diffusion model (LDM)_ that learns continuous audio representations from [CLAP](https://huggingface.co/docs/transformers/main/model_doc/clap)
21
- latents. AudioLDM takes a text prompt as input and predicts the corresponding audio. It can generate text-conditional
22
- sound effects, human speech and music.
23
-
24
- This pipeline was contributed by [sanchit-gandhi](https://huggingface.co/sanchit-gandhi). The original codebase can be found [here](https://github.com/haoheliu/AudioLDM).
25
-
26
- ## Text-to-Audio
27
-
28
- The [`AudioLDMPipeline`] can be used to load pre-trained weights from [cvssp/audioldm](https://huggingface.co/cvssp/audioldm) and generate text-conditional audio outputs:
29
-
30
- ```python
31
- from diffusers import AudioLDMPipeline
32
- import torch
33
- import scipy
34
-
35
- repo_id = "cvssp/audioldm"
36
- pipe = AudioLDMPipeline.from_pretrained(repo_id, torch_dtype=torch.float16)
37
- pipe = pipe.to("cuda")
38
-
39
- prompt = "Techno music with a strong, upbeat tempo and high melodic riffs"
40
- audio = pipe(prompt, num_inference_steps=10, audio_length_in_s=5.0).audios[0]
41
-
42
- # save the audio sample as a .wav file
43
- scipy.io.wavfile.write("techno.wav", rate=16000, data=audio)
44
- ```
45
-
46
- ### Tips
47
-
48
- Prompts:
49
- * Descriptive prompt inputs work best: you can use adjectives to describe the sound (e.g. "high quality" or "clear") and make the prompt context specific (e.g., "water stream in a forest" instead of "stream").
50
- * It's best to use general terms like 'cat' or 'dog' instead of specific names or abstract objects that the model may not be familiar with.
51
-
52
- Inference:
53
- * The _quality_ of the predicted audio sample can be controlled by the `num_inference_steps` argument: higher steps give higher quality audio at the expense of slower inference.
54
- * The _length_ of the predicted audio sample can be controlled by varying the `audio_length_in_s` argument.
55
-
56
- ### How to load and use different schedulers
57
-
58
- The AudioLDM pipeline uses [`DDIMScheduler`] scheduler by default. But `diffusers` provides many other schedulers
59
- that can be used with the AudioLDM pipeline such as [`PNDMScheduler`], [`LMSDiscreteScheduler`], [`EulerDiscreteScheduler`],
60
- [`EulerAncestralDiscreteScheduler`] etc. We recommend using the [`DPMSolverMultistepScheduler`] as it's currently the fastest
61
- scheduler there is.
62
-
63
- To use a different scheduler, you can either change it via the [`ConfigMixin.from_config`]
64
- method, or pass the `scheduler` argument to the `from_pretrained` method of the pipeline. For example, to use the
65
- [`DPMSolverMultistepScheduler`], you can do the following:
66
-
67
- ```python
68
- >>> from diffusers import AudioLDMPipeline, DPMSolverMultistepScheduler
69
- >>> import torch
70
-
71
- >>> pipeline = AudioLDMPipeline.from_pretrained("cvssp/audioldm", torch_dtype=torch.float16)
72
- >>> pipeline.scheduler = DPMSolverMultistepScheduler.from_config(pipeline.scheduler.config)
73
-
74
- >>> # or
75
- >>> dpm_scheduler = DPMSolverMultistepScheduler.from_pretrained("cvssp/audioldm", subfolder="scheduler")
76
- >>> pipeline = AudioLDMPipeline.from_pretrained("cvssp/audioldm", scheduler=dpm_scheduler, torch_dtype=torch.float16)
77
- ```
78
-
79
- ## AudioLDMPipeline
80
- [[autodoc]] AudioLDMPipeline
81
- - all
82
- - __call__
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/source/en/api/pipelines/cycle_diffusion.mdx DELETED
@@ -1,100 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # Cycle Diffusion
14
-
15
- ## Overview
16
-
17
- Cycle Diffusion is a Text-Guided Image-to-Image Generation model proposed in [Unifying Diffusion Models' Latent Space, with Applications to CycleDiffusion and Guidance](https://arxiv.org/abs/2210.05559) by Chen Henry Wu, Fernando De la Torre.
18
-
19
- The abstract of the paper is the following:
20
-
21
- *Diffusion models have achieved unprecedented performance in generative modeling. The commonly-adopted formulation of the latent code of diffusion models is a sequence of gradually denoised samples, as opposed to the simpler (e.g., Gaussian) latent space of GANs, VAEs, and normalizing flows. This paper provides an alternative, Gaussian formulation of the latent space of various diffusion models, as well as an invertible DPM-Encoder that maps images into the latent space. While our formulation is purely based on the definition of diffusion models, we demonstrate several intriguing consequences. (1) Empirically, we observe that a common latent space emerges from two diffusion models trained independently on related domains. In light of this finding, we propose CycleDiffusion, which uses DPM-Encoder for unpaired image-to-image translation. Furthermore, applying CycleDiffusion to text-to-image diffusion models, we show that large-scale text-to-image diffusion models can be used as zero-shot image-to-image editors. (2) One can guide pre-trained diffusion models and GANs by controlling the latent codes in a unified, plug-and-play formulation based on energy-based models. Using the CLIP model and a face recognition model as guidance, we demonstrate that diffusion models have better coverage of low-density sub-populations and individuals than GANs.*
22
-
23
- *Tips*:
24
- - The Cycle Diffusion pipeline is fully compatible with any [Stable Diffusion](./stable_diffusion) checkpoints
25
- - Currently Cycle Diffusion only works with the [`DDIMScheduler`].
26
-
27
- *Example*:
28
-
29
- In the following we should how to best use the [`CycleDiffusionPipeline`]
30
-
31
- ```python
32
- import requests
33
- import torch
34
- from PIL import Image
35
- from io import BytesIO
36
-
37
- from diffusers import CycleDiffusionPipeline, DDIMScheduler
38
-
39
- # load the pipeline
40
- # make sure you're logged in with `huggingface-cli login`
41
- model_id_or_path = "CompVis/stable-diffusion-v1-4"
42
- scheduler = DDIMScheduler.from_pretrained(model_id_or_path, subfolder="scheduler")
43
- pipe = CycleDiffusionPipeline.from_pretrained(model_id_or_path, scheduler=scheduler).to("cuda")
44
-
45
- # let's download an initial image
46
- url = "https://raw.githubusercontent.com/ChenWu98/cycle-diffusion/main/data/dalle2/An%20astronaut%20riding%20a%20horse.png"
47
- response = requests.get(url)
48
- init_image = Image.open(BytesIO(response.content)).convert("RGB")
49
- init_image = init_image.resize((512, 512))
50
- init_image.save("horse.png")
51
-
52
- # let's specify a prompt
53
- source_prompt = "An astronaut riding a horse"
54
- prompt = "An astronaut riding an elephant"
55
-
56
- # call the pipeline
57
- image = pipe(
58
- prompt=prompt,
59
- source_prompt=source_prompt,
60
- image=init_image,
61
- num_inference_steps=100,
62
- eta=0.1,
63
- strength=0.8,
64
- guidance_scale=2,
65
- source_guidance_scale=1,
66
- ).images[0]
67
-
68
- image.save("horse_to_elephant.png")
69
-
70
- # let's try another example
71
- # See more samples at the original repo: https://github.com/ChenWu98/cycle-diffusion
72
- url = "https://raw.githubusercontent.com/ChenWu98/cycle-diffusion/main/data/dalle2/A%20black%20colored%20car.png"
73
- response = requests.get(url)
74
- init_image = Image.open(BytesIO(response.content)).convert("RGB")
75
- init_image = init_image.resize((512, 512))
76
- init_image.save("black.png")
77
-
78
- source_prompt = "A black colored car"
79
- prompt = "A blue colored car"
80
-
81
- # call the pipeline
82
- torch.manual_seed(0)
83
- image = pipe(
84
- prompt=prompt,
85
- source_prompt=source_prompt,
86
- image=init_image,
87
- num_inference_steps=100,
88
- eta=0.1,
89
- strength=0.85,
90
- guidance_scale=3,
91
- source_guidance_scale=1,
92
- ).images[0]
93
-
94
- image.save("black_to_blue.png")
95
- ```
96
-
97
- ## CycleDiffusionPipeline
98
- [[autodoc]] CycleDiffusionPipeline
99
- - all
100
- - __call__
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/source/en/api/pipelines/dance_diffusion.mdx DELETED
@@ -1,34 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # Dance Diffusion
14
-
15
- ## Overview
16
-
17
- [Dance Diffusion](https://github.com/Harmonai-org/sample-generator) by Zach Evans.
18
-
19
- Dance Diffusion is the first in a suite of generative audio tools for producers and musicians to be released by Harmonai.
20
- For more info or to get involved in the development of these tools, please visit https://harmonai.org and fill out the form on the front page.
21
-
22
- The original codebase of this implementation can be found [here](https://github.com/Harmonai-org/sample-generator).
23
-
24
- ## Available Pipelines:
25
-
26
- | Pipeline | Tasks | Colab
27
- |---|---|:---:|
28
- | [pipeline_dance_diffusion.py](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/dance_diffusion/pipeline_dance_diffusion.py) | *Unconditional Audio Generation* | - |
29
-
30
-
31
- ## DanceDiffusionPipeline
32
- [[autodoc]] DanceDiffusionPipeline
33
- - all
34
- - __call__
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/source/en/api/pipelines/ddim.mdx DELETED
@@ -1,36 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # DDIM
14
-
15
- ## Overview
16
-
17
- [Denoising Diffusion Implicit Models](https://arxiv.org/abs/2010.02502) (DDIM) by Jiaming Song, Chenlin Meng and Stefano Ermon.
18
-
19
- The abstract of the paper is the following:
20
-
21
- Denoising diffusion probabilistic models (DDPMs) have achieved high quality image generation without adversarial training, yet they require simulating a Markov chain for many steps to produce a sample. To accelerate sampling, we present denoising diffusion implicit models (DDIMs), a more efficient class of iterative implicit probabilistic models with the same training procedure as DDPMs. In DDPMs, the generative process is defined as the reverse of a Markovian diffusion process. We construct a class of non-Markovian diffusion processes that lead to the same training objective, but whose reverse process can be much faster to sample from. We empirically demonstrate that DDIMs can produce high quality samples 10× to 50× faster in terms of wall-clock time compared to DDPMs, allow us to trade off computation for sample quality, and can perform semantically meaningful image interpolation directly in the latent space.
22
-
23
- The original codebase of this paper can be found here: [ermongroup/ddim](https://github.com/ermongroup/ddim).
24
- For questions, feel free to contact the author on [tsong.me](https://tsong.me/).
25
-
26
- ## Available Pipelines:
27
-
28
- | Pipeline | Tasks | Colab
29
- |---|---|:---:|
30
- | [pipeline_ddim.py](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/ddim/pipeline_ddim.py) | *Unconditional Image Generation* | - |
31
-
32
-
33
- ## DDIMPipeline
34
- [[autodoc]] DDIMPipeline
35
- - all
36
- - __call__
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/source/en/api/pipelines/ddpm.mdx DELETED
@@ -1,37 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # DDPM
14
-
15
- ## Overview
16
-
17
- [Denoising Diffusion Probabilistic Models](https://arxiv.org/abs/2006.11239)
18
- (DDPM) by Jonathan Ho, Ajay Jain and Pieter Abbeel proposes the diffusion based model of the same name, but in the context of the 🤗 Diffusers library, DDPM refers to the discrete denoising scheduler from the paper as well as the pipeline.
19
-
20
- The abstract of the paper is the following:
21
-
22
- We present high quality image synthesis results using diffusion probabilistic models, a class of latent variable models inspired by considerations from nonequilibrium thermodynamics. Our best results are obtained by training on a weighted variational bound designed according to a novel connection between diffusion probabilistic models and denoising score matching with Langevin dynamics, and our models naturally admit a progressive lossy decompression scheme that can be interpreted as a generalization of autoregressive decoding. On the unconditional CIFAR10 dataset, we obtain an Inception score of 9.46 and a state-of-the-art FID score of 3.17. On 256x256 LSUN, we obtain sample quality similar to ProgressiveGAN.
23
-
24
- The original codebase of this paper can be found [here](https://github.com/hojonathanho/diffusion).
25
-
26
-
27
- ## Available Pipelines:
28
-
29
- | Pipeline | Tasks | Colab
30
- |---|---|:---:|
31
- | [pipeline_ddpm.py](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/ddpm/pipeline_ddpm.py) | *Unconditional Image Generation* | - |
32
-
33
-
34
- # DDPMPipeline
35
- [[autodoc]] DDPMPipeline
36
- - all
37
- - __call__
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/source/en/api/pipelines/dit.mdx DELETED
@@ -1,59 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # Scalable Diffusion Models with Transformers (DiT)
14
-
15
- ## Overview
16
-
17
- [Scalable Diffusion Models with Transformers](https://arxiv.org/abs/2212.09748) (DiT) by William Peebles and Saining Xie.
18
-
19
- The abstract of the paper is the following:
20
-
21
- *We explore a new class of diffusion models based on the transformer architecture. We train latent diffusion models of images, replacing the commonly-used U-Net backbone with a transformer that operates on latent patches. We analyze the scalability of our Diffusion Transformers (DiTs) through the lens of forward pass complexity as measured by Gflops. We find that DiTs with higher Gflops -- through increased transformer depth/width or increased number of input tokens -- consistently have lower FID. In addition to possessing good scalability properties, our largest DiT-XL/2 models outperform all prior diffusion models on the class-conditional ImageNet 512x512 and 256x256 benchmarks, achieving a state-of-the-art FID of 2.27 on the latter.*
22
-
23
- The original codebase of this paper can be found here: [facebookresearch/dit](https://github.com/facebookresearch/dit).
24
-
25
- ## Available Pipelines:
26
-
27
- | Pipeline | Tasks | Colab
28
- |---|---|:---:|
29
- | [pipeline_dit.py](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/dit/pipeline_dit.py) | *Conditional Image Generation* | - |
30
-
31
-
32
- ## Usage example
33
-
34
- ```python
35
- from diffusers import DiTPipeline, DPMSolverMultistepScheduler
36
- import torch
37
-
38
- pipe = DiTPipeline.from_pretrained("facebook/DiT-XL-2-256", torch_dtype=torch.float16)
39
- pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
40
- pipe = pipe.to("cuda")
41
-
42
- # pick words from Imagenet class labels
43
- pipe.labels # to print all available words
44
-
45
- # pick words that exist in ImageNet
46
- words = ["white shark", "umbrella"]
47
-
48
- class_ids = pipe.get_label_ids(words)
49
-
50
- generator = torch.manual_seed(33)
51
- output = pipe(class_labels=class_ids, num_inference_steps=25, generator=generator)
52
-
53
- image = output.images[0] # label 'white shark'
54
- ```
55
-
56
- ## DiTPipeline
57
- [[autodoc]] DiTPipeline
58
- - all
59
- - __call__
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/source/en/api/pipelines/latent_diffusion.mdx DELETED
@@ -1,49 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # Latent Diffusion
14
-
15
- ## Overview
16
-
17
- Latent Diffusion was proposed in [High-Resolution Image Synthesis with Latent Diffusion Models](https://arxiv.org/abs/2112.10752) by Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, Björn Ommer.
18
-
19
- The abstract of the paper is the following:
20
-
21
- *By decomposing the image formation process into a sequential application of denoising autoencoders, diffusion models (DMs) achieve state-of-the-art synthesis results on image data and beyond. Additionally, their formulation allows for a guiding mechanism to control the image generation process without retraining. However, since these models typically operate directly in pixel space, optimization of powerful DMs often consumes hundreds of GPU days and inference is expensive due to sequential evaluations. To enable DM training on limited computational resources while retaining their quality and flexibility, we apply them in the latent space of powerful pretrained autoencoders. In contrast to previous work, training diffusion models on such a representation allows for the first time to reach a near-optimal point between complexity reduction and detail preservation, greatly boosting visual fidelity. By introducing cross-attention layers into the model architecture, we turn diffusion models into powerful and flexible generators for general conditioning inputs such as text or bounding boxes and high-resolution synthesis becomes possible in a convolutional manner. Our latent diffusion models (LDMs) achieve a new state of the art for image inpainting and highly competitive performance on various tasks, including unconditional image generation, semantic scene synthesis, and super-resolution, while significantly reducing computational requirements compared to pixel-based DMs.*
22
-
23
- The original codebase can be found [here](https://github.com/CompVis/latent-diffusion).
24
-
25
- ## Tips:
26
-
27
- -
28
- -
29
- -
30
-
31
- ## Available Pipelines:
32
-
33
- | Pipeline | Tasks | Colab
34
- |---|---|:---:|
35
- | [pipeline_latent_diffusion.py](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/latent_diffusion/pipeline_latent_diffusion.py) | *Text-to-Image Generation* | - |
36
- | [pipeline_latent_diffusion_superresolution.py](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/latent_diffusion/pipeline_latent_diffusion_superresolution.py) | *Super Resolution* | - |
37
-
38
- ## Examples:
39
-
40
-
41
- ## LDMTextToImagePipeline
42
- [[autodoc]] LDMTextToImagePipeline
43
- - all
44
- - __call__
45
-
46
- ## LDMSuperResolutionPipeline
47
- [[autodoc]] LDMSuperResolutionPipeline
48
- - all
49
- - __call__
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/source/en/api/pipelines/latent_diffusion_uncond.mdx DELETED
@@ -1,42 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # Unconditional Latent Diffusion
14
-
15
- ## Overview
16
-
17
- Unconditional Latent Diffusion was proposed in [High-Resolution Image Synthesis with Latent Diffusion Models](https://arxiv.org/abs/2112.10752) by Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, Björn Ommer.
18
-
19
- The abstract of the paper is the following:
20
-
21
- *By decomposing the image formation process into a sequential application of denoising autoencoders, diffusion models (DMs) achieve state-of-the-art synthesis results on image data and beyond. Additionally, their formulation allows for a guiding mechanism to control the image generation process without retraining. However, since these models typically operate directly in pixel space, optimization of powerful DMs often consumes hundreds of GPU days and inference is expensive due to sequential evaluations. To enable DM training on limited computational resources while retaining their quality and flexibility, we apply them in the latent space of powerful pretrained autoencoders. In contrast to previous work, training diffusion models on such a representation allows for the first time to reach a near-optimal point between complexity reduction and detail preservation, greatly boosting visual fidelity. By introducing cross-attention layers into the model architecture, we turn diffusion models into powerful and flexible generators for general conditioning inputs such as text or bounding boxes and high-resolution synthesis becomes possible in a convolutional manner. Our latent diffusion models (LDMs) achieve a new state of the art for image inpainting and highly competitive performance on various tasks, including unconditional image generation, semantic scene synthesis, and super-resolution, while significantly reducing computational requirements compared to pixel-based DMs.*
22
-
23
- The original codebase can be found [here](https://github.com/CompVis/latent-diffusion).
24
-
25
- ## Tips:
26
-
27
- -
28
- -
29
- -
30
-
31
- ## Available Pipelines:
32
-
33
- | Pipeline | Tasks | Colab
34
- |---|---|:---:|
35
- | [pipeline_latent_diffusion_uncond.py](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/latent_diffusion_uncond/pipeline_latent_diffusion_uncond.py) | *Unconditional Image Generation* | - |
36
-
37
- ## Examples:
38
-
39
- ## LDMPipeline
40
- [[autodoc]] LDMPipeline
41
- - all
42
- - __call__
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/source/en/api/pipelines/overview.mdx DELETED
@@ -1,213 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # Pipelines
14
-
15
- Pipelines provide a simple way to run state-of-the-art diffusion models in inference.
16
- Most diffusion systems consist of multiple independently-trained models and highly adaptable scheduler
17
- components - all of which are needed to have a functioning end-to-end diffusion system.
18
-
19
- As an example, [Stable Diffusion](https://huggingface.co/blog/stable_diffusion) has three independently trained models:
20
- - [Autoencoder](./api/models#vae)
21
- - [Conditional Unet](./api/models#UNet2DConditionModel)
22
- - [CLIP text encoder](https://huggingface.co/docs/transformers/v4.27.1/en/model_doc/clip#transformers.CLIPTextModel)
23
- - a scheduler component, [scheduler](./api/scheduler#pndm),
24
- - a [CLIPImageProcessor](https://huggingface.co/docs/transformers/v4.27.1/en/model_doc/clip#transformers.CLIPImageProcessor),
25
- - as well as a [safety checker](./stable_diffusion#safety_checker).
26
- All of these components are necessary to run stable diffusion in inference even though they were trained
27
- or created independently from each other.
28
-
29
- To that end, we strive to offer all open-sourced, state-of-the-art diffusion system under a unified API.
30
- More specifically, we strive to provide pipelines that
31
- - 1. can load the officially published weights and yield 1-to-1 the same outputs as the original implementation according to the corresponding paper (*e.g.* [LDMTextToImagePipeline](https://github.com/huggingface/diffusers/tree/main/src/diffusers/pipelines/latent_diffusion), uses the officially released weights of [High-Resolution Image Synthesis with Latent Diffusion Models](https://arxiv.org/abs/2112.10752)),
32
- - 2. have a simple user interface to run the model in inference (see the [Pipelines API](#pipelines-api) section),
33
- - 3. are easy to understand with code that is self-explanatory and can be read along-side the official paper (see [Pipelines summary](#pipelines-summary)),
34
- - 4. can easily be contributed by the community (see the [Contribution](#contribution) section).
35
-
36
- **Note** that pipelines do not (and should not) offer any training functionality.
37
- If you are looking for *official* training examples, please have a look at [examples](https://github.com/huggingface/diffusers/tree/main/examples).
38
-
39
- ## 🧨 Diffusers Summary
40
-
41
- The following table summarizes all officially supported pipelines, their corresponding paper, and if
42
- available a colab notebook to directly try them out.
43
-
44
-
45
- | Pipeline | Paper | Tasks | Colab
46
- |---|---|:---:|:---:|
47
- | [alt_diffusion](./alt_diffusion) | [**AltDiffusion**](https://arxiv.org/abs/2211.06679) | Image-to-Image Text-Guided Generation | -
48
- | [audio_diffusion](./audio_diffusion) | [**Audio Diffusion**](https://github.com/teticio/audio_diffusion.git) | Unconditional Audio Generation |
49
- | [controlnet](./api/pipelines/stable_diffusion/controlnet) | [**ControlNet with Stable Diffusion**](https://arxiv.org/abs/2302.05543) | Image-to-Image Text-Guided Generation | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers/controlnet.ipynb)
50
- | [cycle_diffusion](./cycle_diffusion) | [**Cycle Diffusion**](https://arxiv.org/abs/2210.05559) | Image-to-Image Text-Guided Generation |
51
- | [dance_diffusion](./dance_diffusion) | [**Dance Diffusion**](https://github.com/williamberman/diffusers.git) | Unconditional Audio Generation |
52
- | [ddpm](./ddpm) | [**Denoising Diffusion Probabilistic Models**](https://arxiv.org/abs/2006.11239) | Unconditional Image Generation |
53
- | [ddim](./ddim) | [**Denoising Diffusion Implicit Models**](https://arxiv.org/abs/2010.02502) | Unconditional Image Generation |
54
- | [latent_diffusion](./latent_diffusion) | [**High-Resolution Image Synthesis with Latent Diffusion Models**](https://arxiv.org/abs/2112.10752)| Text-to-Image Generation |
55
- | [latent_diffusion](./latent_diffusion) | [**High-Resolution Image Synthesis with Latent Diffusion Models**](https://arxiv.org/abs/2112.10752)| Super Resolution Image-to-Image |
56
- | [latent_diffusion_uncond](./latent_diffusion_uncond) | [**High-Resolution Image Synthesis with Latent Diffusion Models**](https://arxiv.org/abs/2112.10752) | Unconditional Image Generation |
57
- | [paint_by_example](./paint_by_example) | [**Paint by Example: Exemplar-based Image Editing with Diffusion Models**](https://arxiv.org/abs/2211.13227) | Image-Guided Image Inpainting |
58
- | [pndm](./pndm) | [**Pseudo Numerical Methods for Diffusion Models on Manifolds**](https://arxiv.org/abs/2202.09778) | Unconditional Image Generation |
59
- | [score_sde_ve](./score_sde_ve) | [**Score-Based Generative Modeling through Stochastic Differential Equations**](https://openreview.net/forum?id=PxTIG12RRHS) | Unconditional Image Generation |
60
- | [score_sde_vp](./score_sde_vp) | [**Score-Based Generative Modeling through Stochastic Differential Equations**](https://openreview.net/forum?id=PxTIG12RRHS) | Unconditional Image Generation |
61
- | [semantic_stable_diffusion](./semantic_stable_diffusion) | [**SEGA: Instructing Diffusion using Semantic Dimensions**](https://arxiv.org/abs/2301.12247) | Text-to-Image Generation |
62
- | [stable_diffusion_text2img](./stable_diffusion/text2img) | [**Stable Diffusion**](https://stability.ai/blog/stable-diffusion-public-release) | Text-to-Image Generation | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers/training_example.ipynb)
63
- | [stable_diffusion_img2img](./stable_diffusion/img2img) | [**Stable Diffusion**](https://stability.ai/blog/stable-diffusion-public-release) | Image-to-Image Text-Guided Generation | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers/image_2_image_using_diffusers.ipynb)
64
- | [stable_diffusion_inpaint](./stable_diffusion/inpaint) | [**Stable Diffusion**](https://stability.ai/blog/stable-diffusion-public-release) | Text-Guided Image Inpainting | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers/in_painting_with_stable_diffusion_using_diffusers.ipynb)
65
- | [stable_diffusion_panorama](./stable_diffusion/panorama) | [**MultiDiffusion: Fusing Diffusion Paths for Controlled Image Generation**](https://arxiv.org/abs/2302.08113) | Text-Guided Panorama View Generation |
66
- | [stable_diffusion_pix2pix](./stable_diffusion/pix2pix) | [**InstructPix2Pix: Learning to Follow Image Editing Instructions**](https://arxiv.org/abs/2211.09800) | Text-Based Image Editing |
67
- | [stable_diffusion_pix2pix_zero](./stable_diffusion/pix2pix_zero) | [**Zero-shot Image-to-Image Translation**](https://arxiv.org/abs/2302.03027) | Text-Based Image Editing |
68
- | [stable_diffusion_attend_and_excite](./stable_diffusion/attend_and_excite) | [**Attend and Excite: Attention-Based Semantic Guidance for Text-to-Image Diffusion Models**](https://arxiv.org/abs/2301.13826) | Text-to-Image Generation |
69
- | [stable_diffusion_self_attention_guidance](./stable_diffusion/self_attention_guidance) | [**Self-Attention Guidance**](https://arxiv.org/abs/2210.00939) | Text-to-Image Generation |
70
- | [stable_diffusion_image_variation](./stable_diffusion/image_variation) | [**Stable Diffusion Image Variations**](https://github.com/LambdaLabsML/lambda-diffusers#stable-diffusion-image-variations) | Image-to-Image Generation |
71
- | [stable_diffusion_latent_upscale](./stable_diffusion/latent_upscale) | [**Stable Diffusion Latent Upscaler**](https://twitter.com/StabilityAI/status/1590531958815064065) | Text-Guided Super Resolution Image-to-Image |
72
- | [stable_diffusion_2](./stable_diffusion_2/) | [**Stable Diffusion 2**](https://stability.ai/blog/stable-diffusion-v2-release) | Text-to-Image Generation |
73
- | [stable_diffusion_2](./stable_diffusion_2) | [**Stable Diffusion 2**](https://stability.ai/blog/stable-diffusion-v2-release) | Text-Guided Image Inpainting |
74
- | [stable_diffusion_2](./stable_diffusion_2) | [**Stable Diffusion 2**](https://stability.ai/blog/stable-diffusion-v2-release) | Depth-to-Image Text-Guided Generation |
75
- | [stable_diffusion_2](./stable_diffusion_2) | [**Stable Diffusion 2**](https://stability.ai/blog/stable-diffusion-v2-release) | Text-Guided Super Resolution Image-to-Image |
76
- | [stable_diffusion_safe](./stable_diffusion_safe) | [**Safe Stable Diffusion**](https://arxiv.org/abs/2211.05105) | Text-Guided Generation | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/ml-research/safe-latent-diffusion/blob/main/examples/Safe%20Latent%20Diffusion.ipynb)
77
- | [stable_unclip](./stable_unclip) | **Stable unCLIP** | Text-to-Image Generation |
78
- | [stable_unclip](./stable_unclip) | **Stable unCLIP** | Image-to-Image Text-Guided Generation |
79
- | [stochastic_karras_ve](./stochastic_karras_ve) | [**Elucidating the Design Space of Diffusion-Based Generative Models**](https://arxiv.org/abs/2206.00364) | Unconditional Image Generation |
80
- | [text_to_video_sd](./api/pipelines/text_to_video) | [Modelscope's Text-to-video-synthesis Model in Open Domain](https://modelscope.cn/models/damo/text-to-video-synthesis/summary) | Text-to-Video Generation |
81
- | [unclip](./unclip) | [Hierarchical Text-Conditional Image Generation with CLIP Latents](https://arxiv.org/abs/2204.06125) | Text-to-Image Generation |
82
- | [versatile_diffusion](./versatile_diffusion) | [Versatile Diffusion: Text, Images and Variations All in One Diffusion Model](https://arxiv.org/abs/2211.08332) | Text-to-Image Generation |
83
- | [versatile_diffusion](./versatile_diffusion) | [Versatile Diffusion: Text, Images and Variations All in One Diffusion Model](https://arxiv.org/abs/2211.08332) | Image Variations Generation |
84
- | [versatile_diffusion](./versatile_diffusion) | [Versatile Diffusion: Text, Images and Variations All in One Diffusion Model](https://arxiv.org/abs/2211.08332) | Dual Image and Text Guided Generation |
85
- | [vq_diffusion](./vq_diffusion) | [Vector Quantized Diffusion Model for Text-to-Image Synthesis](https://arxiv.org/abs/2111.14822) | Text-to-Image Generation |
86
-
87
-
88
- **Note**: Pipelines are simple examples of how to play around with the diffusion systems as described in the corresponding papers.
89
-
90
- However, most of them can be adapted to use different scheduler components or even different model components. Some pipeline examples are shown in the [Examples](#examples) below.
91
-
92
- ## Pipelines API
93
-
94
- Diffusion models often consist of multiple independently-trained models or other previously existing components.
95
-
96
-
97
- Each model has been trained independently on a different task and the scheduler can easily be swapped out and replaced with a different one.
98
- During inference, we however want to be able to easily load all components and use them in inference - even if one component, *e.g.* CLIP's text encoder, originates from a different library, such as [Transformers](https://github.com/huggingface/transformers). To that end, all pipelines provide the following functionality:
99
-
100
- - [`from_pretrained` method](../diffusion_pipeline) that accepts a Hugging Face Hub repository id, *e.g.* [runwayml/stable-diffusion-v1-5](https://huggingface.co/runwayml/stable-diffusion-v1-5) or a path to a local directory, *e.g.*
101
- "./stable-diffusion". To correctly retrieve which models and components should be loaded, one has to provide a `model_index.json` file, *e.g.* [runwayml/stable-diffusion-v1-5/model_index.json](https://huggingface.co/runwayml/stable-diffusion-v1-5/blob/main/model_index.json), which defines all components that should be
102
- loaded into the pipelines. More specifically, for each model/component one needs to define the format `<name>: ["<library>", "<class name>"]`. `<name>` is the attribute name given to the loaded instance of `<class name>` which can be found in the library or pipeline folder called `"<library>"`.
103
- - [`save_pretrained`](../diffusion_pipeline) that accepts a local path, *e.g.* `./stable-diffusion` under which all models/components of the pipeline will be saved. For each component/model a folder is created inside the local path that is named after the given attribute name, *e.g.* `./stable_diffusion/unet`.
104
- In addition, a `model_index.json` file is created at the root of the local path, *e.g.* `./stable_diffusion/model_index.json` so that the complete pipeline can again be instantiated
105
- from the local path.
106
- - [`to`](../diffusion_pipeline) which accepts a `string` or `torch.device` to move all models that are of type `torch.nn.Module` to the passed device. The behavior is fully analogous to [PyTorch's `to` method](https://pytorch.org/docs/stable/generated/torch.nn.Module.html#torch.nn.Module.to).
107
- - [`__call__`] method to use the pipeline in inference. `__call__` defines inference logic of the pipeline and should ideally encompass all aspects of it, from pre-processing to forwarding tensors to the different models and schedulers, as well as post-processing. The API of the `__call__` method can strongly vary from pipeline to pipeline. *E.g.* a text-to-image pipeline, such as [`StableDiffusionPipeline`](./stable_diffusion) should accept among other things the text prompt to generate the image. A pure image generation pipeline, such as [DDPMPipeline](https://github.com/huggingface/diffusers/tree/main/src/diffusers/pipelines/ddpm) on the other hand can be run without providing any inputs. To better understand what inputs can be adapted for
108
- each pipeline, one should look directly into the respective pipeline.
109
-
110
- **Note**: All pipelines have PyTorch's autograd disabled by decorating the `__call__` method with a [`torch.no_grad`](https://pytorch.org/docs/stable/generated/torch.no_grad.html) decorator because pipelines should
111
- not be used for training. If you want to store the gradients during the forward pass, we recommend writing your own pipeline, see also our [community-examples](https://github.com/huggingface/diffusers/tree/main/examples/community).
112
-
113
- ## Contribution
114
-
115
- We are more than happy about any contribution to the officially supported pipelines 🤗. We aspire
116
- all of our pipelines to be **self-contained**, **easy-to-tweak**, **beginner-friendly** and for **one-purpose-only**.
117
-
118
- - **Self-contained**: A pipeline shall be as self-contained as possible. More specifically, this means that all functionality should be either directly defined in the pipeline file itself, should be inherited from (and only from) the [`DiffusionPipeline` class](.../diffusion_pipeline) or be directly attached to the model and scheduler components of the pipeline.
119
- - **Easy-to-use**: Pipelines should be extremely easy to use - one should be able to load the pipeline and
120
- use it for its designated task, *e.g.* text-to-image generation, in just a couple of lines of code. Most
121
- logic including pre-processing, an unrolled diffusion loop, and post-processing should all happen inside the `__call__` method.
122
- - **Easy-to-tweak**: Certain pipelines will not be able to handle all use cases and tasks that you might like them to. If you want to use a certain pipeline for a specific use case that is not yet supported, you might have to copy the pipeline file and tweak the code to your needs. We try to make the pipeline code as readable as possible so that each part –from pre-processing to diffusing to post-processing– can easily be adapted. If you would like the community to benefit from your customized pipeline, we would love to see a contribution to our [community-examples](https://github.com/huggingface/diffusers/tree/main/examples/community). If you feel that an important pipeline should be part of the official pipelines but isn't, a contribution to the [official pipelines](./overview) would be even better.
123
- - **One-purpose-only**: Pipelines should be used for one task and one task only. Even if two tasks are very similar from a modeling point of view, *e.g.* image2image translation and in-painting, pipelines shall be used for one task only to keep them *easy-to-tweak* and *readable*.
124
-
125
- ## Examples
126
-
127
- ### Text-to-Image generation with Stable Diffusion
128
-
129
- ```python
130
- # make sure you're logged in with `huggingface-cli login`
131
- from diffusers import StableDiffusionPipeline, LMSDiscreteScheduler
132
-
133
- pipe = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5")
134
- pipe = pipe.to("cuda")
135
-
136
- prompt = "a photo of an astronaut riding a horse on mars"
137
- image = pipe(prompt).images[0]
138
-
139
- image.save("astronaut_rides_horse.png")
140
- ```
141
-
142
- ### Image-to-Image text-guided generation with Stable Diffusion
143
-
144
- The `StableDiffusionImg2ImgPipeline` lets you pass a text prompt and an initial image to condition the generation of new images.
145
-
146
- ```python
147
- import requests
148
- from PIL import Image
149
- from io import BytesIO
150
-
151
- from diffusers import StableDiffusionImg2ImgPipeline
152
-
153
- # load the pipeline
154
- device = "cuda"
155
- pipe = StableDiffusionImg2ImgPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16).to(
156
- device
157
- )
158
-
159
- # let's download an initial image
160
- url = "https://raw.githubusercontent.com/CompVis/stable-diffusion/main/assets/stable-samples/img2img/sketch-mountains-input.jpg"
161
-
162
- response = requests.get(url)
163
- init_image = Image.open(BytesIO(response.content)).convert("RGB")
164
- init_image = init_image.resize((768, 512))
165
-
166
- prompt = "A fantasy landscape, trending on artstation"
167
-
168
- images = pipe(prompt=prompt, image=init_image, strength=0.75, guidance_scale=7.5).images
169
-
170
- images[0].save("fantasy_landscape.png")
171
- ```
172
- You can also run this example on colab [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers/image_2_image_using_diffusers.ipynb)
173
-
174
- ### Tweak prompts reusing seeds and latents
175
-
176
- You can generate your own latents to reproduce results, or tweak your prompt on a specific result you liked. [This notebook](https://github.com/pcuenca/diffusers-examples/blob/main/notebooks/stable-diffusion-seeds.ipynb) shows how to do it step by step. You can also run it in Google Colab [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/pcuenca/diffusers-examples/blob/main/notebooks/stable-diffusion-seeds.ipynb)
177
-
178
-
179
- ### In-painting using Stable Diffusion
180
-
181
- The `StableDiffusionInpaintPipeline` lets you edit specific parts of an image by providing a mask and text prompt.
182
-
183
- ```python
184
- import PIL
185
- import requests
186
- import torch
187
- from io import BytesIO
188
-
189
- from diffusers import StableDiffusionInpaintPipeline
190
-
191
-
192
- def download_image(url):
193
- response = requests.get(url)
194
- return PIL.Image.open(BytesIO(response.content)).convert("RGB")
195
-
196
-
197
- img_url = "https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo.png"
198
- mask_url = "https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo_mask.png"
199
-
200
- init_image = download_image(img_url).resize((512, 512))
201
- mask_image = download_image(mask_url).resize((512, 512))
202
-
203
- pipe = StableDiffusionInpaintPipeline.from_pretrained(
204
- "runwayml/stable-diffusion-inpainting",
205
- torch_dtype=torch.float16,
206
- )
207
- pipe = pipe.to("cuda")
208
-
209
- prompt = "Face of a yellow cat, high resolution, sitting on a park bench"
210
- image = pipe(prompt=prompt, image=init_image, mask_image=mask_image).images[0]
211
- ```
212
-
213
- You can also run this example on colab [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers/in_painting_with_stable_diffusion_using_diffusers.ipynb)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/source/en/api/pipelines/paint_by_example.mdx DELETED
@@ -1,74 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # PaintByExample
14
-
15
- ## Overview
16
-
17
- [Paint by Example: Exemplar-based Image Editing with Diffusion Models](https://arxiv.org/abs/2211.13227) by Binxin Yang, Shuyang Gu, Bo Zhang, Ting Zhang, Xuejin Chen, Xiaoyan Sun, Dong Chen, Fang Wen.
18
-
19
- The abstract of the paper is the following:
20
-
21
- *Language-guided image editing has achieved great success recently. In this paper, for the first time, we investigate exemplar-guided image editing for more precise control. We achieve this goal by leveraging self-supervised training to disentangle and re-organize the source image and the exemplar. However, the naive approach will cause obvious fusing artifacts. We carefully analyze it and propose an information bottleneck and strong augmentations to avoid the trivial solution of directly copying and pasting the exemplar image. Meanwhile, to ensure the controllability of the editing process, we design an arbitrary shape mask for the exemplar image and leverage the classifier-free guidance to increase the similarity to the exemplar image. The whole framework involves a single forward of the diffusion model without any iterative optimization. We demonstrate that our method achieves an impressive performance and enables controllable editing on in-the-wild images with high fidelity.*
22
-
23
- The original codebase can be found [here](https://github.com/Fantasy-Studio/Paint-by-Example).
24
-
25
- ## Available Pipelines:
26
-
27
- | Pipeline | Tasks | Colab
28
- |---|---|:---:|
29
- | [pipeline_paint_by_example.py](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/paint_by_example/pipeline_paint_by_example.py) | *Image-Guided Image Painting* | - |
30
-
31
- ## Tips
32
-
33
- - PaintByExample is supported by the official [Fantasy-Studio/Paint-by-Example](https://huggingface.co/Fantasy-Studio/Paint-by-Example) checkpoint. The checkpoint has been warm-started from the [CompVis/stable-diffusion-v1-4](https://huggingface.co/CompVis/stable-diffusion-v1-4) and with the objective to inpaint partly masked images conditioned on example / reference images
34
- - To quickly demo *PaintByExample*, please have a look at [this demo](https://huggingface.co/spaces/Fantasy-Studio/Paint-by-Example)
35
- - You can run the following code snippet as an example:
36
-
37
-
38
- ```python
39
- # !pip install diffusers transformers
40
-
41
- import PIL
42
- import requests
43
- import torch
44
- from io import BytesIO
45
- from diffusers import DiffusionPipeline
46
-
47
-
48
- def download_image(url):
49
- response = requests.get(url)
50
- return PIL.Image.open(BytesIO(response.content)).convert("RGB")
51
-
52
-
53
- img_url = "https://raw.githubusercontent.com/Fantasy-Studio/Paint-by-Example/main/examples/image/example_1.png"
54
- mask_url = "https://raw.githubusercontent.com/Fantasy-Studio/Paint-by-Example/main/examples/mask/example_1.png"
55
- example_url = "https://raw.githubusercontent.com/Fantasy-Studio/Paint-by-Example/main/examples/reference/example_1.jpg"
56
-
57
- init_image = download_image(img_url).resize((512, 512))
58
- mask_image = download_image(mask_url).resize((512, 512))
59
- example_image = download_image(example_url).resize((512, 512))
60
-
61
- pipe = DiffusionPipeline.from_pretrained(
62
- "Fantasy-Studio/Paint-by-Example",
63
- torch_dtype=torch.float16,
64
- )
65
- pipe = pipe.to("cuda")
66
-
67
- image = pipe(image=init_image, mask_image=mask_image, example_image=example_image).images[0]
68
- image
69
- ```
70
-
71
- ## PaintByExamplePipeline
72
- [[autodoc]] PaintByExamplePipeline
73
- - all
74
- - __call__
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/source/en/api/pipelines/pndm.mdx DELETED
@@ -1,35 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # PNDM
14
-
15
- ## Overview
16
-
17
- [Pseudo Numerical methods for Diffusion Models on manifolds](https://arxiv.org/abs/2202.09778) (PNDM) by Luping Liu, Yi Ren, Zhijie Lin and Zhou Zhao.
18
-
19
- The abstract of the paper is the following:
20
-
21
- Denoising Diffusion Probabilistic Models (DDPMs) can generate high-quality samples such as image and audio samples. However, DDPMs require hundreds to thousands of iterations to produce final samples. Several prior works have successfully accelerated DDPMs through adjusting the variance schedule (e.g., Improved Denoising Diffusion Probabilistic Models) or the denoising equation (e.g., Denoising Diffusion Implicit Models (DDIMs)). However, these acceleration methods cannot maintain the quality of samples and even introduce new noise at a high speedup rate, which limit their practicability. To accelerate the inference process while keeping the sample quality, we provide a fresh perspective that DDPMs should be treated as solving differential equations on manifolds. Under such a perspective, we propose pseudo numerical methods for diffusion models (PNDMs). Specifically, we figure out how to solve differential equations on manifolds and show that DDIMs are simple cases of pseudo numerical methods. We change several classical numerical methods to corresponding pseudo numerical methods and find that the pseudo linear multi-step method is the best in most situations. According to our experiments, by directly using pre-trained models on Cifar10, CelebA and LSUN, PNDMs can generate higher quality synthetic images with only 50 steps compared with 1000-step DDIMs (20x speedup), significantly outperform DDIMs with 250 steps (by around 0.4 in FID) and have good generalization on different variance schedules.
22
-
23
- The original codebase can be found [here](https://github.com/luping-liu/PNDM).
24
-
25
- ## Available Pipelines:
26
-
27
- | Pipeline | Tasks | Colab
28
- |---|---|:---:|
29
- | [pipeline_pndm.py](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/pndm/pipeline_pndm.py) | *Unconditional Image Generation* | - |
30
-
31
-
32
- ## PNDMPipeline
33
- [[autodoc]] PNDMPipeline
34
- - all
35
- - __call__
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/source/en/api/pipelines/repaint.mdx DELETED
@@ -1,77 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # RePaint
14
-
15
- ## Overview
16
-
17
- [RePaint: Inpainting using Denoising Diffusion Probabilistic Models](https://arxiv.org/abs/2201.09865) (PNDM) by Andreas Lugmayr, Martin Danelljan, Andres Romero, Fisher Yu, Radu Timofte, Luc Van Gool.
18
-
19
- The abstract of the paper is the following:
20
-
21
- Free-form inpainting is the task of adding new content to an image in the regions specified by an arbitrary binary mask. Most existing approaches train for a certain distribution of masks, which limits their generalization capabilities to unseen mask types. Furthermore, training with pixel-wise and perceptual losses often leads to simple textural extensions towards the missing areas instead of semantically meaningful generation. In this work, we propose RePaint: A Denoising Diffusion Probabilistic Model (DDPM) based inpainting approach that is applicable to even extreme masks. We employ a pretrained unconditional DDPM as the generative prior. To condition the generation process, we only alter the reverse diffusion iterations by sampling the unmasked regions using the given image information. Since this technique does not modify or condition the original DDPM network itself, the model produces high-quality and diverse output images for any inpainting form. We validate our method for both faces and general-purpose image inpainting using standard and extreme masks.
22
- RePaint outperforms state-of-the-art Autoregressive, and GAN approaches for at least five out of six mask distributions.
23
-
24
- The original codebase can be found [here](https://github.com/andreas128/RePaint).
25
-
26
- ## Available Pipelines:
27
-
28
- | Pipeline | Tasks | Colab
29
- |-------------------------------------------------------------------------------------------------------------------------------|--------------------|:---:|
30
- | [pipeline_repaint.py](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/repaint/pipeline_repaint.py) | *Image Inpainting* | - |
31
-
32
- ## Usage example
33
-
34
- ```python
35
- from io import BytesIO
36
-
37
- import torch
38
-
39
- import PIL
40
- import requests
41
- from diffusers import RePaintPipeline, RePaintScheduler
42
-
43
-
44
- def download_image(url):
45
- response = requests.get(url)
46
- return PIL.Image.open(BytesIO(response.content)).convert("RGB")
47
-
48
-
49
- img_url = "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/repaint/celeba_hq_256.png"
50
- mask_url = "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/repaint/mask_256.png"
51
-
52
- # Load the original image and the mask as PIL images
53
- original_image = download_image(img_url).resize((256, 256))
54
- mask_image = download_image(mask_url).resize((256, 256))
55
-
56
- # Load the RePaint scheduler and pipeline based on a pretrained DDPM model
57
- scheduler = RePaintScheduler.from_pretrained("google/ddpm-ema-celebahq-256")
58
- pipe = RePaintPipeline.from_pretrained("google/ddpm-ema-celebahq-256", scheduler=scheduler)
59
- pipe = pipe.to("cuda")
60
-
61
- generator = torch.Generator(device="cuda").manual_seed(0)
62
- output = pipe(
63
- original_image=original_image,
64
- mask_image=mask_image,
65
- num_inference_steps=250,
66
- eta=0.0,
67
- jump_length=10,
68
- jump_n_sample=10,
69
- generator=generator,
70
- )
71
- inpainted_image = output.images[0]
72
- ```
73
-
74
- ## RePaintPipeline
75
- [[autodoc]] RePaintPipeline
76
- - all
77
- - __call__
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/source/en/api/pipelines/score_sde_ve.mdx DELETED
@@ -1,36 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # Score SDE VE
14
-
15
- ## Overview
16
-
17
- [Score-Based Generative Modeling through Stochastic Differential Equations](https://arxiv.org/abs/2011.13456) (Score SDE) by Yang Song, Jascha Sohl-Dickstein, Diederik P. Kingma, Abhishek Kumar, Stefano Ermon and Ben Poole.
18
-
19
- The abstract of the paper is the following:
20
-
21
- Creating noise from data is easy; creating data from noise is generative modeling. We present a stochastic differential equation (SDE) that smoothly transforms a complex data distribution to a known prior distribution by slowly injecting noise, and a corresponding reverse-time SDE that transforms the prior distribution back into the data distribution by slowly removing the noise. Crucially, the reverse-time SDE depends only on the time-dependent gradient field (\aka, score) of the perturbed data distribution. By leveraging advances in score-based generative modeling, we can accurately estimate these scores with neural networks, and use numerical SDE solvers to generate samples. We show that this framework encapsulates previous approaches in score-based generative modeling and diffusion probabilistic modeling, allowing for new sampling procedures and new modeling capabilities. In particular, we introduce a predictor-corrector framework to correct errors in the evolution of the discretized reverse-time SDE. We also derive an equivalent neural ODE that samples from the same distribution as the SDE, but additionally enables exact likelihood computation, and improved sampling efficiency. In addition, we provide a new way to solve inverse problems with score-based models, as demonstrated with experiments on class-conditional generation, image inpainting, and colorization. Combined with multiple architectural improvements, we achieve record-breaking performance for unconditional image generation on CIFAR-10 with an Inception score of 9.89 and FID of 2.20, a competitive likelihood of 2.99 bits/dim, and demonstrate high fidelity generation of 1024 x 1024 images for the first time from a score-based generative model.
22
-
23
- The original codebase can be found [here](https://github.com/yang-song/score_sde_pytorch).
24
-
25
- This pipeline implements the Variance Expanding (VE) variant of the method.
26
-
27
- ## Available Pipelines:
28
-
29
- | Pipeline | Tasks | Colab
30
- |---|---|:---:|
31
- | [pipeline_score_sde_ve.py](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/score_sde_ve/pipeline_score_sde_ve.py) | *Unconditional Image Generation* | - |
32
-
33
- ## ScoreSdeVePipeline
34
- [[autodoc]] ScoreSdeVePipeline
35
- - all
36
- - __call__
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/source/en/api/pipelines/semantic_stable_diffusion.mdx DELETED
@@ -1,79 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # Semantic Guidance
14
-
15
- Semantic Guidance for Diffusion Models was proposed in [SEGA: Instructing Diffusion using Semantic Dimensions](https://arxiv.org/abs/2301.12247) and provides strong semantic control over the image generation.
16
- Small changes to the text prompt usually result in entirely different output images. However, with SEGA a variety of changes to the image are enabled that can be controlled easily and intuitively, and stay true to the original image composition.
17
-
18
- The abstract of the paper is the following:
19
-
20
- *Text-to-image diffusion models have recently received a lot of interest for their astonishing ability to produce high-fidelity images from text only. However, achieving one-shot generation that aligns with the user's intent is nearly impossible, yet small changes to the input prompt often result in very different images. This leaves the user with little semantic control. To put the user in control, we show how to interact with the diffusion process to flexibly steer it along semantic directions. This semantic guidance (SEGA) allows for subtle and extensive edits, changes in composition and style, as well as optimizing the overall artistic conception. We demonstrate SEGA's effectiveness on a variety of tasks and provide evidence for its versatility and flexibility.*
21
-
22
-
23
- *Overview*:
24
-
25
- | Pipeline | Tasks | Colab | Demo
26
- |---|---|:---:|:---:|
27
- | [pipeline_semantic_stable_diffusion.py](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/semantic_stable_diffusion/pipeline_semantic_stable_diffusion.py) | *Text-to-Image Generation* | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/ml-research/semantic-image-editing/blob/main/examples/SemanticGuidance.ipynb) | [Coming Soon](https://huggingface.co/AIML-TUDA)
28
-
29
- ## Tips
30
-
31
- - The Semantic Guidance pipeline can be used with any [Stable Diffusion](./stable_diffusion/text2img) checkpoint.
32
-
33
- ### Run Semantic Guidance
34
-
35
- The interface of [`SemanticStableDiffusionPipeline`] provides several additional parameters to influence the image generation.
36
- Exemplary usage may look like this:
37
-
38
- ```python
39
- import torch
40
- from diffusers import SemanticStableDiffusionPipeline
41
-
42
- pipe = SemanticStableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16)
43
- pipe = pipe.to("cuda")
44
-
45
- out = pipe(
46
- prompt="a photo of the face of a woman",
47
- num_images_per_prompt=1,
48
- guidance_scale=7,
49
- editing_prompt=[
50
- "smiling, smile", # Concepts to apply
51
- "glasses, wearing glasses",
52
- "curls, wavy hair, curly hair",
53
- "beard, full beard, mustache",
54
- ],
55
- reverse_editing_direction=[False, False, False, False], # Direction of guidance i.e. increase all concepts
56
- edit_warmup_steps=[10, 10, 10, 10], # Warmup period for each concept
57
- edit_guidance_scale=[4, 5, 5, 5.4], # Guidance scale for each concept
58
- edit_threshold=[
59
- 0.99,
60
- 0.975,
61
- 0.925,
62
- 0.96,
63
- ], # Threshold for each concept. Threshold equals the percentile of the latent space that will be discarded. I.e. threshold=0.99 uses 1% of the latent dimensions
64
- edit_momentum_scale=0.3, # Momentum scale that will be added to the latent guidance
65
- edit_mom_beta=0.6, # Momentum beta
66
- edit_weights=[1, 1, 1, 1, 1], # Weights of the individual concepts against each other
67
- )
68
- ```
69
-
70
- For more examples check the Colab notebook.
71
-
72
- ## StableDiffusionSafePipelineOutput
73
- [[autodoc]] pipelines.semantic_stable_diffusion.SemanticStableDiffusionPipelineOutput
74
- - all
75
-
76
- ## SemanticStableDiffusionPipeline
77
- [[autodoc]] SemanticStableDiffusionPipeline
78
- - all
79
- - __call__
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/source/en/api/pipelines/spectrogram_diffusion.mdx DELETED
@@ -1,54 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # Multi-instrument Music Synthesis with Spectrogram Diffusion
14
-
15
- ## Overview
16
-
17
- [Spectrogram Diffusion](https://arxiv.org/abs/2206.05408) by Curtis Hawthorne, Ian Simon, Adam Roberts, Neil Zeghidour, Josh Gardner, Ethan Manilow, and Jesse Engel.
18
-
19
- An ideal music synthesizer should be both interactive and expressive, generating high-fidelity audio in realtime for arbitrary combinations of instruments and notes. Recent neural synthesizers have exhibited a tradeoff between domain-specific models that offer detailed control of only specific instruments, or raw waveform models that can train on any music but with minimal control and slow generation. In this work, we focus on a middle ground of neural synthesizers that can generate audio from MIDI sequences with arbitrary combinations of instruments in realtime. This enables training on a wide range of transcription datasets with a single model, which in turn offers note-level control of composition and instrumentation across a wide range of instruments. We use a simple two-stage process: MIDI to spectrograms with an encoder-decoder Transformer, then spectrograms to audio with a generative adversarial network (GAN) spectrogram inverter. We compare training the decoder as an autoregressive model and as a Denoising Diffusion Probabilistic Model (DDPM) and find that the DDPM approach is superior both qualitatively and as measured by audio reconstruction and Fréchet distance metrics. Given the interactivity and generality of this approach, we find this to be a promising first step towards interactive and expressive neural synthesis for arbitrary combinations of instruments and notes.
20
-
21
- The original codebase of this implementation can be found at [magenta/music-spectrogram-diffusion](https://github.com/magenta/music-spectrogram-diffusion).
22
-
23
- ## Model
24
-
25
- ![img](https://storage.googleapis.com/music-synthesis-with-spectrogram-diffusion/architecture.png)
26
-
27
- As depicted above the model takes as input a MIDI file and tokenizes it into a sequence of 5 second intervals. Each tokenized interval then together with positional encodings is passed through the Note Encoder and its representation is concatenated with the previous window's generated spectrogram representation obtained via the Context Encoder. For the initial 5 second window this is set to zero. The resulting context is then used as conditioning to sample the denoised Spectrogram from the MIDI window and we concatenate this spectrogram to the final output as well as use it for the context of the next MIDI window. The process repeats till we have gone over all the MIDI inputs. Finally a MelGAN decoder converts the potentially long spectrogram to audio which is the final result of this pipeline.
28
-
29
- ## Available Pipelines:
30
-
31
- | Pipeline | Tasks | Colab
32
- |---|---|:---:|
33
- | [pipeline_spectrogram_diffusion.py](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/spectrogram_diffusion/pipeline_spectrogram_diffusion) | *Unconditional Audio Generation* | - |
34
-
35
-
36
- ## Example usage
37
-
38
- ```python
39
- from diffusers import SpectrogramDiffusionPipeline, MidiProcessor
40
-
41
- pipe = SpectrogramDiffusionPipeline.from_pretrained("google/music-spectrogram-diffusion")
42
- pipe = pipe.to("cuda")
43
- processor = MidiProcessor()
44
-
45
- # Download MIDI from: wget http://www.piano-midi.de/midis/beethoven/beethoven_hammerklavier_2.mid
46
- output = pipe(processor("beethoven_hammerklavier_2.mid"))
47
-
48
- audio = output.audios[0]
49
- ```
50
-
51
- ## SpectrogramDiffusionPipeline
52
- [[autodoc]] SpectrogramDiffusionPipeline
53
- - all
54
- - __call__
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/source/en/api/pipelines/stable_diffusion/attend_and_excite.mdx DELETED
@@ -1,75 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # Attend and Excite: Attention-Based Semantic Guidance for Text-to-Image Diffusion Models
14
-
15
- ## Overview
16
-
17
- Attend and Excite for Stable Diffusion was proposed in [Attend-and-Excite: Attention-Based Semantic Guidance for Text-to-Image Diffusion Models](https://attendandexcite.github.io/Attend-and-Excite/) and provides textual attention control over the image generation.
18
-
19
- The abstract of the paper is the following:
20
-
21
- *Text-to-image diffusion models have recently received a lot of interest for their astonishing ability to produce high-fidelity images from text only. However, achieving one-shot generation that aligns with the user's intent is nearly impossible, yet small changes to the input prompt often result in very different images. This leaves the user with little semantic control. To put the user in control, we show how to interact with the diffusion process to flexibly steer it along semantic directions. This semantic guidance (SEGA) allows for subtle and extensive edits, changes in composition and style, as well as optimizing the overall artistic conception. We demonstrate SEGA's effectiveness on a variety of tasks and provide evidence for its versatility and flexibility.*
22
-
23
- Resources
24
-
25
- * [Project Page](https://attendandexcite.github.io/Attend-and-Excite/)
26
- * [Paper](https://arxiv.org/abs/2301.13826)
27
- * [Original Code](https://github.com/AttendAndExcite/Attend-and-Excite)
28
- * [Demo](https://huggingface.co/spaces/AttendAndExcite/Attend-and-Excite)
29
-
30
-
31
- ## Available Pipelines:
32
-
33
- | Pipeline | Tasks | Colab | Demo
34
- |---|---|:---:|:---:|
35
- | [pipeline_semantic_stable_diffusion_attend_and_excite.py](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_semantic_stable_diffusion_attend_and_excite) | *Text-to-Image Generation* | - | https://huggingface.co/spaces/AttendAndExcite/Attend-and-Excite
36
-
37
-
38
- ### Usage example
39
-
40
-
41
- ```python
42
- import torch
43
- from diffusers import StableDiffusionAttendAndExcitePipeline
44
-
45
- model_id = "CompVis/stable-diffusion-v1-4"
46
- pipe = StableDiffusionAttendAndExcitePipeline.from_pretrained(model_id, torch_dtype=torch.float16).to("cuda")
47
- pipe = pipe.to("cuda")
48
-
49
- prompt = "a cat and a frog"
50
-
51
- # use get_indices function to find out indices of the tokens you want to alter
52
- pipe.get_indices(prompt)
53
-
54
- token_indices = [2, 5]
55
- seed = 6141
56
- generator = torch.Generator("cuda").manual_seed(seed)
57
-
58
- images = pipe(
59
- prompt=prompt,
60
- token_indices=token_indices,
61
- guidance_scale=7.5,
62
- generator=generator,
63
- num_inference_steps=50,
64
- max_iter_to_alter=25,
65
- ).images
66
-
67
- image = images[0]
68
- image.save(f"../images/{prompt}_{seed}.png")
69
- ```
70
-
71
-
72
- ## StableDiffusionAttendAndExcitePipeline
73
- [[autodoc]] StableDiffusionAttendAndExcitePipeline
74
- - all
75
- - __call__
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/source/en/api/pipelines/stable_diffusion/controlnet.mdx DELETED
@@ -1,280 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # Text-to-Image Generation with ControlNet Conditioning
14
-
15
- ## Overview
16
-
17
- [Adding Conditional Control to Text-to-Image Diffusion Models](https://arxiv.org/abs/2302.05543) by Lvmin Zhang and Maneesh Agrawala.
18
-
19
- Using the pretrained models we can provide control images (for example, a depth map) to control Stable Diffusion text-to-image generation so that it follows the structure of the depth image and fills in the details.
20
-
21
- The abstract of the paper is the following:
22
-
23
- *We present a neural network structure, ControlNet, to control pretrained large diffusion models to support additional input conditions. The ControlNet learns task-specific conditions in an end-to-end way, and the learning is robust even when the training dataset is small (< 50k). Moreover, training a ControlNet is as fast as fine-tuning a diffusion model, and the model can be trained on a personal devices. Alternatively, if powerful computation clusters are available, the model can scale to large amounts (millions to billions) of data. We report that large diffusion models like Stable Diffusion can be augmented with ControlNets to enable conditional inputs like edge maps, segmentation maps, keypoints, etc. This may enrich the methods to control large diffusion models and further facilitate related applications.*
24
-
25
- This model was contributed by the amazing community contributor [takuma104](https://huggingface.co/takuma104) ❤️ .
26
-
27
- Resources:
28
-
29
- * [Paper](https://arxiv.org/abs/2302.05543)
30
- * [Original Code](https://github.com/lllyasviel/ControlNet)
31
-
32
- ## Available Pipelines:
33
-
34
- | Pipeline | Tasks | Demo
35
- |---|---|:---:|
36
- | [StableDiffusionControlNetPipeline](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_controlnet.py) | *Text-to-Image Generation with ControlNet Conditioning* | [Colab Example](https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers/controlnet.ipynb)
37
-
38
- ## Usage example
39
-
40
- In the following we give a simple example of how to use a *ControlNet* checkpoint with Diffusers for inference.
41
- The inference pipeline is the same for all pipelines:
42
-
43
- * 1. Take an image and run it through a pre-conditioning processor.
44
- * 2. Run the pre-processed image through the [`StableDiffusionControlNetPipeline`].
45
-
46
- Let's have a look at a simple example using the [Canny Edge ControlNet](https://huggingface.co/lllyasviel/sd-controlnet-canny).
47
-
48
- ```python
49
- from diffusers import StableDiffusionControlNetPipeline
50
- from diffusers.utils import load_image
51
-
52
- # Let's load the popular vermeer image
53
- image = load_image(
54
- "https://hf.co/datasets/huggingface/documentation-images/resolve/main/diffusers/input_image_vermeer.png"
55
- )
56
- ```
57
-
58
- ![img](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/input_image_vermeer.png)
59
-
60
- Next, we process the image to get the canny image. This is step *1.* - running the pre-conditioning processor. The pre-conditioning processor is different for every ControlNet. Please see the model cards of the [official checkpoints](#controlnet-with-stable-diffusion-1.5) for more information about other models.
61
-
62
- First, we need to install opencv:
63
-
64
- ```
65
- pip install opencv-contrib-python
66
- ```
67
-
68
- Next, let's also install all required Hugging Face libraries:
69
-
70
- ```
71
- pip install diffusers transformers git+https://github.com/huggingface/accelerate.git
72
- ```
73
-
74
- Then we can retrieve the canny edges of the image.
75
-
76
- ```python
77
- import cv2
78
- from PIL import Image
79
- import numpy as np
80
-
81
- image = np.array(image)
82
-
83
- low_threshold = 100
84
- high_threshold = 200
85
-
86
- image = cv2.Canny(image, low_threshold, high_threshold)
87
- image = image[:, :, None]
88
- image = np.concatenate([image, image, image], axis=2)
89
- canny_image = Image.fromarray(image)
90
- ```
91
-
92
- Let's take a look at the processed image.
93
-
94
- ![img](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/vermeer_canny_edged.png)
95
-
96
- Now, we load the official [Stable Diffusion 1.5 Model](runwayml/stable-diffusion-v1-5) as well as the ControlNet for canny edges.
97
-
98
- ```py
99
- from diffusers import StableDiffusionControlNetPipeline, ControlNetModel
100
- import torch
101
-
102
- controlnet = ControlNetModel.from_pretrained("lllyasviel/sd-controlnet-canny", torch_dtype=torch.float16)
103
- pipe = StableDiffusionControlNetPipeline.from_pretrained(
104
- "runwayml/stable-diffusion-v1-5", controlnet=controlnet, torch_dtype=torch.float16
105
- )
106
- ```
107
-
108
- To speed-up things and reduce memory, let's enable model offloading and use the fast [`UniPCMultistepScheduler`].
109
-
110
- ```py
111
- from diffusers import UniPCMultistepScheduler
112
-
113
- pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
114
-
115
- # this command loads the individual model components on GPU on-demand.
116
- pipe.enable_model_cpu_offload()
117
- ```
118
-
119
- Finally, we can run the pipeline:
120
-
121
- ```py
122
- generator = torch.manual_seed(0)
123
-
124
- out_image = pipe(
125
- "disco dancer with colorful lights", num_inference_steps=20, generator=generator, image=canny_image
126
- ).images[0]
127
- ```
128
-
129
- This should take only around 3-4 seconds on GPU (depending on hardware). The output image then looks as follows:
130
-
131
- ![img](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/vermeer_disco_dancing.png)
132
-
133
-
134
- **Note**: To see how to run all other ControlNet checkpoints, please have a look at [ControlNet with Stable Diffusion 1.5](#controlnet-with-stable-diffusion-1.5).
135
-
136
- <!-- TODO: add space -->
137
-
138
- ## Combining multiple conditionings
139
-
140
- Multiple ControlNet conditionings can be combined for a single image generation. Pass a list of ControlNets to the pipeline's constructor and a corresponding list of conditionings to `__call__`.
141
-
142
- When combining conditionings, it is helpful to mask conditionings such that they do not overlap. In the example, we mask the middle of the canny map where the pose conditioning is located.
143
-
144
- It can also be helpful to vary the `controlnet_conditioning_scales` to emphasize one conditioning over the other.
145
-
146
- ### Canny conditioning
147
-
148
- The original image:
149
-
150
- <img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/landscape.png"/>
151
-
152
- Prepare the conditioning:
153
-
154
- ```python
155
- from diffusers.utils import load_image
156
- from PIL import Image
157
- import cv2
158
- import numpy as np
159
- from diffusers.utils import load_image
160
-
161
- canny_image = load_image(
162
- "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/landscape.png"
163
- )
164
- canny_image = np.array(canny_image)
165
-
166
- low_threshold = 100
167
- high_threshold = 200
168
-
169
- canny_image = cv2.Canny(canny_image, low_threshold, high_threshold)
170
-
171
- # zero out middle columns of image where pose will be overlayed
172
- zero_start = canny_image.shape[1] // 4
173
- zero_end = zero_start + canny_image.shape[1] // 2
174
- canny_image[:, zero_start:zero_end] = 0
175
-
176
- canny_image = canny_image[:, :, None]
177
- canny_image = np.concatenate([canny_image, canny_image, canny_image], axis=2)
178
- canny_image = Image.fromarray(canny_image)
179
- ```
180
-
181
- <img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/controlnet/landscape_canny_masked.png"/>
182
-
183
- ### Openpose conditioning
184
-
185
- The original image:
186
-
187
- <img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/person.png" width=600/>
188
-
189
- Prepare the conditioning:
190
-
191
- ```python
192
- from controlnet_aux import OpenposeDetector
193
- from diffusers.utils import load_image
194
-
195
- openpose = OpenposeDetector.from_pretrained("lllyasviel/ControlNet")
196
-
197
- openpose_image = load_image(
198
- "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/person.png"
199
- )
200
- openpose_image = openpose(openpose_image)
201
- ```
202
-
203
- <img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/controlnet/person_pose.png" width=600/>
204
-
205
- ### Running ControlNet with multiple conditionings
206
-
207
- ```python
208
- from diffusers import StableDiffusionControlNetPipeline, ControlNetModel, UniPCMultistepScheduler
209
- import torch
210
-
211
- controlnet = [
212
- ControlNetModel.from_pretrained("lllyasviel/sd-controlnet-openpose", torch_dtype=torch.float16),
213
- ControlNetModel.from_pretrained("lllyasviel/sd-controlnet-canny", torch_dtype=torch.float16),
214
- ]
215
-
216
- pipe = StableDiffusionControlNetPipeline.from_pretrained(
217
- "runwayml/stable-diffusion-v1-5", controlnet=controlnet, torch_dtype=torch.float16
218
- )
219
- pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
220
-
221
- pipe.enable_xformers_memory_efficient_attention()
222
- pipe.enable_model_cpu_offload()
223
-
224
- prompt = "a giant standing in a fantasy landscape, best quality"
225
- negative_prompt = "monochrome, lowres, bad anatomy, worst quality, low quality"
226
-
227
- generator = torch.Generator(device="cpu").manual_seed(1)
228
-
229
- images = [openpose_image, canny_image]
230
-
231
- image = pipe(
232
- prompt,
233
- images,
234
- num_inference_steps=20,
235
- generator=generator,
236
- negative_prompt=negative_prompt,
237
- controlnet_conditioning_scale=[1.0, 0.8],
238
- ).images[0]
239
-
240
- image.save("./multi_controlnet_output.png")
241
- ```
242
-
243
- <img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/controlnet/multi_controlnet_output.png" width=600/>
244
-
245
- ## Available checkpoints
246
-
247
- ControlNet requires a *control image* in addition to the text-to-image *prompt*.
248
- Each pretrained model is trained using a different conditioning method that requires different images for conditioning the generated outputs. For example, Canny edge conditioning requires the control image to be the output of a Canny filter, while depth conditioning requires the control image to be a depth map. See the overview and image examples below to know more.
249
-
250
- All checkpoints can be found under the authors' namespace [lllyasviel](https://huggingface.co/lllyasviel).
251
-
252
- ### ControlNet with Stable Diffusion 1.5
253
-
254
- | Model Name | Control Image Overview| Control Image Example | Generated Image Example |
255
- |---|---|---|---|
256
- |[lllyasviel/sd-controlnet-canny](https://huggingface.co/lllyasviel/sd-controlnet-canny)<br/> *Trained with canny edge detection* | A monochrome image with white edges on a black background.|<a href="https://huggingface.co/takuma104/controlnet_dev/blob/main/gen_compare/control_images/converted/control_bird_canny.png"><img width="64" style="margin:0;padding:0;" src="https://huggingface.co/takuma104/controlnet_dev/resolve/main/gen_compare/control_images/converted/control_bird_canny.png"/></a>|<a href="https://huggingface.co/takuma104/controlnet_dev/resolve/main/gen_compare/output_images/diffusers/output_bird_canny_1.png"><img width="64" src="https://huggingface.co/takuma104/controlnet_dev/resolve/main/gen_compare/output_images/diffusers/output_bird_canny_1.png"/></a>|
257
- |[lllyasviel/sd-controlnet-depth](https://huggingface.co/lllyasviel/sd-controlnet-depth)<br/> *Trained with Midas depth estimation* |A grayscale image with black representing deep areas and white representing shallow areas.|<a href="https://huggingface.co/takuma104/controlnet_dev/blob/main/gen_compare/control_images/converted/control_vermeer_depth.png"><img width="64" src="https://huggingface.co/takuma104/controlnet_dev/resolve/main/gen_compare/control_images/converted/control_vermeer_depth.png"/></a>|<a href="https://huggingface.co/takuma104/controlnet_dev/resolve/main/gen_compare/output_images/diffusers/output_vermeer_depth_2.png"><img width="64" src="https://huggingface.co/takuma104/controlnet_dev/resolve/main/gen_compare/output_images/diffusers/output_vermeer_depth_2.png"/></a>|
258
- |[lllyasviel/sd-controlnet-hed](https://huggingface.co/lllyasviel/sd-controlnet-hed)<br/> *Trained with HED edge detection (soft edge)* |A monochrome image with white soft edges on a black background.|<a href="https://huggingface.co/takuma104/controlnet_dev/blob/main/gen_compare/control_images/converted/control_bird_hed.png"><img width="64" src="https://huggingface.co/takuma104/controlnet_dev/resolve/main/gen_compare/control_images/converted/control_bird_hed.png"/></a>|<a href="https://huggingface.co/takuma104/controlnet_dev/resolve/main/gen_compare/output_images/diffusers/output_bird_hed_1.png"><img width="64" src="https://huggingface.co/takuma104/controlnet_dev/resolve/main/gen_compare/output_images/diffusers/output_bird_hed_1.png"/></a> |
259
- |[lllyasviel/sd-controlnet-mlsd](https://huggingface.co/lllyasviel/sd-controlnet-mlsd)<br/> *Trained with M-LSD line detection* |A monochrome image composed only of white straight lines on a black background.|<a href="https://huggingface.co/takuma104/controlnet_dev/blob/main/gen_compare/control_images/converted/control_room_mlsd.png"><img width="64" src="https://huggingface.co/takuma104/controlnet_dev/resolve/main/gen_compare/control_images/converted/control_room_mlsd.png"/></a>|<a href="https://huggingface.co/takuma104/controlnet_dev/resolve/main/gen_compare/output_images/diffusers/output_room_mlsd_0.png"><img width="64" src="https://huggingface.co/takuma104/controlnet_dev/resolve/main/gen_compare/output_images/diffusers/output_room_mlsd_0.png"/></a>|
260
- |[lllyasviel/sd-controlnet-normal](https://huggingface.co/lllyasviel/sd-controlnet-normal)<br/> *Trained with normal map* |A [normal mapped](https://en.wikipedia.org/wiki/Normal_mapping) image.|<a href="https://huggingface.co/takuma104/controlnet_dev/blob/main/gen_compare/control_images/converted/control_human_normal.png"><img width="64" src="https://huggingface.co/takuma104/controlnet_dev/resolve/main/gen_compare/control_images/converted/control_human_normal.png"/></a>|<a href="https://huggingface.co/takuma104/controlnet_dev/resolve/main/gen_compare/output_images/diffusers/output_human_normal_1.png"><img width="64" src="https://huggingface.co/takuma104/controlnet_dev/resolve/main/gen_compare/output_images/diffusers/output_human_normal_1.png"/></a>|
261
- |[lllyasviel/sd-controlnet-openpose](https://huggingface.co/lllyasviel/sd-controlnet_openpose)<br/> *Trained with OpenPose bone image* |A [OpenPose bone](https://github.com/CMU-Perceptual-Computing-Lab/openpose) image.|<a href="https://huggingface.co/takuma104/controlnet_dev/blob/main/gen_compare/control_images/converted/control_human_openpose.png"><img width="64" src="https://huggingface.co/takuma104/controlnet_dev/resolve/main/gen_compare/control_images/converted/control_human_openpose.png"/></a>|<a href="https://huggingface.co/takuma104/controlnet_dev/resolve/main/gen_compare/output_images/diffusers/output_human_openpose_0.png"><img width="64" src="https://huggingface.co/takuma104/controlnet_dev/resolve/main/gen_compare/output_images/diffusers/output_human_openpose_0.png"/></a>|
262
- |[lllyasviel/sd-controlnet-scribble](https://huggingface.co/lllyasviel/sd-controlnet_scribble)<br/> *Trained with human scribbles* |A hand-drawn monochrome image with white outlines on a black background.|<a href="https://huggingface.co/takuma104/controlnet_dev/blob/main/gen_compare/control_images/converted/control_vermeer_scribble.png"><img width="64" src="https://huggingface.co/takuma104/controlnet_dev/resolve/main/gen_compare/control_images/converted/control_vermeer_scribble.png"/></a>|<a href="https://huggingface.co/takuma104/controlnet_dev/resolve/main/gen_compare/output_images/diffusers/output_vermeer_scribble_0.png"><img width="64" src="https://huggingface.co/takuma104/controlnet_dev/resolve/main/gen_compare/output_images/diffusers/output_vermeer_scribble_0.png"/></a> |
263
- |[lllyasviel/sd-controlnet-seg](https://huggingface.co/lllyasviel/sd-controlnet_seg)<br/>*Trained with semantic segmentation* |An [ADE20K](https://groups.csail.mit.edu/vision/datasets/ADE20K/)'s segmentation protocol image.|<a href="https://huggingface.co/takuma104/controlnet_dev/blob/main/gen_compare/control_images/converted/control_room_seg.png"><img width="64" src="https://huggingface.co/takuma104/controlnet_dev/resolve/main/gen_compare/control_images/converted/control_room_seg.png"/></a>|<a href="https://huggingface.co/takuma104/controlnet_dev/resolve/main/gen_compare/output_images/diffusers/output_room_seg_1.png"><img width="64" src="https://huggingface.co/takuma104/controlnet_dev/resolve/main/gen_compare/output_images/diffusers/output_room_seg_1.png"/></a> |
264
-
265
- ## StableDiffusionControlNetPipeline
266
- [[autodoc]] StableDiffusionControlNetPipeline
267
- - all
268
- - __call__
269
- - enable_attention_slicing
270
- - disable_attention_slicing
271
- - enable_vae_slicing
272
- - disable_vae_slicing
273
- - enable_xformers_memory_efficient_attention
274
- - disable_xformers_memory_efficient_attention
275
-
276
- ## FlaxStableDiffusionControlNetPipeline
277
- [[autodoc]] FlaxStableDiffusionControlNetPipeline
278
- - all
279
- - __call__
280
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/source/en/api/pipelines/stable_diffusion/depth2img.mdx DELETED
@@ -1,33 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # Depth-to-Image Generation
14
-
15
- ## StableDiffusionDepth2ImgPipeline
16
-
17
- The depth-guided stable diffusion model was created by the researchers and engineers from [CompVis](https://github.com/CompVis), [Stability AI](https://stability.ai/), and [LAION](https://laion.ai/), as part of Stable Diffusion 2.0. It uses [MiDas](https://github.com/isl-org/MiDaS) to infer depth based on an image.
18
-
19
- [`StableDiffusionDepth2ImgPipeline`] lets you pass a text prompt and an initial image to condition the generation of new images as well as a `depth_map` to preserve the images’ structure.
20
-
21
- The original codebase can be found here:
22
- - *Stable Diffusion v2*: [Stability-AI/stablediffusion](https://github.com/Stability-AI/stablediffusion#depth-conditional-stable-diffusion)
23
-
24
- Available Checkpoints are:
25
- - *stable-diffusion-2-depth*: [stabilityai/stable-diffusion-2-depth](https://huggingface.co/stabilityai/stable-diffusion-2-depth)
26
-
27
- [[autodoc]] StableDiffusionDepth2ImgPipeline
28
- - all
29
- - __call__
30
- - enable_attention_slicing
31
- - disable_attention_slicing
32
- - enable_xformers_memory_efficient_attention
33
- - disable_xformers_memory_efficient_attention
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/source/en/api/pipelines/stable_diffusion/image_variation.mdx DELETED
@@ -1,31 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # Image Variation
14
-
15
- ## StableDiffusionImageVariationPipeline
16
-
17
- [`StableDiffusionImageVariationPipeline`] lets you generate variations from an input image using Stable Diffusion. It uses a fine-tuned version of Stable Diffusion model, trained by [Justin Pinkney](https://www.justinpinkney.com/) (@Buntworthy) at [Lambda](https://lambdalabs.com/).
18
-
19
- The original codebase can be found here:
20
- [Stable Diffusion Image Variations](https://github.com/LambdaLabsML/lambda-diffusers#stable-diffusion-image-variations)
21
-
22
- Available Checkpoints are:
23
- - *sd-image-variations-diffusers*: [lambdalabs/sd-image-variations-diffusers](https://huggingface.co/lambdalabs/sd-image-variations-diffusers)
24
-
25
- [[autodoc]] StableDiffusionImageVariationPipeline
26
- - all
27
- - __call__
28
- - enable_attention_slicing
29
- - disable_attention_slicing
30
- - enable_xformers_memory_efficient_attention
31
- - disable_xformers_memory_efficient_attention
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/source/en/api/pipelines/stable_diffusion/img2img.mdx DELETED
@@ -1,36 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # Image-to-Image Generation
14
-
15
- ## StableDiffusionImg2ImgPipeline
16
-
17
- The Stable Diffusion model was created by the researchers and engineers from [CompVis](https://github.com/CompVis), [Stability AI](https://stability.ai/), [runway](https://github.com/runwayml), and [LAION](https://laion.ai/). The [`StableDiffusionImg2ImgPipeline`] lets you pass a text prompt and an initial image to condition the generation of new images using Stable Diffusion.
18
-
19
- The original codebase can be found here: [CampVis/stable-diffusion](https://github.com/CompVis/stable-diffusion/blob/main/scripts/img2img.py)
20
-
21
- [`StableDiffusionImg2ImgPipeline`] is compatible with all Stable Diffusion checkpoints for [Text-to-Image](./text2img)
22
-
23
- The pipeline uses the diffusion-denoising mechanism proposed by SDEdit ([SDEdit: Guided Image Synthesis and Editing with Stochastic Differential Equations](https://arxiv.org/abs/2108.01073)
24
- proposed by Chenlin Meng, Yutong He, Yang Song, Jiaming Song, Jiajun Wu, Jun-Yan Zhu, Stefano Ermon).
25
-
26
- [[autodoc]] StableDiffusionImg2ImgPipeline
27
- - all
28
- - __call__
29
- - enable_attention_slicing
30
- - disable_attention_slicing
31
- - enable_xformers_memory_efficient_attention
32
- - disable_xformers_memory_efficient_attention
33
-
34
- [[autodoc]] FlaxStableDiffusionImg2ImgPipeline
35
- - all
36
- - __call__
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/source/en/api/pipelines/stable_diffusion/inpaint.mdx DELETED
@@ -1,37 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # Text-Guided Image Inpainting
14
-
15
- ## StableDiffusionInpaintPipeline
16
-
17
- The Stable Diffusion model was created by the researchers and engineers from [CompVis](https://github.com/CompVis), [Stability AI](https://stability.ai/), [runway](https://github.com/runwayml), and [LAION](https://laion.ai/). The [`StableDiffusionInpaintPipeline`] lets you edit specific parts of an image by providing a mask and a text prompt using Stable Diffusion.
18
-
19
- The original codebase can be found here:
20
- - *Stable Diffusion V1*: [CampVis/stable-diffusion](https://github.com/runwayml/stable-diffusion#inpainting-with-stable-diffusion)
21
- - *Stable Diffusion V2*: [Stability-AI/stablediffusion](https://github.com/Stability-AI/stablediffusion#image-inpainting-with-stable-diffusion)
22
-
23
- Available checkpoints are:
24
- - *stable-diffusion-inpainting (512x512 resolution)*: [runwayml/stable-diffusion-inpainting](https://huggingface.co/runwayml/stable-diffusion-inpainting)
25
- - *stable-diffusion-2-inpainting (512x512 resolution)*: [stabilityai/stable-diffusion-2-inpainting](https://huggingface.co/stabilityai/stable-diffusion-2-inpainting)
26
-
27
- [[autodoc]] StableDiffusionInpaintPipeline
28
- - all
29
- - __call__
30
- - enable_attention_slicing
31
- - disable_attention_slicing
32
- - enable_xformers_memory_efficient_attention
33
- - disable_xformers_memory_efficient_attention
34
-
35
- [[autodoc]] FlaxStableDiffusionInpaintPipeline
36
- - all
37
- - __call__
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
diffus/docs/source/en/api/pipelines/stable_diffusion/latent_upscale.mdx DELETED
@@ -1,33 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # Stable Diffusion Latent Upscaler
14
-
15
- ## StableDiffusionLatentUpscalePipeline
16
-
17
- The Stable Diffusion Latent Upscaler model was created by [Katherine Crowson](https://github.com/crowsonkb/k-diffusion) in collaboration with [Stability AI](https://stability.ai/). It can be used on top of any [`StableDiffusionUpscalePipeline`] checkpoint to enhance its output image resolution by a factor of 2.
18
-
19
- A notebook that demonstrates the original implementation can be found here:
20
- - [Stable Diffusion Upscaler Demo](https://colab.research.google.com/drive/1o1qYJcFeywzCIdkfKJy7cTpgZTCM2EI4)
21
-
22
- Available Checkpoints are:
23
- - *stabilityai/latent-upscaler*: [stabilityai/sd-x2-latent-upscaler](https://huggingface.co/stabilityai/sd-x2-latent-upscaler)
24
-
25
-
26
- [[autodoc]] StableDiffusionLatentUpscalePipeline
27
- - all
28
- - __call__
29
- - enable_sequential_cpu_offload
30
- - enable_attention_slicing
31
- - disable_attention_slicing
32
- - enable_xformers_memory_efficient_attention
33
- - disable_xformers_memory_efficient_attention