Skip to content

Commit 3cf4f9c

Browse files
authored
Allow passing config_file argument to ControlNetModel when using from_single_file (#6959)
* update * update * update
1 parent 40dd9cb commit 3cf4f9c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/diffusers/loaders/controlnet.py

+10
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ def from_single_file(cls, pretrained_model_link_or_path, **kwargs):
3838
- A link to the `.ckpt` file (for example
3939
`"https://huggingface.co/<repo_id>/blob/main/<path_to_file>.ckpt"`) on the Hub.
4040
- A path to a *file* containing all pipeline weights.
41+
config_file (`str`, *optional*):
42+
Filepath to the configuration YAML file associated with the model. If not provided it will default to:
43+
https://raw.githubusercontent.com/lllyasviel/ControlNet/main/models/cldm_v15.yaml
4144
torch_dtype (`str` or `torch.dtype`, *optional*):
4245
Override the default `torch.dtype` and load the model with another dtype. If `"auto"` is passed, the
4346
dtype is automatically derived from the model's weights.
@@ -89,6 +92,7 @@ def from_single_file(cls, pretrained_model_link_or_path, **kwargs):
8992
```
9093
"""
9194
original_config_file = kwargs.pop("original_config_file", None)
95+
config_file = kwargs.pop("config_file", None)
9296
resume_download = kwargs.pop("resume_download", False)
9397
force_download = kwargs.pop("force_download", False)
9498
proxies = kwargs.pop("proxies", None)
@@ -100,6 +104,12 @@ def from_single_file(cls, pretrained_model_link_or_path, **kwargs):
100104
use_safetensors = kwargs.pop("use_safetensors", True)
101105

102106
class_name = cls.__name__
107+
if (config_file is not None) and (original_config_file is not None):
108+
raise ValueError(
109+
"You cannot pass both `config_file` and `original_config_file` to `from_single_file`. Please use only one of these arguments."
110+
)
111+
112+
original_config_file = config_file or original_config_file
103113
original_config, checkpoint = fetch_ldm_config_and_checkpoint(
104114
pretrained_model_link_or_path=pretrained_model_link_or_path,
105115
class_name=class_name,

0 commit comments

Comments
 (0)