From d4665cb6c05ed15c6ec29834d758373705f32d01 Mon Sep 17 00:00:00 2001 From: yiyixuxu Date: Tue, 5 Mar 2024 00:50:17 +0000 Subject: [PATCH 1/5] update the signature of from_single_file --- src/diffusers/loaders/single_file.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/diffusers/loaders/single_file.py b/src/diffusers/loaders/single_file.py index 875858ce7761..55681d8e6fd1 100644 --- a/src/diffusers/loaders/single_file.py +++ b/src/diffusers/loaders/single_file.py @@ -181,6 +181,31 @@ def from_single_file(cls, pretrained_model_link_or_path, **kwargs): revision (`str`, *optional*, defaults to `"main"`): The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier allowed by Git. + original_config_file (`str`, *optional*): + The path to the original config file that was used to train the model. If not provided, the config file + will be inferred from the checkpoint file. + model_type (`str`, *optional*): + The type of model to load. If not provided, the model type will be inferred from the checkpoint file. + image_size (`int`, *optional*): + The size of the image output. It's used to configure the `simple_size` parameter of the UNet and VAE model. + load_safety_checker (`bool`, *optional*, defaults to `False`): + Whether to load the safety checker model or not. By default, the safety checker is not loaded unless user pass + a `safety_checker` component in the `kwargs`. + num_in_channels (`int`, *optional*): + Specify the number of input channels for the UNet model. Read more about how to configure UNet model with this parameter + here https://huggingface.co/docs/diffusers/training/adapt_a_model#configure-unet2dconditionmodel-parameters + scaling_factor (`float`, *optional*): + The scaling factor to use for the VAE model. If not provided, It will first try to infer from the config file. + If the scaling factor is not found in the config file, the defaut value 0.18215 is used + scheduler_type (`str`, *optional*): + The type of scheduler to load. If not provided, the scheduler type will be inferred from the checkpoint file. + prediction_type (`str`, *optional*): + The type of prediction to load. If not provided, the prediction type will be inferred from the checkpoint file. + kwargs (remaining dictionary of keyword arguments, *optional*): + Can be used to overwrite load and saveable variables (the pipeline components of the specific pipeline + class). The overwritten components are passed directly to the pipelines `__init__` method. See example + below for more information. + Examples: ```py From 9d9fcbb6dca632e7de7162618630708462122f9a Mon Sep 17 00:00:00 2001 From: Dhruv Nair Date: Wed, 6 Mar 2024 14:25:15 +0530 Subject: [PATCH 2/5] Update src/diffusers/loaders/single_file.py Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com> --- src/diffusers/loaders/single_file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/diffusers/loaders/single_file.py b/src/diffusers/loaders/single_file.py index 55681d8e6fd1..24252a703247 100644 --- a/src/diffusers/loaders/single_file.py +++ b/src/diffusers/loaders/single_file.py @@ -187,7 +187,7 @@ def from_single_file(cls, pretrained_model_link_or_path, **kwargs): model_type (`str`, *optional*): The type of model to load. If not provided, the model type will be inferred from the checkpoint file. image_size (`int`, *optional*): - The size of the image output. It's used to configure the `simple_size` parameter of the UNet and VAE model. + The size of the image output. It's used to configure the `sample_size` parameter of the UNet and VAE model. load_safety_checker (`bool`, *optional*, defaults to `False`): Whether to load the safety checker model or not. By default, the safety checker is not loaded unless user pass a `safety_checker` component in the `kwargs`. From 30349936d31fe3cbdbbfcb39ecd3a23cb4790632 Mon Sep 17 00:00:00 2001 From: Dhruv Nair Date: Wed, 6 Mar 2024 14:25:32 +0530 Subject: [PATCH 3/5] Update src/diffusers/loaders/single_file.py Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com> --- src/diffusers/loaders/single_file.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/diffusers/loaders/single_file.py b/src/diffusers/loaders/single_file.py index 24252a703247..c9c38c87b788 100644 --- a/src/diffusers/loaders/single_file.py +++ b/src/diffusers/loaders/single_file.py @@ -189,8 +189,7 @@ def from_single_file(cls, pretrained_model_link_or_path, **kwargs): image_size (`int`, *optional*): The size of the image output. It's used to configure the `sample_size` parameter of the UNet and VAE model. load_safety_checker (`bool`, *optional*, defaults to `False`): - Whether to load the safety checker model or not. By default, the safety checker is not loaded unless user pass - a `safety_checker` component in the `kwargs`. + Whether to load the safety checker model or not. By default, the safety checker is not loaded unless a `safety_checker` component is passed to the `kwargs`. num_in_channels (`int`, *optional*): Specify the number of input channels for the UNet model. Read more about how to configure UNet model with this parameter here https://huggingface.co/docs/diffusers/training/adapt_a_model#configure-unet2dconditionmodel-parameters From 9be48155ca1b89445ede86ac713d0089c4bb8650 Mon Sep 17 00:00:00 2001 From: Dhruv Nair Date: Wed, 6 Mar 2024 14:25:38 +0530 Subject: [PATCH 4/5] Update src/diffusers/loaders/single_file.py Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com> --- src/diffusers/loaders/single_file.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diffusers/loaders/single_file.py b/src/diffusers/loaders/single_file.py index c9c38c87b788..3c7dd5d062e8 100644 --- a/src/diffusers/loaders/single_file.py +++ b/src/diffusers/loaders/single_file.py @@ -194,8 +194,8 @@ def from_single_file(cls, pretrained_model_link_or_path, **kwargs): Specify the number of input channels for the UNet model. Read more about how to configure UNet model with this parameter here https://huggingface.co/docs/diffusers/training/adapt_a_model#configure-unet2dconditionmodel-parameters scaling_factor (`float`, *optional*): - The scaling factor to use for the VAE model. If not provided, It will first try to infer from the config file. - If the scaling factor is not found in the config file, the defaut value 0.18215 is used + The scaling factor to use for the VAE model. If not provided, it is inferred from the config file first. + If the scaling factor is not found in the config file, the default value 0.18215 is used. scheduler_type (`str`, *optional*): The type of scheduler to load. If not provided, the scheduler type will be inferred from the checkpoint file. prediction_type (`str`, *optional*): From c5ee141a539ec8fc8a7c4dbfd132e364e53a8d4a Mon Sep 17 00:00:00 2001 From: Dhruv Nair Date: Wed, 6 Mar 2024 14:25:45 +0530 Subject: [PATCH 5/5] Update src/diffusers/loaders/single_file.py Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com> --- src/diffusers/loaders/single_file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/diffusers/loaders/single_file.py b/src/diffusers/loaders/single_file.py index 3c7dd5d062e8..d17ed4f743db 100644 --- a/src/diffusers/loaders/single_file.py +++ b/src/diffusers/loaders/single_file.py @@ -192,7 +192,7 @@ def from_single_file(cls, pretrained_model_link_or_path, **kwargs): Whether to load the safety checker model or not. By default, the safety checker is not loaded unless a `safety_checker` component is passed to the `kwargs`. num_in_channels (`int`, *optional*): Specify the number of input channels for the UNet model. Read more about how to configure UNet model with this parameter - here https://huggingface.co/docs/diffusers/training/adapt_a_model#configure-unet2dconditionmodel-parameters + [here](https://huggingface.co/docs/diffusers/training/adapt_a_model#configure-unet2dconditionmodel-parameters). scaling_factor (`float`, *optional*): The scaling factor to use for the VAE model. If not provided, it is inferred from the config file first. If the scaling factor is not found in the config file, the default value 0.18215 is used.