-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Add AniMemoryPipeline #10083
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
Open
animemory
wants to merge
13
commits into
huggingface:main
Choose a base branch
from
animemory:animemory
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add AniMemoryPipeline #10083
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
537562a
Add AniMemoryPipeline
animemory 786be0d
Merge branch 'main' into animemory
animemory 8f51743
refactor the scheduler
animemory b3a70b5
Merge branch 'main' into animemory
animemory f71062f
make
hlky 8cb5e51
doc-builder
hlky 020f8ae
make style
hlky a479683
make fix-copies
hlky c924111
Add docs
animemory 407ea6e
Merge branch 'animemory' of https://github.com/animemory/diffusers in…
animemory 0076d0d
Merge branch 'main' into animemory
animemory 5c98d7e
Merge branch 'main' into animemory
animemory 71cadd4
Merge branch 'main' into animemory
a-r-r-o-w 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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,58 @@ | ||||||
| <!--Copyright 2024 The HuggingFace Team and AniMemory Team. All rights reserved. | ||||||
|
|
||||||
| Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||||||
| the License. You may obtain a copy of the License at | ||||||
|
|
||||||
| http://www.apache.org/licenses/LICENSE-2.0 | ||||||
|
|
||||||
| Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||||||
| an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||||||
| specific language governing permissions and limitations under the License. | ||||||
| --> | ||||||
|
|
||||||
| # AniMemory-alpha | ||||||
|  | ||||||
|
|
||||||
|
|
||||||
|
|
||||||
| [Animemory Alpha](https://huggingface.co/animEEEmpire/AniMemory-alpha) is a bilingual model primarily focused on anime-style image generation. It utilizes a SDXL-type Unet | ||||||
| structure and a self-developed bilingual T5-XXL text encoder, achieving good alignment between Chinese and English. We | ||||||
| first developed our general model using billion-level data and then tuned the anime model through a series of | ||||||
| post-training strategies and curated data. By open-sourcing the Alpha version, we hope to contribute to the development | ||||||
| of the anime community, and we greatly value any feedback. | ||||||
|
|
||||||
| ### Usage | ||||||
| ``` | ||||||
| from diffusers import AniMemoryPipeline | ||||||
| import torch | ||||||
|
|
||||||
| pipe = AniMemoryPipeline.from_pretrained("animEEEmpire/AniMemory-alpha", torch_dtype=torch.bfloat16) | ||||||
| pipe.to("cuda") | ||||||
|
|
||||||
| prompt = "一只凶恶的狼,猩红的眼神,在午夜咆哮,月光皎洁" | ||||||
| negative_prompt = "nsfw, worst quality, low quality, normal quality, low resolution, monochrome, blurry, wrong, Mutated hands and fingers, text, ugly faces, twisted, jpeg artifacts, watermark, low contrast, realistic" | ||||||
|
|
||||||
| images = pipe(prompt=prompt, | ||||||
| negative_prompt=negative_prompt, | ||||||
| num_inference_steps=40, | ||||||
| height=1024, width=1024, | ||||||
| guidance_scale=7.0 | ||||||
| )[0] | ||||||
| images.save("output.png") | ||||||
| ``` | ||||||
|
|
||||||
| Use pipe.enable_sequential_cpu_offload() to offload the model into CPU for less GPU memory cost (about 14.25 G, compared to 25.67 G if CPU offload is not enabled), but the inference time will increase significantly(5.18s v.s. 17.74s on A100 40G). | ||||||
|
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.
Suggested change
|
||||||
|
|
||||||
| <Tip> | ||||||
|
|
||||||
| Make sure to check out the Schedulers [guide](../../using-diffusers/schedulers.md) to learn how to explore the tradeoff between scheduler speed and quality, and see the [reuse components across pipelines](../../using-diffusers/loading.md#reuse-a-pipeline) section to learn how to efficiently load the same components into multiple pipelines. | ||||||
|
|
||||||
| </Tip> | ||||||
|
|
||||||
|
|
||||||
|
|
||||||
| ## AniMemoryPipeline | ||||||
|
|
||||||
| [[autodoc]] AniMemoryPipeline | ||||||
| - all | ||||||
| - __call__ | ||||||
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 | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,18 @@ | ||||||
| <!--Copyright 2024 The HuggingFace Team and AniMemory Team. All rights reserved. | ||||||
|
|
||||||
| Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||||||
| the License. You may obtain a copy of the License at | ||||||
|
|
||||||
| http://www.apache.org/licenses/LICENSE-2.0 | ||||||
|
|
||||||
| Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||||||
| an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||||||
| specific language governing permissions and limitations under the License. | ||||||
| --> | ||||||
|
|
||||||
| # EulerAncestralDiscreteXPredScheduler | ||||||
|
|
||||||
| An improved scheduler(SingDiffusion) that addresses the sampling challenge at the initial singular time step. To know more about SingDiffusion, check out the original [blog post](https://pangzecheung.github.io/SingDiffusion/). Our original paper can be found [here](https://arxiv.org/abs/2403.08381). | ||||||
|
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.
Suggested change
|
||||||
|
|
||||||
| ## EulerAncestralDiscreteXPredScheduler | ||||||
| [[autodoc]] EulerAncestralDiscreteXPredScheduler | ||||||
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 |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| from typing import TYPE_CHECKING | ||
|
|
||
| from ...utils import ( | ||
| DIFFUSERS_SLOW_IMPORT, | ||
| OptionalDependencyNotAvailable, | ||
| _LazyModule, | ||
| get_objects_from_module, | ||
| is_torch_available, | ||
| is_transformers_available, | ||
| ) | ||
|
|
||
|
|
||
| _dummy_objects = {} | ||
| _import_structure = {"pipeline_output": ["AniMemoryPipelineOutput"]} | ||
|
|
||
|
|
||
| try: | ||
| if not (is_transformers_available() and is_torch_available()): | ||
| raise OptionalDependencyNotAvailable() | ||
| except OptionalDependencyNotAvailable: | ||
| from ...utils import dummy_torch_and_transformers_objects # noqa F403 | ||
|
|
||
| _dummy_objects.update(get_objects_from_module(dummy_torch_and_transformers_objects)) | ||
| else: | ||
| _import_structure["modeling_movq"] = ["MoVQ"] | ||
| _import_structure["modeling_text_encoder"] = ["AniMemoryAltCLip", "AniMemoryT5"] | ||
| _import_structure["pipeline_animemory"] = ["AniMemoryPipeline"] | ||
|
|
||
| if TYPE_CHECKING or DIFFUSERS_SLOW_IMPORT: | ||
| try: | ||
| if not (is_transformers_available() and is_torch_available()): | ||
| raise OptionalDependencyNotAvailable() | ||
|
|
||
| except OptionalDependencyNotAvailable: | ||
| from ...utils.dummy_torch_and_transformers_objects import * # noqa F403 | ||
| else: | ||
| from .pipeline_animemory import AniMemoryPipeline | ||
|
|
||
| else: | ||
| import sys | ||
|
|
||
| sys.modules[__name__] = _LazyModule( | ||
| __name__, | ||
| globals()["__file__"], | ||
| _import_structure, | ||
| module_spec=__spec__, | ||
| ) | ||
|
|
||
| for name, value in _dummy_objects.items(): | ||
| setattr(sys.modules[__name__], name, value) |
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.