Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated doc for stable diffusion pipelines #1770

Merged
merged 23 commits into from
Jan 2, 2023

Conversation

yiyixuxu
Copy link
Collaborator

  • one doc page for each stable diffusion pipeline
  • added docstring examples (text2img, inpaint, img2img, upscale, depth2img)

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Dec 19, 2022

The documentation is not available anymore as the PR was closed or merged.

@yiyixuxu
Copy link
Collaborator Author

Hi @anton-l :

How can I fix these 2 tests that failed?
I don't understand what the error I got from check_code_quality test means
for the check_repository_consistency - do I need to copy and modify the same docstring example from stable diffusion pipeline to alt diffusion? or is this something I can ignore?

@anton-l
Copy link
Member

anton-l commented Dec 19, 2022

@yiyixuxu most of the time the code quality and repo consistency tests can be fixed by running make style and make fix-copies from the repo's root. The dependencies for those scripts can be installed with pip install diffusers[quality]
The definitions are gathered here, if you ever need to run the steps manually: https://github.com/huggingface/diffusers/blob/main/Makefile#LL57C3-L57C3

There's also make quality that will check for things that need manual attention (the check_code_quality test does the same thing)

@@ -71,53 +76,3 @@ If you want to use all possible use cases in a single `DiffusionPipeline` you ca
## StableDiffusionPipelineOutput
[[autodoc]] pipelines.stable_diffusion.StableDiffusionPipelineOutput

## StableDiffusionPipeline
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@@ -24,7 +24,7 @@ For more details about how Stable Diffusion 2 works and how it differs from Stab

### Available checkpoints:

Note that the architecture is more or less identical to [Stable Diffusion 1](./api/pipelines/stable_diffusion) so please refer to [this page](./api/pipelines/stable_diffusion) for API documentation.
Note that the architecture is more or less identical to [Stable Diffusion 1](./api/pipelines/stable_diffusion/overview) so please refer to [this page](./api/pipelines/stable_diffusion/overview) for API documentation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we maybe add new sections for every example here?:

Text-to-Image

Text-to-Image (512x512 resolution): stabilityai/stable-diffusion-2-base with [StableDiffusionPipeline]
Text-to-Image (768x768 resolution): stabilityai/stable-diffusion-2 with [StableDiffusionPipeline]

```python
from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler
import torch
repo_id = "stabilityai/stable-diffusion-2-base"
pipe = DiffusionPipeline.from_pretrained(repo_id, torch_dtype=torch.float16, revision="fp16")
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
pipe = pipe.to("cuda")
prompt = "High quality photo of an astronaut riding a horse in space"
image = pipe(prompt, num_inference_steps=25).images[0]
image.save("astronaut.png")

Image Inpainting

etc...

This way we could better link to the different tasks.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the upscaler should we use "Super-Resolution" or "Image-Upscaling"? I want to make the names consistent at least on the navigation bar

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Super-Resolution" sounds good to me! Def in favor of making names consistent

Copy link
Contributor

@patrickvonplaten patrickvonplaten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks nice - like the new structure much better & super cool that you added a bunch of examples to the pipeline_.....py functions :-)

Could we add a bit more text to the individual stable diffusion pipeline functions?

@yiyixuxu
Copy link
Collaborator Author

@yiyixuxu most of the time the code quality and repo consistency tests can be fixed by running make style and make fix-copies from the repo's root. The dependencies for those scripts can be installed with pip install diffusers[quality] ✨ The definitions are gathered here, if you ever need to run the steps manually: https://github.com/huggingface/diffusers/blob/main/Makefile#LL57C3-L57C3

There's also make quality that will check for things that need manual attention (the check_code_quality test does the same thing)

@anton-l when I run these commands I notice it changes files that I did not touch on this PR - why did this happen and is it ok for me to commit these changes?

@patrickvonplaten
Copy link
Contributor

@yiyixuxu most of the time the code quality and repo consistency tests can be fixed by running make style and make fix-copies from the repo's root. The dependencies for those scripts can be installed with pip install diffusers[quality] sparkles The definitions are gathered here, if you ever need to run the steps manually: https://github.com/huggingface/diffusers/blob/main/Makefile#LL57C3-L57C3
There's also make quality that will check for things that need manual attention (the check_code_quality test does the same thing)

@anton-l when I run these commands I notice it changes files that I did not touch on this PR - why did this happen and is it ok for me to commit these changes?

It might be because of different versions of black, doc-builder and isort that you have installed.
For now, we pin black, doc-builder and isort to the versions as defined in setup.py:

black:

"black==22.8",

isort:
"isort>=5.5.4",

doc-builder:
"hf-doc-builder>=0.3.0",

So as you can see only black is actually pinned to 22.8, the others are not pinned.

Could you maybe do:

pip install black==22.8

=> then make style shouldn't change anything anymore.

@anton-l we should probably update black soon.

Also cc @patil-suraj @pcuenca @williamberman FYI

@yiyixuxu yiyixuxu force-pushed the update-stablediffusion-doc branch from 7c8ece5 to 4bd7af3 Compare December 31, 2022 19:54
add pipeline examples to docstrings

updated stable_diffusion_2 page

added descriptions for each stable diffusion pipeline
@yiyixuxu yiyixuxu force-pushed the update-stablediffusion-doc branch from 4bd7af3 to fafc352 Compare December 31, 2022 20:01
@yiyixuxu yiyixuxu requested a review from pcuenca December 31, 2022 20:38
@yiyixuxu
Copy link
Collaborator Author

@yiyixuxu most of the time the code quality and repo consistency tests can be fixed by running make style and make fix-copies from the repo's root. The dependencies for those scripts can be installed with pip install diffusers[quality] sparkles The definitions are gathered here, if you ever need to run the steps manually: https://github.com/huggingface/diffusers/blob/main/Makefile#LL57C3-L57C3
There's also make quality that will check for things that need manual attention (the check_code_quality test does the same thing)

@anton-l when I run these commands I notice it changes files that I did not touch on this PR - why did this happen and is it ok for me to commit these changes?

It might be because of different versions of black, doc-builder and isort that you have installed. For now, we pin black, doc-builder and isort to the versions as defined in setup.py:

black:

"black==22.8",

isort:

"isort>=5.5.4",

doc-builder:

"hf-doc-builder>=0.3.0",

So as you can see only black is actually pinned to 22.8, the others are not pinned.

Could you maybe do:

pip install black==22.8

=> then make style shouldn't change anything anymore.

@anton-l we should probably update black soon.

Also cc @patil-suraj @pcuenca @williamberman FYI

Thanks! it works now

I added some descriptions for each pipeline - do you want to take a look and let me know if there is anything we need to add before I merge?

Copy link
Contributor

@patrickvonplaten patrickvonplaten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some final suggestions to improve the docs, but overall this looks really nice to me :-)

Think once the suggestions are in we can merge this one!

Thanks a lot for working on it.

yiyixuxu and others added 18 commits January 1, 2023 17:32
Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
…sion_upscale.py

Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
…sion_depth2img.py

Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
…mg2img.py

Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
@yiyixuxu
Copy link
Collaborator Author

yiyixuxu commented Jan 2, 2023

@anton-l @patrickvonplaten

test failing because the AltDiffusion pipelines have this "Copied from ..." statement but we want the doc string examples to be different: different checkpoint, prompt in a Chinese

this is one of the commits that triggered the error be35fda

Should I remove the "Copied from ..." statement?

@patrickvonplaten
Copy link
Contributor

@yiyixuxu great catch! We'll do a trick here in this case to fix it - let me add one commit to your PR :-)

import re


def replace_example_docstring(example_docstring):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice!

@patrickvonplaten
Copy link
Contributor

I've added a docstring function decorator we can use to circumvent this #Copied from" problem as it's very likely to happen again :-)

In short, for examples we should probably always recommend to:

  • Define a global file variable called "EXAMPLE_DOCSTRING"
  • Define an empty "Examples:" in the docstring
  • Make use of the just added function decorator to replace it

This is a trick we also use in transformers to allow for both personalized example docstrings and be able to keep using the #Copied from mechanism

@yiyixuxu yiyixuxu merged commit da31075 into huggingface:main Jan 2, 2023
@yiyixuxu yiyixuxu deleted the update-stablediffusion-doc branch January 2, 2023 21:36
yoonseokjin pushed a commit to yoonseokjin/diffusers that referenced this pull request Dec 25, 2023
* add a doc page for each pipeline under api/pipelines/stable_diffusion
* add pipeline examples to docstrings
* updated stable_diffusion_2 page
* updated default markdown syntax to list methods based on huggingface#1870
* add function decorator

Co-authored-by: yiyixuxu <yixu@Yis-MacBook-Pro.lan>
Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants