-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Integration of from_pretrained
and from_single_file
#10208
base: main
Are you sure you want to change the base?
Integration of from_pretrained
and from_single_file
#10208
Conversation
Updated dictionary used when loading the |
Can anyone please review this PR? |
…loading_method_integration
…e map for loading single file checkpoints.
…loading_method_integration
Hi @suzukimain thank you for taking the time to put this together. I think if we were to unify single file and from pretrained loading it would be by placing all the loading logic under We can look into how to unify the two loading methods, but I don't think we can merge this PR in its current state. cc'ing: @yiyixuxu for her thoughts as well. |
…Integrate-load-method-into-from_pretrained
local_files_only=local_files_only, | ||
revision=revision, | ||
) | ||
pipeline_class = _get_pipeline_class(cls, class_name=cls.__name__, config=None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don't pass the class_name when loading a single file checkpoint in DiffusionPipeline
, it will result in a TypeError.
# Load the pipeline from a single file | ||
elif load_method_name == "from_single_file": | ||
# The arguments for the __init__ method of `DiffusionPipeline` are keyword arguments, so they cannot be loaded from `from_single_file` | ||
if cls.__name__ == "DiffusionPipeline": | ||
# import it here to avoid circular import | ||
from .stable_diffusion.convert_from_ckpt import download_from_original_stable_diffusion_ckpt | ||
|
||
checkpoint = load_single_file_checkpoint( | ||
pretrained_model_name_or_path, | ||
force_download=force_download, | ||
proxies=proxies, | ||
token=token, | ||
cache_dir=cache_dir, | ||
local_files_only=local_files_only, | ||
revision=revision, | ||
) | ||
|
||
return download_from_original_stable_diffusion_ckpt(checkpoint, **kwargs) | ||
else: | ||
return cls.from_single_file(pretrained_model_name_or_path, **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm separating the process because executing DiffusionPipeline.from_single_file
results in the following error:
ValueError: Pipeline <class 'diffusers.pipelines.pipeline_utils.DiffusionPipeline'> expected {'kwargs', 'args'}, but only set() were passed.
…loading_method_integration
What does this PR do?
This PR integrates the
from_single_file
function intofrom_pretrained
Additionally, since
AutoPipeline
doesn't have a method to load single file checkpoints, I've adapted a part of the model_search functionality to enable this capability.Before submitting
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@yiyixuxu ,@asomoza