diffusers icon indicating copy to clipboard operation
diffusers copied to clipboard

updated doc for stable diffusion pipelines

Open yiyixuxu opened this issue 3 years ago • 3 comments

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

yiyixuxu avatar Dec 19 '22 17:12 yiyixuxu

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

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?

yiyixuxu avatar Dec 19 '22 18:12 yiyixuxu

@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 avatar Dec 19 '22 19:12 anton-l

@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?

yiyixuxu avatar Dec 25 '22 04:12 yiyixuxu

@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: https://github.com/huggingface/diffusers/blob/e4fe9413121b78c4c1f109b50f0f3cc1c320a1a2/setup.py#L83 isort: https://github.com/huggingface/diffusers/blob/e4fe9413121b78c4c1f109b50f0f3cc1c320a1a2/setup.py#L91 doc-builder: https://github.com/huggingface/diffusers/blob/e4fe9413121b78c4c1f109b50f0f3cc1c320a1a2/setup.py#L88

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

patrickvonplaten avatar Dec 30 '22 13:12 patrickvonplaten

@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:

https://github.com/huggingface/diffusers/blob/e4fe9413121b78c4c1f109b50f0f3cc1c320a1a2/setup.py#L83

isort: https://github.com/huggingface/diffusers/blob/e4fe9413121b78c4c1f109b50f0f3cc1c320a1a2/setup.py#L91

doc-builder: https://github.com/huggingface/diffusers/blob/e4fe9413121b78c4c1f109b50f0f3cc1c320a1a2/setup.py#L88

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?

yiyixuxu avatar Dec 31 '22 20:12 yiyixuxu

@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 https://github.com/huggingface/diffusers/pull/1770/commits/be35fdac9ad1f3216e79a0c1e36c3b94b33f144b

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

yiyixuxu avatar Jan 02 '23 06:01 yiyixuxu

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

patrickvonplaten avatar Jan 02 '23 15:01 patrickvonplaten

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

patrickvonplaten avatar Jan 02 '23 15:01 patrickvonplaten