-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Add ControlNet-XS support #5827
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
Merged
Changes from all commits
Commits
Show all changes
100 commits
Select commit
Hold shift + click to select a range
7ce3745
Check in 23-10-05
UmerHA 70d58d9
check-in 23-10-06
UmerHA 762bdfd
check-in 23-10-07 2pm
UmerHA 267ca00
check-in 23-10-08
UmerHA 5356478
check-in 231009T1200
UmerHA b30120c
check-in 230109
UmerHA 7b67ceb
checkin 231010
UmerHA f4d8d62
init + forward run
UmerHA 9c17549
checkin
UmerHA cc40b55
checkin
UmerHA 95b7425
ControlNetXSModel is now saveable+loadable
UmerHA 0e7c848
Forward works
UmerHA 969e7e8
checkin
UmerHA 111fa2d
Pipeline works with `no_control=True`
UmerHA 34b7dbb
Merge branch 'huggingface:main' into controlnet-xs
UmerHA 6270bc0
checkin
UmerHA 7ae8a46
Merge branch 'controlnet-xs' of https://github.com/UmerHA/diffusers i…
UmerHA 9267388
debug: save intermediate outputs of resnet
UmerHA 8bcb3d0
checkin
UmerHA a52e605
Understood time error + fixed connection error
UmerHA b408dbc
checkin
UmerHA e0ad61b
checkin 231106T1600
UmerHA d76881a
turned off detailled debug prints
UmerHA 202d3de
time debug logs
UmerHA 8996cf4
small fix
UmerHA f54ac82
Separated control_scale for connections/time
UmerHA 7654c32
simplified debug logging
UmerHA cc1a706
Full denoising works with control scale = 0
UmerHA 05f9926
aligned logs
UmerHA 34ecd9a
Added control_attention_head_dim param
UmerHA c975ea8
Passing n_heads instead of dim_head into ctrl unet
UmerHA 535149d
Fixed ctrl midblock bug
UmerHA 1583c13
Cleanup
UmerHA 73a7b99
Fixed time dtype bug
UmerHA e20d4b5
checkin
UmerHA 56e9b59
1. from_unet, 2. base passed, 3. all unet params
UmerHA 2cc2cfb
checkin
UmerHA 0bb9457
Finished docstrings
UmerHA 39257c5
cleanup
UmerHA e4f412e
make style
UmerHA 031aab3
Merge remote-tracking branch 'upstream/main' into controlnet-xs
UmerHA e032fa0
checkin
UmerHA e543a54
more tests pass
UmerHA 6945de8
Fixed tests
UmerHA 1a0c4ad
removed debug logs
UmerHA 7cc437e
make style + quality
UmerHA 0f655bb
make fix-copies
UmerHA cf0b6d5
fixed documentation
UmerHA 3cb6d32
added cnxs to doc toc
UmerHA f11e0e7
added control start/end param
UmerHA 7b05af4
Update controlnetxs_sdxl.md
UmerHA 5f99f79
tried to fix copies..
UmerHA 85dc485
Fixed norm_num_groups in from_unet
UmerHA c76eb35
added sdxl-depth test
UmerHA 08668ae
created SD2.1 controlnet-xs pipeline
UmerHA c9d7e7d
Merge branch 'huggingface:main' into controlnet-xs
UmerHA ad1f39f
re-added debug logs
UmerHA 76e9b96
Merge branch 'main' into controlnet-xs
UmerHA 37cbe6c
Adjusting group norm ; readded logs
UmerHA d2c2635
Added debug log statements
UmerHA f794113
removed debug logs ; started tests for sd2.1
UmerHA e6de144
updated sd21 tests
UmerHA 0ba4b03
fixed tests
UmerHA 412c772
fixed tests
UmerHA 3776ce7
slightly increased error tolerance for 1 test
UmerHA 6897ea9
Merge branch 'main' into controlnet-xs
UmerHA 17a12ce
make style & quality
UmerHA a884e87
Added docs for CNXS-SD
UmerHA e6dc473
make fix-copies
UmerHA b598273
Fixed sd compile test ; fixed gradient ckpointing
UmerHA b75e623
vae downs = cnxs conditioning downs; removed guess
UmerHA 0f2a05f
make style & quality
UmerHA f59231c
Fixed tests
UmerHA 165a358
fixed test
UmerHA 8416484
Merge branch 'main' into controlnet-xs
UmerHA a2d5a52
Incorporated review feedback
UmerHA a5d94d7
simplified control model surgery
UmerHA 87a3254
fixed tests & make style / quality
UmerHA d8e723b
Updated docs; deleted pip & cursor files
UmerHA 7b00646
Rolled back minimal change to resnet
UmerHA d8cc418
Update resnet.py
UmerHA aacf54e
Update resnet.py
UmerHA d05be07
Merge branch 'main' into controlnet-xs
UmerHA 5997cf9
Update src/diffusers/models/controlnetxs.py
UmerHA 40e099a
Update src/diffusers/models/controlnetxs.py
UmerHA b789646
Incorporated review feedback
UmerHA a3bd017
Merge branch 'main' into controlnet-xs
UmerHA 06bfe12
Update docs/source/en/api/pipelines/controlnetxs_sdxl.md
UmerHA 4e9448a
Update docs/source/en/api/pipelines/controlnetxs.md
UmerHA 348bedb
Update docs/source/en/api/pipelines/controlnetxs.md
UmerHA 167b767
Update docs/source/en/api/pipelines/controlnetxs.md
UmerHA 40744c9
Update src/diffusers/models/controlnetxs.py
UmerHA bab91cb
Update src/diffusers/models/controlnetxs.py
UmerHA bf976d0
Update src/diffusers/pipelines/controlnet_xs/pipeline_controlnet_xs.py
UmerHA dfa97f0
Update docs/source/en/api/pipelines/controlnetxs.md
UmerHA eb8dd2b
Update src/diffusers/pipelines/controlnet_xs/pipeline_controlnet_xs_s…
UmerHA 58ea5ab
Incorporated doc feedback
UmerHA 7e35ccf
Merge branch 'main' into controlnet-xs
UmerHA 51e4fdd
Merge branch 'main' into controlnet-xs
UmerHA 83a2b11
Merge branch 'main' into controlnet-xs
DN6 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,39 @@ | ||
| <!--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. | ||
| --> | ||
|
|
||
| # ControlNet-XS | ||
|
|
||
| ControlNet-XS was introduced in [ControlNet-XS](https://vislearn.github.io/ControlNet-XS/) by Denis Zavadski and Carsten Rother. It is based on the observation that the control model in the [original ControlNet](https://huggingface.co/papers/2302.05543) can be made much smaller and still produce good results. | ||
|
|
||
| Like the original ControlNet model, you can provide an additional control image to condition and control Stable Diffusion generation. For example, if you provide a depth map, the ControlNet model generates an image that'll preserve the spatial information from the depth map. It is a more flexible and accurate way to control the image generation process. | ||
|
|
||
| ControlNet-XS generates images with comparable quality to a regular ControlNet, but it is 20-25% faster ([see benchmark](https://github.com/UmerHA/controlnet-xs-benchmark/blob/main/Speed%20Benchmark.ipynb) with StableDiffusion-XL) and uses ~45% less memory. | ||
|
|
||
| Here's the overview from the [project page](https://vislearn.github.io/ControlNet-XS/): | ||
|
|
||
| *With increasing computing capabilities, current model architectures appear to follow the trend of simply upscaling all components without validating the necessity for doing so. In this project we investigate the size and architectural design of ControlNet [Zhang et al., 2023] for controlling the image generation process with stable diffusion-based models. We show that a new architecture with as little as 1% of the parameters of the base model achieves state-of-the art results, considerably better than ControlNet in terms of FID score. Hence we call it ControlNet-XS. We provide the code for controlling StableDiffusion-XL [Podell et al., 2023] (Model B, 48M Parameters) and StableDiffusion 2.1 [Rombach et al. 2022] (Model B, 14M Parameters), all under openrail license.* | ||
|
|
||
| This model was contributed by [UmerHA](https://twitter.com/UmerHAdil). ❤️ | ||
|
|
||
| <Tip> | ||
|
|
||
| Make sure to check out the Schedulers [guide](../../using-diffusers/schedulers) to learn how to explore the tradeoff between scheduler speed and quality, and see the [reuse components across pipelines](../../using-diffusers/loading#reuse-components-across-pipelines) section to learn how to efficiently load the same components into multiple pipelines. | ||
|
|
||
| </Tip> | ||
|
|
||
| ## StableDiffusionControlNetXSPipeline | ||
| [[autodoc]] StableDiffusionControlNetXSPipeline | ||
| - all | ||
| - __call__ | ||
|
|
||
| ## StableDiffusionPipelineOutput | ||
| [[autodoc]] pipelines.stable_diffusion.StableDiffusionPipelineOutput |
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,45 @@ | ||
| <!--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. | ||
| --> | ||
|
|
||
| # ControlNet-XS with Stable Diffusion XL | ||
|
|
||
| ControlNet-XS was introduced in [ControlNet-XS](https://vislearn.github.io/ControlNet-XS/) by Denis Zavadski and Carsten Rother. It is based on the observation that the control model in the [original ControlNet](https://huggingface.co/papers/2302.05543) can be made much smaller and still produce good results. | ||
|
|
||
| Like the original ControlNet model, you can provide an additional control image to condition and control Stable Diffusion generation. For example, if you provide a depth map, the ControlNet model generates an image that'll preserve the spatial information from the depth map. It is a more flexible and accurate way to control the image generation process. | ||
|
|
||
| ControlNet-XS generates images with comparable quality to a regular ControlNet, but it is 20-25% faster ([see benchmark](https://github.com/UmerHA/controlnet-xs-benchmark/blob/main/Speed%20Benchmark.ipynb)) and uses ~45% less memory. | ||
|
|
||
| Here's the overview from the [project page](https://vislearn.github.io/ControlNet-XS/): | ||
|
|
||
| *With increasing computing capabilities, current model architectures appear to follow the trend of simply upscaling all components without validating the necessity for doing so. In this project we investigate the size and architectural design of ControlNet [Zhang et al., 2023] for controlling the image generation process with stable diffusion-based models. We show that a new architecture with as little as 1% of the parameters of the base model achieves state-of-the art results, considerably better than ControlNet in terms of FID score. Hence we call it ControlNet-XS. We provide the code for controlling StableDiffusion-XL [Podell et al., 2023] (Model B, 48M Parameters) and StableDiffusion 2.1 [Rombach et al. 2022] (Model B, 14M Parameters), all under openrail license.* | ||
|
|
||
| This model was contributed by [UmerHA](https://twitter.com/UmerHAdil). ❤️ | ||
|
|
||
| <Tip warning={true}> | ||
|
|
||
| 🧪 Many of the SDXL ControlNet checkpoints are experimental, and there is a lot of room for improvement. Feel free to open an [Issue](https://github.com/huggingface/diffusers/issues/new/choose) and leave us feedback on how we can improve! | ||
|
|
||
| </Tip> | ||
|
|
||
| <Tip> | ||
|
|
||
| Make sure to check out the Schedulers [guide](../../using-diffusers/schedulers) to learn how to explore the tradeoff between scheduler speed and quality, and see the [reuse components across pipelines](../../using-diffusers/loading#reuse-components-across-pipelines) section to learn how to efficiently load the same components into multiple pipelines. | ||
|
|
||
| </Tip> | ||
|
|
||
| ## StableDiffusionXLControlNetXSPipeline | ||
| [[autodoc]] StableDiffusionXLControlNetXSPipeline | ||
| - all | ||
| - __call__ | ||
|
|
||
| ## StableDiffusionPipelineOutput | ||
| [[autodoc]] pipelines.stable_diffusion.StableDiffusionPipelineOutput | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.