-
Notifications
You must be signed in to change notification settings - Fork 6.6k
add a from_pipe method to DiffusionPipeline
#7241
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
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
99cdecc
add from_pipe
f664d17
up
daab15d
up
1639263
style
29cc455
Merge branch 'main' into from_pipe
yiyixuxu a94ef03
add test
yiyixuxu 0b9d579
fix tests
yiyixuxu 507dc3c
add a test for offload
yiyixuxu afd5354
fix tests
yiyixuxu e17504a
fix
yiyixuxu 20829e0
make get_signature_types a class method + find out which pipelines ca…
yiyixuxu 6f97758
style
yiyixuxu f722006
up
yiyixuxu cac53a0
up
yiyixuxu ada8d04
fix tests!
yiyixuxu 02f0527
update test name
yiyixuxu e4a785c
Merge branch 'main' into from_pipe
yiyixuxu 312cce4
separate out the cpu offload test
yiyixuxu a496e8c
Merge branch 'from_pipe' of github.com:huggingface/diffusers into fro…
yiyixuxu af4f18f
only check type for modules
yiyixuxu 7c9bfbe
Merge branch 'main' into from_pipe
yiyixuxu 28cf55b
Apply suggestions from code review
yiyixuxu f21b738
up
yiyixuxu 6660203
up
yiyixuxu b3fb32e
Merge branch 'main' into from_pipe
yiyixuxu 154bdbc
made a texter mixin for from_pipe
yiyixuxu e501044
fix tests: make sure pipelines does not make stateful changes to the …
yiyixuxu f2e2ffe
add doc
yiyixuxu 26535f6
Update src/diffusers/pipelines/pipeline_utils.py
yiyixuxu 3bf58a4
up
yiyixuxu 5e39360
move guide
yiyixuxu e088ac3
Merge branch 'main' into from_pipe
yiyixuxu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -292,6 +292,39 @@ def get_class_obj_and_candidates( | |
| return class_obj, class_candidates | ||
|
|
||
|
|
||
| def _get_custom_pipeline_class( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very nice cleanup here! |
||
| custom_pipeline, | ||
| repo_id=None, | ||
| hub_revision=None, | ||
| class_name=None, | ||
| cache_dir=None, | ||
| revision=None, | ||
| ): | ||
| if custom_pipeline.endswith(".py"): | ||
| path = Path(custom_pipeline) | ||
| # decompose into folder & file | ||
| file_name = path.name | ||
| custom_pipeline = path.parent.absolute() | ||
| elif repo_id is not None: | ||
| file_name = f"{custom_pipeline}.py" | ||
| custom_pipeline = repo_id | ||
| else: | ||
| file_name = CUSTOM_PIPELINE_FILE_NAME | ||
|
|
||
| if repo_id is not None and hub_revision is not None: | ||
| # if we load the pipeline code from the Hub | ||
| # make sure to overwrite the `revision` | ||
| revision = hub_revision | ||
|
|
||
| return get_class_from_dynamic_module( | ||
| custom_pipeline, | ||
| module_file=file_name, | ||
| class_name=class_name, | ||
| cache_dir=cache_dir, | ||
| revision=revision, | ||
| ) | ||
|
|
||
|
|
||
| def _get_pipeline_class( | ||
| class_obj, | ||
| config=None, | ||
|
|
@@ -304,25 +337,10 @@ def _get_pipeline_class( | |
| revision=None, | ||
| ): | ||
| if custom_pipeline is not None: | ||
| if custom_pipeline.endswith(".py"): | ||
| path = Path(custom_pipeline) | ||
| # decompose into folder & file | ||
| file_name = path.name | ||
| custom_pipeline = path.parent.absolute() | ||
| elif repo_id is not None: | ||
| file_name = f"{custom_pipeline}.py" | ||
| custom_pipeline = repo_id | ||
| else: | ||
| file_name = CUSTOM_PIPELINE_FILE_NAME | ||
|
|
||
| if repo_id is not None and hub_revision is not None: | ||
| # if we load the pipeline code from the Hub | ||
| # make sure to overwrite the `revision` | ||
| revision = hub_revision | ||
|
|
||
| return get_class_from_dynamic_module( | ||
| return _get_custom_pipeline_class( | ||
| custom_pipeline, | ||
| module_file=file_name, | ||
| repo_id=repo_id, | ||
| hub_revision=hub_revision, | ||
| class_name=class_name, | ||
| cache_dir=cache_dir, | ||
| revision=revision, | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@DN6
currently, we will modify the original 2d unet's config - even though we do not use it here, we create a new unet motion model instead