Skip to content
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

[Pipeline] Add LEDITS++ pipelines #6074

Merged
merged 56 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
eb9d25b
Setup LEdits++ file structure
manuelbrack Nov 30, 2023
b53ecc1
Fix import
manuelbrack Nov 30, 2023
92eb6b3
LEditsPP Stable Diffusion pipeline
kathath Nov 30, 2023
c86cd2b
Include variable image aspect ratios
manuelbrack Nov 30, 2023
cf89827
Implement LEDITS++ for SDXL
manuelbrack Dec 1, 2023
2111db0
clean up LEditsPPPipelineStableDiffusion
kathath Dec 1, 2023
03b5770
Merge branch 'ledits_pp' of github.com:ml-research/diffusers into led…
kathath Dec 1, 2023
a0deef0
Adjust inversion output
manuelbrack Dec 1, 2023
32a78ef
Added docu, more cleanup for LEditsPPPipelineStableDiffusion
kathath Dec 5, 2023
4b2e3be
Merge branch 'ledits_pp' of github.com:ml-research/diffusers into led…
kathath Dec 5, 2023
e9aec54
clean up LEditsPPPipelineStableDiffusionXL
kathath Dec 6, 2023
1ef50b3
Update documentation
manuelbrack Dec 7, 2023
a00b353
Fix documentation import
manuelbrack Dec 7, 2023
ce70506
Add skeleton IF implementation
manuelbrack Dec 7, 2023
127c352
Fix documentation typo
manuelbrack Dec 7, 2023
c90c80e
Add LEDTIS docu to toctree
manuelbrack Dec 7, 2023
af19de6
Add missing title
manuelbrack Dec 7, 2023
06e8861
Finalize SD documentation
manuelbrack Dec 7, 2023
149bc4d
Finalize SD-XL documentation
manuelbrack Dec 7, 2023
d798e05
Fix code style and quality
manuelbrack Dec 7, 2023
e1f428b
Fix typo
manuelbrack Dec 7, 2023
c2d7a0a
Fix return types
manuelbrack Dec 8, 2023
244e6f0
added LEditsPPPipelineIF; minor changes for LEditsPPPipelineStableDif…
kathath Dec 8, 2023
0da0115
Fix copy reference
manuelbrack Dec 10, 2023
69f064f
add documentation for IF
manuelbrack Dec 10, 2023
d690ad8
Add first tests
kathath Dec 12, 2023
82a2d5a
Fix batching for SD-XL
kathath Dec 20, 2023
1464328
Fix text encoding and perfect reconstruction for SD-XL
kathath Dec 20, 2023
f6b94eb
Add tests for SD-XL, minor changes
kathath Dec 20, 2023
8409e04
move user_mask to correct device, use cross_attention_kwargs also for…
kathath Dec 28, 2023
49a4a2c
Example docstring
kathath Dec 28, 2023
b5055b8
Fix attention resolution for non-square images
manuelbrack Jan 25, 2024
2e06d07
Refactoring for PR review
manuelbrack Jan 29, 2024
935508d
Merge branch 'main' into ledits_pp
manuelbrack Jan 29, 2024
8154fee
Safely remove ledits_utils.py
manuelbrack Jan 29, 2024
074a035
Style fixes
manuelbrack Jan 29, 2024
0d60c3b
Replace assertions with ValueError
manuelbrack Jan 29, 2024
2da7bca
Remove LEditsPPPipelineIF
manuelbrack Feb 8, 2024
87b2f08
Remove unecessary input checks
manuelbrack Feb 8, 2024
e91ef78
Refactoring of CrossAttnProcessor
manuelbrack Feb 9, 2024
0ab4ec0
Revert unecessary changes to scheduler
manuelbrack Feb 9, 2024
ae13535
Remove first progress-bar in inversion
manuelbrack Feb 9, 2024
2dc5247
Refactor scheduler usage and reset
manuelbrack Feb 13, 2024
8e5e310
Use imageprocessor instead of custom logic
manuelbrack Feb 13, 2024
1ec846a
Fix scheduler init warning
manuelbrack Feb 13, 2024
9de246b
Fix error when running the pipeline in fp16
manuelbrack Feb 13, 2024
e71c5ce
Update documentation wrt perfect inversion
manuelbrack Feb 13, 2024
76b4447
Update tests
manuelbrack Feb 13, 2024
74627c8
Merge branch 'huggingface:main' into ledits_pp
manuelbrack Feb 27, 2024
976edb6
Fix code quality and copy consistency
manuelbrack Feb 27, 2024
73574a5
Update LEditsPP import
manuelbrack Mar 1, 2024
afab27d
Merge branch 'main' into ledits_pp
manuelbrack Mar 1, 2024
47f64fd
Remove enable/disable methods that are now in StableDiffusionMixin
manuelbrack Mar 6, 2024
6770e67
Change import in docs
manuelbrack Mar 7, 2024
8ba5e24
Revert import structure change
manuelbrack Mar 7, 2024
dfa291f
Fix ledits imports
manuelbrack Mar 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/source/en/_toctree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@
title: Latent Consistency Models
- local: api/pipelines/latent_diffusion
title: Latent Diffusion
- local: api/pipelines/ledits_pp
title: LEDITS++
- local: api/pipelines/panorama
title: MultiDiffusion
- local: api/pipelines/musicldm
Expand Down
54 changes: 54 additions & 0 deletions docs/source/en/api/pipelines/ledits_pp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!--Copyright 2023 The HuggingFace 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.
-->

# LEDITS++

LEDITS++ was proposed in [LEDITS++: Limitless Image Editing using Text-to-Image Models](https://huggingface.co/papers/2311.16711) by Manuel Brack, Felix Friedrich, Katharina Kornmeier, Linoy Tsaban, Patrick Schramowski, Kristian Kersting, Apolinário Passos.

The abstract from the paper is:

*Text-to-image diffusion models have recently received increasing interest for their astonishing ability to produce high-fidelity images from solely text inputs. Subsequent research efforts aim to exploit and apply their capabilities to real image editing. However, existing image-to-image methods are often inefficient, imprecise, and of limited versatility. They either require time-consuming fine-tuning, deviate unnecessarily strongly from the input image, and/or lack support for multiple, simultaneous edits. To address these issues, we introduce LEDITS++, an efficient yet versatile and precise textual image manipulation technique. LEDITS++'s novel inversion approach requires no tuning nor optimization and produces high-fidelity results with a few diffusion steps. Second, our methodology supports multiple simultaneous edits and is architecture-agnostic. Third, we use a novel implicit masking technique that limits changes to relevant image regions. We propose the novel TEdBench++ benchmark as part of our exhaustive evaluation. Our results demonstrate the capabilities of LEDITS++ and its improvements over previous methods. The project page is available at https://leditsplusplus-project.static.hf.space .*

<Tip>

You can find additional information about LEDITS++ on the [project page](https://leditsplusplus-project.static.hf.space/index.html) and try it out in a [demo](https://huggingface.co/spaces/editing-images/leditsplusplus).

</Tip>

<Tip warning={true}>
Due to some backward compatability issues with the current diffusers implementation of [`~schedulers.DPMSolverMultistepScheduler`] this implementation of LEdits++ can no longer guarantee perfect inversion.
This issue is unlikely to have any noticeable effects on applied use-cases. However, we provide an alternative implementation that guarantees perfect inversion in a dedicated [GitHub repo](https://github.com/ml-research/ledits_pp).
</Tip>

We provide two distinct pipelines based on different pre-trained models.

## LEditsPPPipelineStableDiffusion
[[autodoc]] LEditsPPPipelineStableDiffusion
- all
- __call__
- invert

## LEditsPPPipelineStableDiffusionXL
[[autodoc]] LEditsPPPipelineStableDiffusionXL
- all
- __call__
- invert



## LEditsPPDiffusionPipelineOutput
[[autodoc]] pipelines.ledits_pp.pipeline_output.LEditsPPDiffusionPipelineOutput
- all

## LEditsPPInversionPipelineOutput
[[autodoc]] pipelines.ledits_pp.pipeline_output.LEditsPPInversionPipelineOutput
- all
1 change: 1 addition & 0 deletions docs/source/en/api/pipelines/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ The table below lists all the pipelines currently available in 🤗 Diffusers an
| [Latent Consistency Models](latent_consistency_models) | text2image |
| [Latent Diffusion](latent_diffusion) | text2image, super-resolution |
| [LDM3D](stable_diffusion/ldm3d_diffusion) | text2image, text-to-3D, text-to-pano, upscaling |
| [LEDITS++](ledits_pp) | image editing |
| [MultiDiffusion](panorama) | text2image |
| [MusicLDM](musicldm) | text2audio |
| [Paint by Example](paint_by_example) | inpainting |
Expand Down
2 changes: 1 addition & 1 deletion docs/source/en/api/pipelines/semantic_stable_diffusion.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ Make sure to check out the Schedulers [guide](../../using-diffusers/schedulers)
- all
- __call__

## StableDiffusionSafePipelineOutput
## SemanticStableDiffusionPipelineOutput
manuelbrack marked this conversation as resolved.
Show resolved Hide resolved
[[autodoc]] pipelines.semantic_stable_diffusion.pipeline_output.SemanticStableDiffusionPipelineOutput
- all
4 changes: 4 additions & 0 deletions src/diffusers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@
"LatentConsistencyModelImg2ImgPipeline",
"LatentConsistencyModelPipeline",
"LDMTextToImagePipeline",
"LEditsPPPipelineStableDiffusion",
"LEditsPPPipelineStableDiffusionXL",
"MusicLDMPipeline",
"PaintByExamplePipeline",
"PIAPipeline",
Expand Down Expand Up @@ -611,6 +613,8 @@
LatentConsistencyModelImg2ImgPipeline,
LatentConsistencyModelPipeline,
LDMTextToImagePipeline,
LEditsPPPipelineStableDiffusion,
LEditsPPPipelineStableDiffusionXL,
MusicLDMPipeline,
PaintByExamplePipeline,
PIAPipeline,
Expand Down
7 changes: 7 additions & 0 deletions src/diffusers/pipelines/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"controlnet_xs": [],
"deprecated": [],
"latent_diffusion": [],
"ledits_pp": [],
"stable_diffusion": [],
"stable_diffusion_xl": [],
}
Expand Down Expand Up @@ -169,6 +170,12 @@
"LatentConsistencyModelPipeline",
]
_import_structure["latent_diffusion"].extend(["LDMTextToImagePipeline"])
_import_structure["ledits_pp"].extend(
[
"LEditsPPPipelineStableDiffusion",
"LEditsPPPipelineStableDiffusionXL",
]
)
yiyixuxu marked this conversation as resolved.
Show resolved Hide resolved
_import_structure["musicldm"] = ["MusicLDMPipeline"]
_import_structure["paint_by_example"] = ["PaintByExamplePipeline"]
_import_structure["pia"] = ["PIAPipeline"]
Expand Down
55 changes: 55 additions & 0 deletions src/diffusers/pipelines/ledits_pp/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
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 = {}

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["pipeline_leditspp_stable_diffusion"] = ["LEditsPPPipelineStableDiffusion"]
_import_structure["pipeline_leditspp_stable_diffusion_xl"] = ["LEditsPPPipelineStableDiffusionXL"]

_import_structure["pipeline_output"] = ["LEditsPPDiffusionPipelineOutput", "LEditsPPDiffusionPipelineOutput"]

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 *
else:
from .pipeline_leditspp_stable_diffusion import (
LEditsPPDiffusionPipelineOutput,
LEditsPPInversionPipelineOutput,
LEditsPPPipelineStableDiffusion,
)
from .pipeline_leditspp_stable_diffusion_xl import LEditsPPPipelineStableDiffusionXL

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)
Loading
Loading