Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
5885d74
Add pag to controlnet inpainting pipeline
juancopi81 Jul 6, 2024
2c11062
Fix minor but with timeste_cond
juancopi81 Jul 6, 2024
6267102
Add code to dummy_torch_and_transformers_objects and use autopipeline…
juancopi81 Jul 6, 2024
d152e16
Fix logic in auto_pipeline when pag and controlnet are present
juancopi81 Jul 8, 2024
d4093e0
Add some debug prints
juancopi81 Jul 8, 2024
3f502f1
Change replacement logic for now so it can take ControlNetPAGInpaintP…
juancopi81 Jul 8, 2024
f6a98cd
Add check of shapes when unet channels == 9
juancopi81 Jul 9, 2024
7d1a260
Remove some print statements, add some debug prints to shapes when un…
juancopi81 Jul 9, 2024
088f0c8
Expand mask and masked_image_latents if necessary when unet has 9 cha…
juancopi81 Jul 9, 2024
bb01aba
Adjust repeat factor so mask, and masked_image_latents match latent_m…
juancopi81 Jul 9, 2024
102ce9d
Concatenate tensors when unet has 9 channels
juancopi81 Jul 10, 2024
f9e4543
Add tests to pag controlnet sd inpaint pipeline
juancopi81 Jul 17, 2024
512a252
Make style changes
juancopi81 Jul 17, 2024
ce28845
Final changes based on @a-r-r-o-w feedback and run make style make qu…
juancopi81 Jul 19, 2024
00f8c7a
Fix incorrect comment for message 'Copied from ...'
juancopi81 Jul 20, 2024
f7a183e
Add test to ensure StableDiffusionControlNetPAGInpaintPipeline works …
juancopi81 Jul 24, 2024
93fca2d
Remove cn_inpainting test for now and change logic if cn and enable_p…
juancopi81 Jul 29, 2024
2fb4fd4
Merge branch 'main' into pag_controlnet_inpaint_sd15
yiyixuxu Sep 4, 2024
d5214db
Merge branch 'main' into pag_controlnet_inpaint_sd15
yiyixuxu Oct 1, 2024
7b2368b
style
yiyixuxu Oct 1, 2024
669052a
loraloadermixin -> stablediffusionloraloadermixin
yiyixuxu Oct 1, 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
3 changes: 3 additions & 0 deletions docs/source/en/api/pipelines/pag.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ The abstract from the paper is:

## StableDiffusionControlNetPAGPipeline
[[autodoc]] StableDiffusionControlNetPAGPipeline

## StableDiffusionControlNetPAGInpaintPipeline
[[autodoc]] StableDiffusionControlNetPAGInpaintPipeline
- all
- __call__

Expand Down
2 changes: 2 additions & 0 deletions src/diffusers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@
"StableDiffusionAttendAndExcitePipeline",
"StableDiffusionControlNetImg2ImgPipeline",
"StableDiffusionControlNetInpaintPipeline",
"StableDiffusionControlNetPAGInpaintPipeline",
"StableDiffusionControlNetPAGPipeline",
"StableDiffusionControlNetPipeline",
"StableDiffusionControlNetXSPipeline",
Expand Down Expand Up @@ -714,6 +715,7 @@
StableDiffusionAttendAndExcitePipeline,
StableDiffusionControlNetImg2ImgPipeline,
StableDiffusionControlNetInpaintPipeline,
StableDiffusionControlNetPAGInpaintPipeline,
StableDiffusionControlNetPAGPipeline,
StableDiffusionControlNetPipeline,
StableDiffusionControlNetXSPipeline,
Expand Down
2 changes: 2 additions & 0 deletions src/diffusers/pipelines/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
)
_import_structure["pag"].extend(
[
"StableDiffusionControlNetPAGInpaintPipeline",
"StableDiffusionPAGPipeline",
"StableDiffusionControlNetPAGPipeline",
"StableDiffusionXLPAGPipeline",
Expand Down Expand Up @@ -515,6 +516,7 @@
)
from .musicldm import MusicLDMPipeline
from .pag import (
StableDiffusionControlNetPAGInpaintPipeline,
StableDiffusionControlNetPAGPipeline,
StableDiffusionPAGPipeline,
StableDiffusionXLControlNetPAGPipeline,
Expand Down
7 changes: 6 additions & 1 deletion src/diffusers/pipelines/auto_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
from .kandinsky3 import Kandinsky3Img2ImgPipeline, Kandinsky3Pipeline
from .latent_consistency_models import LatentConsistencyModelImg2ImgPipeline, LatentConsistencyModelPipeline
from .pag import (
StableDiffusionControlNetPAGInpaintPipeline,
StableDiffusionControlNetPAGPipeline,
StableDiffusionPAGPipeline,
StableDiffusionXLControlNetPAGPipeline,
Expand Down Expand Up @@ -121,6 +122,7 @@
("kandinsky", KandinskyInpaintCombinedPipeline),
("kandinsky22", KandinskyV22InpaintCombinedPipeline),
("stable-diffusion-controlnet", StableDiffusionControlNetInpaintPipeline),
("stable-diffusion-controlnet-pag", StableDiffusionControlNetPAGInpaintPipeline),
("stable-diffusion-xl-controlnet", StableDiffusionXLControlNetInpaintPipeline),
("stable-diffusion-xl-pag", StableDiffusionXLPAGInpaintPipeline),
]
Expand Down Expand Up @@ -944,7 +946,10 @@ def from_pretrained(cls, pretrained_model_or_path, **kwargs):
if "enable_pag" in kwargs:
enable_pag = kwargs.pop("enable_pag")
if enable_pag:
orig_class_name = config["_class_name"].replace("Pipeline", "PAGPipeline")
if "controlnet" in kwargs:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you provide an example where this code addition is needed? I think it should already be addressed in line 944 no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @yiyixuxu,

Thank you very much for your comments. Sorry if I am missing something here, but my idea is as follows:
There are 4 cases that need to be handled:

  • No ControlNet and no Pag -> Keep Pipeline

  • With ControlNet and no Pag -> Replace Pipeline with ControlNetPipeline

  • No ControlNet and with Pag -> Replace Pipeline with PAGPipeline

  • With ControlNet and with Pag -> Replace Pipeline with ControlNetPAGPipeline, which will override the first case.

That's why I added the nested conditions, but maybe I am missing something 🤔

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i see! thank for explaining it, you were absolute ly right!

can we do this instead (to be consistent with AutoPipelineForText2Image and AutoPipelineForImage2Image)

if "controlnet" in kwargs:
            orig_class_name = config["_class_name"].replace("Pipeline", "ControlNetPipeline")
        if "enable_pag" in kwargs:
            enable_pag = kwargs.pop("enable_pag")
            if enable_pag:
                orig_class_name = orig_class_name.replace("Pipeline", "PAGPipeline")

orig_class_name = orig_class_name.replace("Pipeline", "PAGPipeline")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sure, done! This way is better!

orig_class_name = config["_class_name"].replace("Pipeline", "ControlNetPAGPipeline")
else:
orig_class_name = config["_class_name"].replace("Pipeline", "PAGPipeline")

inpainting_cls = _get_task_class(AUTO_INPAINT_PIPELINES_MAPPING, orig_class_name)

Expand Down
2 changes: 2 additions & 0 deletions src/diffusers/pipelines/pag/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
_dummy_objects.update(get_objects_from_module(dummy_torch_and_transformers_objects))
else:
_import_structure["pipeline_pag_controlnet_sd"] = ["StableDiffusionControlNetPAGPipeline"]
_import_structure["pipeline_pag_controlnet_sd_inpaint"] = ["StableDiffusionControlNetPAGInpaintPipeline"]
_import_structure["pipeline_pag_controlnet_sd_xl"] = ["StableDiffusionXLControlNetPAGPipeline"]
_import_structure["pipeline_pag_sd"] = ["StableDiffusionPAGPipeline"]
_import_structure["pipeline_pag_sd_xl"] = ["StableDiffusionXLPAGPipeline"]
Expand All @@ -38,6 +39,7 @@
from ...utils.dummy_torch_and_transformers_objects import *
else:
from .pipeline_pag_controlnet_sd import StableDiffusionControlNetPAGPipeline
from .pipeline_pag_controlnet_sd_inpaint import StableDiffusionControlNetPAGInpaintPipeline
from .pipeline_pag_controlnet_sd_xl import StableDiffusionXLControlNetPAGPipeline
from .pipeline_pag_sd import StableDiffusionPAGPipeline
from .pipeline_pag_sd_xl import StableDiffusionXLPAGPipeline
Expand Down
Loading