Skip to content

Conversation

@huchenz1
Copy link

@huchenz1 huchenz1 commented Oct 28, 2024

When initializing ControlNet-SD3 with the from_transformer method, the dual_attention_layers and qk_norm parameters were not defined in the init method, resulting in the following error:

[rank1]:   File "train_controlnet_sd3.py", line 989, in main
[rank1]:     controlnet = SD3ControlNetModel.from_transformer(transformer)
[rank1]:   File "/home/23124047r/anaconda3/envs/py38/lib/python3.8/site-packages/diffusers/models/controlnet_sd3.py", line 251, in from_transformer
[rank1]:     controlnet = cls(**config)
[rank1]:   File "/home/23124047r/anaconda3/envs/py38/lib/python3.8/site-packages/diffusers/configuration_utils.py", line 665, in inner_init
[rank1]:     init(self, *args, **init_kwargs)
[rank1]: TypeError: __init__() got an unexpected keyword argument 'dual_attention_layers'

To resolve this, the missing keyword arguments were added to ensure compatibility with the from_transformer method.

And pos_embed_input for conditioning images needs to be the same as it in original transformers, for the images shape are the same.

@sayakpaul sayakpaul requested a review from yiyixuxu November 2, 2024 02:15
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

width=sample_size,
patch_size=patch_size,
in_channels=in_channels + extra_conditioning_channels,
in_channels=in_channels,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this change not related to SD 3.5?

Copy link
Author

Choose a reason for hiding this comment

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

It is releated to whether the control net is used for inpainting.
The control image for inpainiting has additional mask channel, but the normal controlnet does not need it. src/diffusers/pipelines/controlnet_sd3/pipeline_stable_diffusion_3_controlnet_inpainting.py

Copy link
Collaborator

@yiyixuxu yiyixuxu Nov 8, 2024

Choose a reason for hiding this comment

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

why are we removing this then? we can set it to 0 when it is not needed, no?

Copy link
Author

Choose a reason for hiding this comment

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

Sorry, you are right. I cancelled the commit and I changed the the default num_extra_conditioning_channels to 0 in the from_transformer method such that when using script, erros will not occur.

@classmethod
def from_transformer(
cls, transformer, num_layers=12, num_extra_conditioning_channels=1, load_weights_from_transformer=True
cls, transformer, num_layers=12, num_extra_conditioning_channels=0, load_weights_from_transformer=True
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we have to change the default? you can manually pass num_extra_conditioning_channels=0 when you need it to be 0, no?

otherwise I will tag the original author to see if it is ok to change here (to make sure it won't break anything)

Copy link
Author

Choose a reason for hiding this comment

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

Because the method in training script use the default parameters and the script is for add control with normal image instead of inpainting. As the result, with num_extra_conditioning_channels=0 in this method, script will occur errors.
In addtion, the default value of num_extra_conditioning_channels in ini method is also 0.

@sayakpaul sayakpaul requested a review from yiyixuxu November 28, 2024 11:02
@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.

@github-actions github-actions bot added the stale Issues that haven't received updates label Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale Issues that haven't received updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants