From 76d492ea49342b486dfbca1dbcdfbb052fe34112 Mon Sep 17 00:00:00 2001 From: Yuta Hayashibe Date: Fri, 16 Sep 2022 22:36:51 +0900 Subject: [PATCH] Fix typos and add Typo check GitHub Action (#483) * Fix typos * Add a typo check action * Fix a bug * Changed to manual typo check currently Ref: https://github.com/huggingface/diffusers/pull/483#pullrequestreview-1104468010 Co-authored-by: Anton Lozhkov * Removed a confusing message * Renamed "nin_shortcut" to "in_shortcut" * Add memo about NIN Co-authored-by: Anton Lozhkov --- .github/workflows/typos.yml | 14 ++++++++++++++ README.md | 8 ++++---- _typos.toml | 12 ++++++++++++ docs/source/api/schedulers.mdx | 6 +++--- docs/source/quicktour.mdx | 8 ++++---- docs/source/training/text_inversion.mdx | 4 ++-- docs/source/training/unconditional_training.mdx | 4 ++-- examples/textual_inversion/README.md | 4 ++-- examples/textual_inversion/textual_inversion.py | 2 +- examples/unconditional_image_generation/README.md | 4 ++-- ...onvert_ddpm_original_checkpoint_to_diffusers.py | 2 +- scripts/generate_logits.py | 2 +- src/diffusers/configuration_utils.py | 6 +++--- src/diffusers/modeling_utils.py | 2 +- src/diffusers/models/resnet.py | 6 +++--- src/diffusers/models/unet_blocks.py | 8 ++++---- src/diffusers/pipeline_utils.py | 10 +++++----- src/diffusers/pipelines/README.md | 2 +- src/diffusers/pipelines/ddim/pipeline_ddim.py | 2 +- src/diffusers/pipelines/ddpm/pipeline_ddpm.py | 2 +- .../latent_diffusion/pipeline_latent_diffusion.py | 2 +- .../pipeline_latent_diffusion_uncond.py | 2 +- src/diffusers/pipelines/pndm/pipeline_pndm.py | 2 +- .../score_sde_ve/pipeline_score_sde_ve.py | 2 +- src/diffusers/pipelines/stable_diffusion/README.md | 2 +- .../stable_diffusion/pipeline_stable_diffusion.py | 4 ++-- .../pipeline_stable_diffusion_img2img.py | 4 ++-- .../pipeline_stable_diffusion_inpaint.py | 2 +- .../pipeline_stable_diffusion_onnx.py | 2 +- .../pipeline_stochastic_karras_ve.py | 2 +- src/diffusers/schedulers/README.md | 2 +- src/diffusers/schedulers/scheduling_karras_ve.py | 2 +- src/diffusers/schedulers/scheduling_sde_vp.py | 2 +- tests/test_modeling_common.py | 2 +- utils/check_inits.py | 2 +- utils/check_table.py | 8 ++++---- utils/check_tf_ops.py | 4 ++-- utils/custom_init_isort.py | 4 ++-- 38 files changed, 92 insertions(+), 66 deletions(-) create mode 100644 .github/workflows/typos.yml create mode 100644 _typos.toml diff --git a/.github/workflows/typos.yml b/.github/workflows/typos.yml new file mode 100644 index 0000000000..fbd051b4da --- /dev/null +++ b/.github/workflows/typos.yml @@ -0,0 +1,14 @@ +name: Check typos + +on: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: typos-action + uses: crate-ci/typos@v1.12.4 diff --git a/README.md b/README.md index 7be7f9f842..5a25ce5012 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ as a modular toolbox for inference and training of diffusion models. More precisely, ๐Ÿค— Diffusers offers: - State-of-the-art diffusion pipelines that can be run in inference with just a couple of lines of code (see [src/diffusers/pipelines](https://github.com/huggingface/diffusers/tree/main/src/diffusers/pipelines)). Check [this overview](https://github.com/huggingface/diffusers/tree/main/src/diffusers/pipelines/README.md#pipelines-summary) to see all supported pipelines and their corresponding official papers. -- Various noise schedulers that can be used interchangeably for the prefered speed vs. quality trade-off in inference (see [src/diffusers/schedulers](https://github.com/huggingface/diffusers/tree/main/src/diffusers/schedulers)). +- Various noise schedulers that can be used interchangeably for the preferred speed vs. quality trade-off in inference (see [src/diffusers/schedulers](https://github.com/huggingface/diffusers/tree/main/src/diffusers/schedulers)). - Multiple types of models, such as UNet, can be used as building blocks in an end-to-end diffusion system (see [src/diffusers/models](https://github.com/huggingface/diffusers/tree/main/src/diffusers/models)). - Training examples to show how to train the most popular diffusion model tasks (see [examples](https://github.com/huggingface/diffusers/tree/main/examples), *e.g.* [unconditional-image-generation](https://github.com/huggingface/diffusers/tree/main/examples/unconditional_image_generation)). @@ -297,7 +297,7 @@ with autocast("cuda"): image.save("ddpm_generated_image.png") ``` - [Unconditional Latent Diffusion](https://huggingface.co/CompVis/ldm-celebahq-256) -- [Unconditional Diffusion with continous scheduler](https://huggingface.co/google/ncsnpp-ffhq-1024) +- [Unconditional Diffusion with continuous scheduler](https://huggingface.co/google/ncsnpp-ffhq-1024) **Other Notebooks**: * [image-to-image generation with Stable Diffusion](https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers/image_2_image_using_diffusers.ipynb) ![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg), @@ -346,8 +346,8 @@ The class provides functionality to compute previous image according to alpha, b ## Philosophy -- Readability and clarity is prefered over highly optimized code. A strong importance is put on providing readable, intuitive and elementary code design. *E.g.*, the provided [schedulers](https://github.com/huggingface/diffusers/tree/main/src/diffusers/schedulers) are separated from the provided [models](https://github.com/huggingface/diffusers/tree/main/src/diffusers/models) and provide well-commented code that can be read alongside the original paper. -- Diffusers is **modality independent** and focuses on providing pretrained models and tools to build systems that generate **continous outputs**, *e.g.* vision and audio. +- Readability and clarity is preferred over highly optimized code. A strong importance is put on providing readable, intuitive and elementary code design. *E.g.*, the provided [schedulers](https://github.com/huggingface/diffusers/tree/main/src/diffusers/schedulers) are separated from the provided [models](https://github.com/huggingface/diffusers/tree/main/src/diffusers/models) and provide well-commented code that can be read alongside the original paper. +- Diffusers is **modality independent** and focuses on providing pretrained models and tools to build systems that generate **continuous outputs**, *e.g.* vision and audio. - Diffusion models and schedulers are provided as concise, elementary building blocks. In contrast, diffusion pipelines are a collection of end-to-end diffusion systems that can be used out-of-the-box, should stay as close as possible to their original implementation and can include components of another library, such as text-encoders. Examples for diffusion pipelines are [Glide](https://github.com/openai/glide-text2im) and [Latent Diffusion](https://github.com/CompVis/latent-diffusion). ## In the works diff --git a/_typos.toml b/_typos.toml new file mode 100644 index 0000000000..4025388915 --- /dev/null +++ b/_typos.toml @@ -0,0 +1,12 @@ +# Files for typos +# Instruction: https://github.com/marketplace/actions/typos-action#getting-started + +[default.extend-identifiers] + +[default.extend-words] +NIN_="NIN" # NIN is used in scripts/convert_ncsnpp_original_checkpoint_to_diffusers.py +nd="np" # nd may be np (numpy) + + +[files] +extend-exclude = ["_typos.toml"] diff --git a/docs/source/api/schedulers.mdx b/docs/source/api/schedulers.mdx index 1b17c2ba19..2b6e58fe12 100644 --- a/docs/source/api/schedulers.mdx +++ b/docs/source/api/schedulers.mdx @@ -44,7 +44,7 @@ To this end, the design of schedulers is such that: The core API for any new scheduler must follow a limited structure. - Schedulers should provide one or more `def step(...)` functions that should be called to update the generated sample iteratively. - Schedulers should provide a `set_timesteps(...)` method that configures the parameters of a schedule function for a specific inference task. -- Schedulers should be framework-agonstic, but provide a simple functionality to convert the scheduler into a specific framework, such as PyTorch +- Schedulers should be framework-agnostic, but provide a simple functionality to convert the scheduler into a specific framework, such as PyTorch with a `set_format(...)` method. The base class [`SchedulerMixin`] implements low level utilities used by multiple schedulers. @@ -53,7 +53,7 @@ The base class [`SchedulerMixin`] implements low level utilities used by multipl [[autodoc]] SchedulerMixin ### SchedulerOutput -The class [`SchedulerOutput`] contains the ouputs from any schedulers `step(...)` call. +The class [`SchedulerOutput`] contains the outputs from any schedulers `step(...)` call. [[autodoc]] schedulers.scheduling_utils.SchedulerOutput @@ -71,7 +71,7 @@ Original paper can be found [here](https://arxiv.org/abs/2010.02502). [[autodoc]] DDPMScheduler -#### Varience exploding, stochastic sampling from Karras et. al +#### Variance exploding, stochastic sampling from Karras et. al Original paper can be found [here](https://arxiv.org/abs/2006.11239). diff --git a/docs/source/quicktour.mdx b/docs/source/quicktour.mdx index 286d9392aa..9574ecac4a 100644 --- a/docs/source/quicktour.mdx +++ b/docs/source/quicktour.mdx @@ -86,11 +86,11 @@ just like we did before only that now you need to pass your `AUTH_TOKEN`: >>> generator = DiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", use_auth_token=AUTH_TOKEN) ``` -If you do not pass your authentification token you will see that the diffusion system will not be correctly -downloaded. Forcing the user to pass an authentification token ensures that it can be verified that the +If you do not pass your authentication token you will see that the diffusion system will not be correctly +downloaded. Forcing the user to pass an authentication token ensures that it can be verified that the user has indeed read and accepted the license, which also means that an internet connection is required. -**Note**: If you do not want to be forced to pass an authentification token, you can also simply download +**Note**: If you do not want to be forced to pass an authentication token, you can also simply download the weights locally via: ``` @@ -98,7 +98,7 @@ git lfs install git clone https://huggingface.co/CompVis/stable-diffusion-v1-4 ``` -and then load locally saved weights into the pipeline. This way, you do not need to pass an authentification +and then load locally saved weights into the pipeline. This way, you do not need to pass an authentication token. Assuming that `"./stable-diffusion-v1-4"` is the local path to the cloned stable-diffusion-v1-4 repo, you can also load the pipeline as follows: diff --git a/docs/source/training/text_inversion.mdx b/docs/source/training/text_inversion.mdx index 107cd706f4..8c53421e21 100644 --- a/docs/source/training/text_inversion.mdx +++ b/docs/source/training/text_inversion.mdx @@ -49,7 +49,7 @@ The `textual_inversion.py` script [here](https://github.com/huggingface/diffuser ### Installing the dependencies -Before running the scipts, make sure to install the library's training dependencies: +Before running the scripts, make sure to install the library's training dependencies: ```bash pip install diffusers[training] accelerate transformers @@ -68,7 +68,7 @@ You need to accept the model license before downloading or using the weights. In You have to be a registered user in ๐Ÿค— Hugging Face Hub, and you'll also need to use an access token for the code to work. For more information on access tokens, please refer to [this section of the documentation](https://huggingface.co/docs/hub/security-tokens). -Run the following command to autheticate your token +Run the following command to authenticate your token ```bash huggingface-cli login diff --git a/docs/source/training/unconditional_training.mdx b/docs/source/training/unconditional_training.mdx index ff8df186e8..e711e05973 100644 --- a/docs/source/training/unconditional_training.mdx +++ b/docs/source/training/unconditional_training.mdx @@ -18,7 +18,7 @@ distribution. ## Installing the dependencies -Before running the scipts, make sure to install the library's training dependencies: +Before running the scripts, make sure to install the library's training dependencies: ```bash pip install diffusers[training] accelerate datasets @@ -117,7 +117,7 @@ from datasets import load_dataset # example 1: local folder dataset = load_dataset("imagefolder", data_dir="path_to_your_folder") -# example 2: local files (suppoted formats are tar, gzip, zip, xz, rar, zstd) +# example 2: local files (supported formats are tar, gzip, zip, xz, rar, zstd) dataset = load_dataset("imagefolder", data_files="path_to_zip_file") # example 3: remote files (supported formats are tar, gzip, zip, xz, rar, zstd) diff --git a/examples/textual_inversion/README.md b/examples/textual_inversion/README.md index ad3b405d0f..65b9d4958b 100644 --- a/examples/textual_inversion/README.md +++ b/examples/textual_inversion/README.md @@ -14,7 +14,7 @@ Colab for inference ## Running locally ### Installing the dependencies -Before running the scipts, make sure to install the library's training dependencies: +Before running the scripts, make sure to install the library's training dependencies: ```bash pip install diffusers[training] accelerate transformers @@ -33,7 +33,7 @@ You need to accept the model license before downloading or using the weights. In You have to be a registered user in ๐Ÿค— Hugging Face Hub, and you'll also need to use an access token for the code to work. For more information on access tokens, please refer to [this section of the documentation](https://huggingface.co/docs/hub/security-tokens). -Run the following command to autheticate your token +Run the following command to authenticate your token ```bash huggingface-cli login diff --git a/examples/textual_inversion/textual_inversion.py b/examples/textual_inversion/textual_inversion.py index 07767189e9..de5761646a 100644 --- a/examples/textual_inversion/textual_inversion.py +++ b/examples/textual_inversion/textual_inversion.py @@ -422,7 +422,7 @@ def main(): eps=args.adam_epsilon, ) - # TODO (patil-suraj): laod scheduler using args + # TODO (patil-suraj): load scheduler using args noise_scheduler = DDPMScheduler( beta_start=0.00085, beta_end=0.012, beta_schedule="scaled_linear", num_train_timesteps=1000, tensor_format="pt" ) diff --git a/examples/unconditional_image_generation/README.md b/examples/unconditional_image_generation/README.md index ad61058138..a2a5a840af 100644 --- a/examples/unconditional_image_generation/README.md +++ b/examples/unconditional_image_generation/README.md @@ -4,7 +4,7 @@ Creating a training image set is [described in a different document](https://hug ### Installing the dependencies -Before running the scipts, make sure to install the library's training dependencies: +Before running the scripts, make sure to install the library's training dependencies: ```bash pip install diffusers[training] accelerate datasets @@ -102,7 +102,7 @@ from datasets import load_dataset # example 1: local folder dataset = load_dataset("imagefolder", data_dir="path_to_your_folder") -# example 2: local files (suppoted formats are tar, gzip, zip, xz, rar, zstd) +# example 2: local files (supported formats are tar, gzip, zip, xz, rar, zstd) dataset = load_dataset("imagefolder", data_files="path_to_zip_file") # example 3: remote files (supported formats are tar, gzip, zip, xz, rar, zstd) diff --git a/scripts/convert_ddpm_original_checkpoint_to_diffusers.py b/scripts/convert_ddpm_original_checkpoint_to_diffusers.py index 52d75c75ef..4222327c23 100644 --- a/scripts/convert_ddpm_original_checkpoint_to_diffusers.py +++ b/scripts/convert_ddpm_original_checkpoint_to_diffusers.py @@ -22,7 +22,7 @@ def renew_resnet_paths(old_list, n_shave_prefix_segments=0): new_item = old_item new_item = new_item.replace("block.", "resnets.") new_item = new_item.replace("conv_shorcut", "conv1") - new_item = new_item.replace("nin_shortcut", "conv_shortcut") + new_item = new_item.replace("in_shortcut", "conv_shortcut") new_item = new_item.replace("temb_proj", "time_emb_proj") new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) diff --git a/scripts/generate_logits.py b/scripts/generate_logits.py index 47dc5485af..531e2e4d71 100644 --- a/scripts/generate_logits.py +++ b/scripts/generate_logits.py @@ -124,4 +124,4 @@ for mod in models: assert torch.allclose( logits[0, 0, 0, :30], results["_".join("_".join(mod.modelId.split("/")).split("-"))], atol=1e-3 ) - print(f"{mod.modelId} has passed succesfully!!!") + print(f"{mod.modelId} has passed successfully!!!") diff --git a/src/diffusers/configuration_utils.py b/src/diffusers/configuration_utils.py index cf85eccb44..3a01fe350a 100644 --- a/src/diffusers/configuration_utils.py +++ b/src/diffusers/configuration_utils.py @@ -45,9 +45,9 @@ class ConfigMixin: Class attributes: - **config_name** (`str`) -- A filename under which the config should stored when calling - [`~ConfigMixin.save_config`] (should be overriden by parent class). + [`~ConfigMixin.save_config`] (should be overridden by parent class). - **ignore_for_config** (`List[str]`) -- A list of attributes that should not be saved in the config (should be - overriden by parent class). + overridden by parent class). """ config_name = None ignore_for_config = [] @@ -125,7 +125,7 @@ class ConfigMixin: A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128', 'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request. output_loading_info(`bool`, *optional*, defaults to `False`): - Whether ot not to also return a dictionary containing missing keys, unexpected keys and error messages. + Whether or not to also return a dictionary containing missing keys, unexpected keys and error messages. local_files_only(`bool`, *optional*, defaults to `False`): Whether or not to only look at local files (i.e., do not try to download the model). use_auth_token (`str` or *bool*, *optional*): diff --git a/src/diffusers/modeling_utils.py b/src/diffusers/modeling_utils.py index 2a23a37e53..ef1ead9ecf 100644 --- a/src/diffusers/modeling_utils.py +++ b/src/diffusers/modeling_utils.py @@ -218,7 +218,7 @@ class ModelMixin(torch.nn.Module): A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128', 'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request. output_loading_info(`bool`, *optional*, defaults to `False`): - Whether ot not to also return a dictionary containing missing keys, unexpected keys and error messages. + Whether or not to also return a dictionary containing missing keys, unexpected keys and error messages. local_files_only(`bool`, *optional*, defaults to `False`): Whether or not to only look at local files (i.e., do not try to download the model). use_auth_token (`str` or *bool*, *optional*): diff --git a/src/diffusers/models/resnet.py b/src/diffusers/models/resnet.py index de0d255f4e..55ae42c2e3 100644 --- a/src/diffusers/models/resnet.py +++ b/src/diffusers/models/resnet.py @@ -264,7 +264,7 @@ class ResnetBlock2D(nn.Module): time_embedding_norm="default", kernel=None, output_scale_factor=1.0, - use_nin_shortcut=None, + use_in_shortcut=None, up=False, down=False, ): @@ -321,10 +321,10 @@ class ResnetBlock2D(nn.Module): else: self.downsample = Downsample2D(in_channels, use_conv=False, padding=1, name="op") - self.use_nin_shortcut = self.in_channels != self.out_channels if use_nin_shortcut is None else use_nin_shortcut + self.use_in_shortcut = self.in_channels != self.out_channels if use_in_shortcut is None else use_in_shortcut self.conv_shortcut = None - if self.use_nin_shortcut: + if self.use_in_shortcut: self.conv_shortcut = torch.nn.Conv2d(in_channels, out_channels, kernel_size=1, stride=1, padding=0) def forward(self, x, temb): diff --git a/src/diffusers/models/unet_blocks.py b/src/diffusers/models/unet_blocks.py index d76c79762c..1fee670c91 100644 --- a/src/diffusers/models/unet_blocks.py +++ b/src/diffusers/models/unet_blocks.py @@ -820,7 +820,7 @@ class AttnSkipDownBlock2D(nn.Module): non_linearity=resnet_act_fn, output_scale_factor=output_scale_factor, pre_norm=resnet_pre_norm, - use_nin_shortcut=True, + use_in_shortcut=True, down=True, kernel="fir", ) @@ -900,7 +900,7 @@ class SkipDownBlock2D(nn.Module): non_linearity=resnet_act_fn, output_scale_factor=output_scale_factor, pre_norm=resnet_pre_norm, - use_nin_shortcut=True, + use_in_shortcut=True, down=True, kernel="fir", ) @@ -1355,7 +1355,7 @@ class AttnSkipUpBlock2D(nn.Module): non_linearity=resnet_act_fn, output_scale_factor=output_scale_factor, pre_norm=resnet_pre_norm, - use_nin_shortcut=True, + use_in_shortcut=True, up=True, kernel="fir", ) @@ -1452,7 +1452,7 @@ class SkipUpBlock2D(nn.Module): non_linearity=resnet_act_fn, output_scale_factor=output_scale_factor, pre_norm=resnet_pre_norm, - use_nin_shortcut=True, + use_in_shortcut=True, up=True, kernel="fir", ) diff --git a/src/diffusers/pipeline_utils.py b/src/diffusers/pipeline_utils.py index 84ee9e20f1..b51b8b7e59 100644 --- a/src/diffusers/pipeline_utils.py +++ b/src/diffusers/pipeline_utils.py @@ -86,7 +86,7 @@ class DiffusionPipeline(ConfigMixin): Class attributes: - **config_name** ([`str`]) -- name of the config file that will store the class and module names of all - compenents of the diffusion pipeline. + components of the diffusion pipeline. """ config_name = "model_index.json" @@ -95,7 +95,7 @@ class DiffusionPipeline(ConfigMixin): from diffusers import pipelines for name, module in kwargs.items(): - # retrive library + # retrieve library library = module.__module__.split(".")[0] # check if the module is a pipeline module @@ -109,7 +109,7 @@ class DiffusionPipeline(ConfigMixin): if library not in LOADABLE_CLASSES or is_pipeline_module: library = pipeline_dir - # retrive class_name + # retrieve class_name class_name = module.__class__.__name__ register_dict = {name: (library, class_name)} @@ -217,7 +217,7 @@ class DiffusionPipeline(ConfigMixin): A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128', 'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request. output_loading_info(`bool`, *optional*, defaults to `False`): - Whether ot not to also return a dictionary containing missing keys, unexpected keys and error messages. + Whether or not to also return a dictionary containing missing keys, unexpected keys and error messages. local_files_only(`bool`, *optional*, defaults to `False`): Whether or not to only look at local files (i.e., do not try to download the model). use_auth_token (`str` or *bool*, *optional*): @@ -234,7 +234,7 @@ class DiffusionPipeline(ConfigMixin): kwargs (remaining dictionary of keyword arguments, *optional*): Can be used to overwrite load - and saveable variables - *i.e.* the pipeline components - of the - speficic pipeline class. The overritten components are then directly passed to the pipelines `__init__` + specific pipeline class. The overritten components are then directly passed to the pipelines `__init__` method. See example below for more information. diff --git a/src/diffusers/pipelines/README.md b/src/diffusers/pipelines/README.md index 328c37dc76..7957a8c364 100644 --- a/src/diffusers/pipelines/README.md +++ b/src/diffusers/pipelines/README.md @@ -70,7 +70,7 @@ not be used for training. If you want to store the gradients during the forward ## Contribution -We are more than happy about any contribution to the offically supported pipelines ๐Ÿค—. We aspire +We are more than happy about any contribution to the officially supported pipelines ๐Ÿค—. We aspire all of our pipelines to be **self-contained**, **easy-to-tweak**, **beginner-friendly** and for **one-purpose-only**. - **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 iteslf, should be inherited from (and only from) the [`DiffusionPipeline` class](https://github.com/huggingface/diffusers/blob/5cbed8e0d157f65d3ddc2420dfd09f2df630e978/src/diffusers/pipeline_utils.py#L56) or be directly attached to the model and scheduler components of the pipeline. diff --git a/src/diffusers/pipelines/ddim/pipeline_ddim.py b/src/diffusers/pipelines/ddim/pipeline_ddim.py index 33f6064dbb..95b49e045f 100644 --- a/src/diffusers/pipelines/ddim/pipeline_ddim.py +++ b/src/diffusers/pipelines/ddim/pipeline_ddim.py @@ -64,7 +64,7 @@ class DDIMPipeline(DiffusionPipeline): expense of slower inference. output_type (`str`, *optional*, defaults to `"pil"`): The output format of the generate image. Choose between - [PIL](https://pillow.readthedocs.io/en/stable/): `PIL.Image.Image` or `nd.array`. + [PIL](https://pillow.readthedocs.io/en/stable/): `PIL.Image.Image` or `np.array`. return_dict (`bool`, *optional*, defaults to `True`): Whether or not to return a [`~pipeline_utils.ImagePipelineOutput`] instead of a plain tuple. diff --git a/src/diffusers/pipelines/ddpm/pipeline_ddpm.py b/src/diffusers/pipelines/ddpm/pipeline_ddpm.py index 71103bbe4d..b7f7093e37 100644 --- a/src/diffusers/pipelines/ddpm/pipeline_ddpm.py +++ b/src/diffusers/pipelines/ddpm/pipeline_ddpm.py @@ -57,7 +57,7 @@ class DDPMPipeline(DiffusionPipeline): deterministic. output_type (`str`, *optional*, defaults to `"pil"`): The output format of the generate image. Choose between - [PIL](https://pillow.readthedocs.io/en/stable/): `PIL.Image.Image` or `nd.array`. + [PIL](https://pillow.readthedocs.io/en/stable/): `PIL.Image.Image` or `np.array`. return_dict (`bool`, *optional*, defaults to `True`): Whether or not to return a [`~pipeline_utils.ImagePipelineOutput`] instead of a plain tuple. diff --git a/src/diffusers/pipelines/latent_diffusion/pipeline_latent_diffusion.py b/src/diffusers/pipelines/latent_diffusion/pipeline_latent_diffusion.py index 9d3be8b1ff..8caa11dbdf 100644 --- a/src/diffusers/pipelines/latent_diffusion/pipeline_latent_diffusion.py +++ b/src/diffusers/pipelines/latent_diffusion/pipeline_latent_diffusion.py @@ -85,7 +85,7 @@ class LDMTextToImagePipeline(DiffusionPipeline): deterministic. output_type (`str`, *optional*, defaults to `"pil"`): The output format of the generate image. Choose between - [PIL](https://pillow.readthedocs.io/en/stable/): `PIL.Image.Image` or `nd.array`. + [PIL](https://pillow.readthedocs.io/en/stable/): `PIL.Image.Image` or `np.array`. return_dict (`bool`, *optional*): Whether or not to return a [`~pipeline_utils.ImagePipelineOutput`] instead of a plain tuple. diff --git a/src/diffusers/pipelines/latent_diffusion_uncond/pipeline_latent_diffusion_uncond.py b/src/diffusers/pipelines/latent_diffusion_uncond/pipeline_latent_diffusion_uncond.py index 3b80b872ff..5574b65df9 100644 --- a/src/diffusers/pipelines/latent_diffusion_uncond/pipeline_latent_diffusion_uncond.py +++ b/src/diffusers/pipelines/latent_diffusion_uncond/pipeline_latent_diffusion_uncond.py @@ -50,7 +50,7 @@ class LDMPipeline(DiffusionPipeline): expense of slower inference. output_type (`str`, *optional*, defaults to `"pil"`): The output format of the generate image. Choose between - [PIL](https://pillow.readthedocs.io/en/stable/): `PIL.Image.Image` or `nd.array`. + [PIL](https://pillow.readthedocs.io/en/stable/): `PIL.Image.Image` or `np.array`. return_dict (`bool`, *optional*, defaults to `True`): Whether or not to return a [`~pipeline_utils.ImagePipelineOutput`] instead of a plain tuple. diff --git a/src/diffusers/pipelines/pndm/pipeline_pndm.py b/src/diffusers/pipelines/pndm/pipeline_pndm.py index f3dff1a9a9..ae6c10e9e9 100644 --- a/src/diffusers/pipelines/pndm/pipeline_pndm.py +++ b/src/diffusers/pipelines/pndm/pipeline_pndm.py @@ -63,7 +63,7 @@ class PNDMPipeline(DiffusionPipeline): generator](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make generation deterministic. output_type (`str`, `optional`, defaults to `"pil"`): The output format of the generate image. Choose - between [PIL](https://pillow.readthedocs.io/en/stable/): `PIL.Image.Image` or `nd.array`. + between [PIL](https://pillow.readthedocs.io/en/stable/): `PIL.Image.Image` or `np.array`. return_dict (`bool`, `optional`, defaults to `True`): Whether or not to return a [`~pipeline_utils.ImagePipelineOutput`] instead of a plain tuple. diff --git a/src/diffusers/pipelines/score_sde_ve/pipeline_score_sde_ve.py b/src/diffusers/pipelines/score_sde_ve/pipeline_score_sde_ve.py index 6ff8e03057..b29795e7f6 100644 --- a/src/diffusers/pipelines/score_sde_ve/pipeline_score_sde_ve.py +++ b/src/diffusers/pipelines/score_sde_ve/pipeline_score_sde_ve.py @@ -43,7 +43,7 @@ class ScoreSdeVePipeline(DiffusionPipeline): deterministic. output_type (`str`, *optional*, defaults to `"pil"`): The output format of the generate image. Choose between - [PIL](https://pillow.readthedocs.io/en/stable/): `PIL.Image.Image` or `nd.array`. + [PIL](https://pillow.readthedocs.io/en/stable/): `PIL.Image.Image` or `np.array`. return_dict (`bool`, *optional*, defaults to `True`): Whether or not to return a [`~pipeline_utils.ImagePipelineOutput`] instead of a plain tuple. diff --git a/src/diffusers/pipelines/stable_diffusion/README.md b/src/diffusers/pipelines/stable_diffusion/README.md index 63ad90fad2..0e6cab2e11 100644 --- a/src/diffusers/pipelines/stable_diffusion/README.md +++ b/src/diffusers/pipelines/stable_diffusion/README.md @@ -12,7 +12,7 @@ The summary of the model is the following: - Stable Diffusion has the same architecture as [Latent Diffusion](https://arxiv.org/abs/2112.10752) but uses a frozen CLIP Text Encoder instead of training the text encoder jointly with the diffusion model. - An in-detail explanation of the Stable Diffusion model can be found under [Stable Diffusion with ๐Ÿงจ Diffusers](https://huggingface.co/blog/stable_diffusion). -- If you don't want to rely on the Hugging Face Hub and having to pass a authentification token, you can +- If you don't want to rely on the Hugging Face Hub and having to pass a authentication token, you can download the weights with `git lfs install; git clone https://huggingface.co/CompVis/stable-diffusion-v1-4` and instead pass the local path to the cloned folder to `from_pretrained` as shown below. - Stable Diffusion can work with a variety of different samplers as is shown below. diff --git a/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py b/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py index f02fa114a8..ce17f2e0ee 100644 --- a/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py +++ b/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py @@ -136,7 +136,7 @@ class StableDiffusionPipeline(DiffusionPipeline): tensor will ge generated by sampling using the supplied random `generator`. output_type (`str`, *optional*, defaults to `"pil"`): The output format of the generate image. Choose between - [PIL](https://pillow.readthedocs.io/en/stable/): `PIL.Image.Image` or `nd.array`. + [PIL](https://pillow.readthedocs.io/en/stable/): `PIL.Image.Image` or `np.array`. return_dict (`bool`, *optional*, defaults to `True`): Whether or not to return a [`~pipelines.stable_diffusion.StableDiffusionPipelineOutput`] instead of a plain tuple. @@ -224,7 +224,7 @@ class StableDiffusionPipeline(DiffusionPipeline): self.scheduler.set_timesteps(num_inference_steps, **extra_set_kwargs) - # if we use LMSDiscreteScheduler, let's make sure latents are mulitplied by sigmas + # if we use LMSDiscreteScheduler, let's make sure latents are multiplied by sigmas if isinstance(self.scheduler, LMSDiscreteScheduler): latents = latents * self.scheduler.sigmas[0] diff --git a/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py b/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py index 69e2fc36fa..817288f499 100644 --- a/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py +++ b/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py @@ -146,7 +146,7 @@ class StableDiffusionImg2ImgPipeline(DiffusionPipeline): deterministic. output_type (`str`, *optional*, defaults to `"pil"`): The output format of the generate image. Choose between - [PIL](https://pillow.readthedocs.io/en/stable/): `PIL.Image.Image` or `nd.array`. + [PIL](https://pillow.readthedocs.io/en/stable/): `PIL.Image.Image` or `np.array`. return_dict (`bool`, *optional*, defaults to `True`): Whether or not to return a [`~pipelines.stable_diffusion.StableDiffusionPipelineOutput`] instead of a plain tuple. @@ -249,7 +249,7 @@ class StableDiffusionImg2ImgPipeline(DiffusionPipeline): # expand the latents if we are doing classifier free guidance latent_model_input = torch.cat([latents] * 2) if do_classifier_free_guidance else latents - # if we use LMSDiscreteScheduler, let's make sure latents are mulitplied by sigmas + # if we use LMSDiscreteScheduler, let's make sure latents are multiplied by sigmas if isinstance(self.scheduler, LMSDiscreteScheduler): sigma = self.scheduler.sigmas[t_index] # the model input needs to be scaled to match the continuous ODE formulation in K-LMS diff --git a/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py b/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py index b529598c70..e97e52071d 100644 --- a/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py +++ b/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py @@ -169,7 +169,7 @@ class StableDiffusionInpaintPipeline(DiffusionPipeline): deterministic. output_type (`str`, *optional*, defaults to `"pil"`): The output format of the generate image. Choose between - [PIL](https://pillow.readthedocs.io/en/stable/): `PIL.Image.Image` or `nd.array`. + [PIL](https://pillow.readthedocs.io/en/stable/): `PIL.Image.Image` or `np.array`. return_dict (`bool`, *optional*, defaults to `True`): Whether or not to return a [`~pipelines.stable_diffusion.StableDiffusionPipelineOutput`] instead of a plain tuple. diff --git a/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_onnx.py b/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_onnx.py index 7ff3ff22fc..b114145d6f 100644 --- a/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_onnx.py +++ b/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_onnx.py @@ -107,7 +107,7 @@ class StableDiffusionOnnxPipeline(DiffusionPipeline): self.scheduler.set_timesteps(num_inference_steps, **extra_set_kwargs) - # if we use LMSDiscreteScheduler, let's make sure latents are mulitplied by sigmas + # if we use LMSDiscreteScheduler, let's make sure latents are multiplied by sigmas if isinstance(self.scheduler, LMSDiscreteScheduler): latents = latents * self.scheduler.sigmas[0] diff --git a/src/diffusers/pipelines/stochastic_karras_ve/pipeline_stochastic_karras_ve.py b/src/diffusers/pipelines/stochastic_karras_ve/pipeline_stochastic_karras_ve.py index 15266544db..1984a25ac0 100644 --- a/src/diffusers/pipelines/stochastic_karras_ve/pipeline_stochastic_karras_ve.py +++ b/src/diffusers/pipelines/stochastic_karras_ve/pipeline_stochastic_karras_ve.py @@ -55,7 +55,7 @@ class KarrasVePipeline(DiffusionPipeline): expense of slower inference. output_type (`str`, *optional*, defaults to `"pil"`): The output format of the generate image. Choose between - [PIL](https://pillow.readthedocs.io/en/stable/): `PIL.Image.Image` or `nd.array`. + [PIL](https://pillow.readthedocs.io/en/stable/): `PIL.Image.Image` or `np.array`. return_dict (`bool`, *optional*, defaults to `True`): Whether or not to return a [`~pipeline_utils.ImagePipelineOutput`] instead of a plain tuple. diff --git a/src/diffusers/schedulers/README.md b/src/diffusers/schedulers/README.md index 3b1eb9342e..edf2299446 100644 --- a/src/diffusers/schedulers/README.md +++ b/src/diffusers/schedulers/README.md @@ -1,7 +1,7 @@ # Schedulers - Schedulers are the algorithms to use diffusion models in inference as well as for training. They include the noise schedules and define algorithm-specific diffusion steps. -- Schedulers can be used interchangable between diffusion models in inference to find the preferred trade-off between speed and generation quality. +- Schedulers can be used interchangeable between diffusion models in inference to find the preferred trade-off between speed and generation quality. - Schedulers are available in numpy, but can easily be transformed into PyTorch. ## API diff --git a/src/diffusers/schedulers/scheduling_karras_ve.py b/src/diffusers/schedulers/scheduling_karras_ve.py index 9898bb7eda..caf7625fb6 100644 --- a/src/diffusers/schedulers/scheduling_karras_ve.py +++ b/src/diffusers/schedulers/scheduling_karras_ve.py @@ -34,7 +34,7 @@ class KarrasVeOutput(BaseOutput): Computed sample (x_{t-1}) of previous timestep. `prev_sample` should be used as next model input in the denoising loop. derivative (`torch.FloatTensor` of shape `(batch_size, num_channels, height, width)` for images): - Derivate of predicted original image sample (x_0). + Derivative of predicted original image sample (x_0). """ prev_sample: torch.FloatTensor diff --git a/src/diffusers/schedulers/scheduling_sde_vp.py b/src/diffusers/schedulers/scheduling_sde_vp.py index c30237395a..f19a5ad76f 100644 --- a/src/diffusers/schedulers/scheduling_sde_vp.py +++ b/src/diffusers/schedulers/scheduling_sde_vp.py @@ -14,7 +14,7 @@ # DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch -# TODO(Patrick, Anton, Suraj) - make scheduler framework indepedent and clean-up a bit +# TODO(Patrick, Anton, Suraj) - make scheduler framework independent and clean-up a bit import numpy as np import torch diff --git a/tests/test_modeling_common.py b/tests/test_modeling_common.py index 9095e39123..1e98fc9de7 100644 --- a/tests/test_modeling_common.py +++ b/tests/test_modeling_common.py @@ -145,7 +145,7 @@ class ModelTesterMixin: new_model.to(torch_device) new_model.eval() - # check if all paramters shape are the same + # check if all parameters shape are the same for param_name in model.state_dict().keys(): param_1 = model.state_dict()[param_name] param_2 = new_model.state_dict()[param_name] diff --git a/utils/check_inits.py b/utils/check_inits.py index 98d4caf010..c5e25182a4 100644 --- a/utils/check_inits.py +++ b/utils/check_inits.py @@ -288,7 +288,7 @@ def check_submodules(): if len(module_not_registered) > 0: list_of_modules = "\n".join(f"- {module}" for module in module_not_registered) raise ValueError( - "The following submodules are not properly registed in the main init of Transformers:\n" + "The following submodules are not properly registered in the main init of Transformers:\n" f"{list_of_modules}\n" "Make sure they appear somewhere in the keys of `_import_structure` with an empty list as value." ) diff --git a/utils/check_table.py b/utils/check_table.py index 6c74308c2e..28c6ea8891 100644 --- a/utils/check_table.py +++ b/utils/check_table.py @@ -53,7 +53,7 @@ def _find_text_in_file(filename, start_prompt, end_prompt): return "".join(lines[start_index:end_index]), start_index, end_index, lines -# Add here suffixes that are used to identify models, seperated by | +# Add here suffixes that are used to identify models, separated by | ALLOWED_MODEL_SUFFIXES = "Model|Encoder|Decoder|ForConditionalGeneration" # Regexes that match TF/Flax/PT model names. _re_tf_models = re.compile(r"TF(.*)(?:Model|Encoder|Decoder|ForConditionalGeneration)") @@ -88,11 +88,11 @@ def _center_text(text, width): def get_model_table_from_auto_modules(): """Generates an up-to-date model table from the content of the auto modules.""" # Dictionary model names to config. - config_maping_names = diffusers_module.models.auto.configuration_auto.CONFIG_MAPPING_NAMES + config_mapping_names = diffusers_module.models.auto.configuration_auto.CONFIG_MAPPING_NAMES model_name_to_config = { - name: config_maping_names[code] + name: config_mapping_names[code] for code, name in diffusers_module.MODEL_NAMES_MAPPING.items() - if code in config_maping_names + if code in config_mapping_names } model_name_to_prefix = {name: config.replace("ConfigMixin", "") for name, config in model_name_to_config.items()} diff --git a/utils/check_tf_ops.py b/utils/check_tf_ops.py index f6c2b8bae4..a3b9593bb2 100644 --- a/utils/check_tf_ops.py +++ b/utils/check_tf_ops.py @@ -41,7 +41,7 @@ INTERNAL_OPS = [ ] -def onnx_compliancy(saved_model_path, strict, opset): +def onnx_compliance(saved_model_path, strict, opset): saved_model = SavedModel() onnx_ops = [] @@ -98,4 +98,4 @@ if __name__ == "__main__": args = parser.parse_args() if args.framework == "onnx": - onnx_compliancy(args.saved_model_path, args.strict, args.opset) + onnx_compliance(args.saved_model_path, args.strict, args.opset) diff --git a/utils/custom_init_isort.py b/utils/custom_init_isort.py index 6501654872..e1e079a99c 100644 --- a/utils/custom_init_isort.py +++ b/utils/custom_init_isort.py @@ -178,7 +178,7 @@ def sort_imports(file, check_only=True): code, start_prompt="_import_structure = {", end_prompt="if TYPE_CHECKING:" ) - # We ignore block 0 (everything untils start_prompt) and the last block (everything after end_prompt). + # We ignore block 0 (everything until start_prompt) and the last block (everything after end_prompt). for block_idx in range(1, len(main_blocks) - 1): # Check if the block contains some `_import_structure`s thingy to sort. block = main_blocks[block_idx] @@ -202,7 +202,7 @@ def sort_imports(file, check_only=True): internal_blocks = split_code_in_indented_blocks(internal_block_code, indent_level=indent) # We have two categories of import key: list or _import_structu[key].append/extend pattern = _re_direct_key if "_import_structure" in block_lines[0] else _re_indirect_key - # Grab the keys, but there is a trap: some lines are empty or jsut comments. + # Grab the keys, but there is a trap: some lines are empty or just comments. keys = [(pattern.search(b).groups()[0] if pattern.search(b) is not None else None) for b in internal_blocks] # We only sort the lines with a key. keys_to_sort = [(i, key) for i, key in enumerate(keys) if key is not None]