├── .github ├── ISSUE_TEMPLATE │ └── bug_report.yml └── workflows │ ├── lint.yaml │ └── publish_action.yaml ├── .gitignore ├── LICENSE ├── README.md ├── __init__.py ├── example_workflows ├── layer_diffusion_cond_example.json ├── layer_diffusion_cond_fg_all.json ├── layer_diffusion_cond_joint_bg.json ├── layer_diffusion_cond_joint_fg.json ├── layer_diffusion_diff_bg.json ├── layer_diffusion_diff_bg_stop_at.json ├── layer_diffusion_diff_fg.json ├── layer_diffusion_fg_example.json ├── layer_diffusion_fg_example_rgba.json └── layer_diffusion_joint.json ├── layered_diffusion.py ├── lib_layerdiffusion ├── __init__.py ├── attention_sharing.py ├── enums.py ├── models.py └── utils.py ├── locales ├── en │ ├── main.json │ └── nodeDefs.json ├── fr │ ├── main.json │ └── nodeDefs.json ├── ja │ ├── main.json │ └── nodeDefs.json ├── ko │ ├── main.json │ └── nodeDefs.json ├── ru │ ├── main.json │ └── nodeDefs.json └── zh │ ├── main.json │ └── nodeDefs.json ├── pyproject.toml └── requirements.txt /.github/ISSUE_TEMPLATE/bug_report.yml: -------------------------------------------------------------------------------- 1 | name: Bug Report 2 | description: You think something is broken in the UI 3 | title: "[Bug]: " 4 | labels: ["bug-report"] 5 | 6 | body: 7 | - type: markdown 8 | attributes: 9 | value: | 10 | > The title of the bug report should be short and descriptive. 11 | > Use relevant keywords for searchability. 12 | > Do not leave it blank, but also do not put an entire error log in it. 13 | - type: textarea 14 | id: what-did 15 | attributes: 16 | label: What happened? 17 | description: Tell us what happened in a very clear and simple way 18 | placeholder: | 19 | txt2img is not working as intended. 20 | validations: 21 | required: true 22 | - type: textarea 23 | id: steps 24 | attributes: 25 | label: Steps to reproduce the problem 26 | description: Please provide us with precise step by step instructions on how to reproduce the bug 27 | placeholder: | 28 | 1. Go to ... 29 | 2. Press ... 30 | 3. ... 31 | validations: 32 | required: true 33 | - type: textarea 34 | id: what-should 35 | attributes: 36 | label: What should have happened? 37 | description: Tell us what you think the normal behavior should be 38 | placeholder: | 39 | ComfyUI should ... 40 | validations: 41 | required: true 42 | - type: textarea 43 | id: commits 44 | attributes: 45 | label: Commit where the problem happens 46 | description: Which commit of the extension are you running on? Please include the commit of both the extension and the ComfyUI (Do not write *Latest version/repo/commit*, as this means nothing and will have changed by the time we read your issue. Rather, copy the **Commit** link at the bottom of the UI, or from the cmd/terminal if you can't launch it.) 47 | value: | 48 | ComfyUI: 49 | ComfyUI-layerdiffuse: 50 | validations: 51 | required: true 52 | - type: textarea 53 | id: sysinfo 54 | attributes: 55 | label: Sysinfo 56 | description: The system information 57 | placeholder: | 58 | OS: 59 | Graphics Card: Nvidia/AMD/Intel 60 | validations: 61 | required: true 62 | - type: textarea 63 | id: logs 64 | attributes: 65 | label: Console logs 66 | description: Please provide **full** cmd/terminal logs from the moment you started UI to the end of it, after the bug occured. If it's very long, provide a link to pastebin or similar service. 67 | render: Shell 68 | validations: 69 | required: true 70 | - type: textarea 71 | id: workflow 72 | attributes: 73 | label: Workflow json file 74 | description: Please provide the minimal workflow json file to reproduce the issue. 75 | validations: 76 | required: true 77 | - type: textarea 78 | id: misc 79 | attributes: 80 | label: Additional information 81 | description: | 82 | Please provide us with any relevant additional info or context. 83 | Examples: 84 |  I have updated my GPU driver recently. 85 | -------------------------------------------------------------------------------- /.github/workflows/lint.yaml: -------------------------------------------------------------------------------- 1 | name: Linter 2 | 3 | on: 4 | - push 5 | - pull_request 6 | 7 | jobs: 8 | lint-python: 9 | name: ruff 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Checkout Code 13 | uses: actions/checkout@v3 14 | - uses: actions/setup-python@v4 15 | with: 16 | python-version: 3.11 17 | # NB: there's no cache: pip here since we're not installing anything 18 | # from the requirements.txt file(s) in the repository; it's faster 19 | # not to have GHA download an (at the time of writing) 4 GB cache 20 | # of PyTorch and other dependencies. 21 | - name: Install Ruff 22 | run: pip install ruff==0.1.6 23 | - name: Run Ruff 24 | run: ruff . -------------------------------------------------------------------------------- /.github/workflows/publish_action.yaml: -------------------------------------------------------------------------------- 1 | name: Publish to Comfy registry 2 | on: 3 | workflow_dispatch: 4 | push: 5 | branches: 6 | - main 7 | paths: 8 | - "pyproject.toml" 9 | 10 | permissions: 11 | issues: write 12 | 13 | jobs: 14 | publish-node: 15 | name: Publish Custom Node to registry 16 | runs-on: ubuntu-latest 17 | if: ${{ github.repository_owner == 'huchenlei' }} 18 | steps: 19 | - name: Check out code 20 | uses: actions/checkout@v4 21 | - name: Publish Custom Node 22 | uses: Comfy-Org/publish-node-action@v1 23 | with: 24 | personal_access_token: ${{ secrets.REGISTRY_ACCESS_TOKEN }} ## Add your own personal access token to your Github secrets and reference it here. 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # poetry 98 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 99 | # This is especially recommended for binary packages to ensure reproducibility, and is more 100 | # commonly ignored for libraries. 101 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 102 | #poetry.lock 103 | 104 | # pdm 105 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 106 | #pdm.lock 107 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 108 | # in version control. 109 | # https://pdm.fming.dev/#use-with-ide 110 | .pdm.toml 111 | 112 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 113 | __pypackages__/ 114 | 115 | # Celery stuff 116 | celerybeat-schedule 117 | celerybeat.pid 118 | 119 | # SageMath parsed files 120 | *.sage.py 121 | 122 | # Environments 123 | .env 124 | .venv 125 | env/ 126 | venv/ 127 | ENV/ 128 | env.bak/ 129 | venv.bak/ 130 | 131 | # Spyder project settings 132 | .spyderproject 133 | .spyproject 134 | 135 | # Rope project settings 136 | .ropeproject 137 | 138 | # mkdocs documentation 139 | /site 140 | 141 | # mypy 142 | .mypy_cache/ 143 | .dmypy.json 144 | dmypy.json 145 | 146 | # Pyre type checker 147 | .pyre/ 148 | 149 | # pytype static type analyzer 150 | .pytype/ 151 | 152 | # Cython debug symbols 153 | cython_debug/ 154 | 155 | # PyCharm 156 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 157 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 158 | # and can be added to the global gitignore or merged into this file. For a more nuclear 159 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 160 | .idea/ 161 | .vscode/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ComfyUI-layerdiffuse 2 | ComfyUI implementation of https://github.com/layerdiffusion/LayerDiffuse. 3 | 4 | ## Installation 5 | Download the repository and unpack it into the custom_nodes folder in the ComfyUI installation directory. 6 | 7 | Or clone via GIT, starting from ComfyUI installation directory: 8 | ```bash 9 | cd custom_nodes 10 | git clone git@github.com:huchenlei/ComfyUI-layerdiffuse.git 11 | ``` 12 | 13 | Run `pip install -r requirements.txt` to install python dependencies. You might experience version conflict on diffusers if you have other extensions that depend on other versions of diffusers. In this case, it is recommended to set up separate Python venvs. 14 | 15 | ## Workflows 16 | ### [Generate foreground](https://github.com/huchenlei/ComfyUI-layerdiffuse/blob/main/example_workflows/layer_diffusion_fg_example_rgba.json) 17 | ![rgba](https://github.com/huchenlei/ComfyUI-layerdiffuse/assets/20929282/5e6085e5-d997-4a0a-b589-257d65eb1eb2) 18 | 19 | ### [Generate foreground (RGB + alpha)](https://github.com/huchenlei/ComfyUI-layerdiffuse/blob/main/example_workflows/layer_diffusion_fg_example.json) 20 | If you want more control of getting RGB images and alpha channel mask separately, you can use this workflow. 21 | ![readme1](https://github.com/huchenlei/ComfyUI-layerdiffuse/assets/20929282/4825b81c-7089-4806-bce7-777229421707) 22 | 23 | ### [Blending (FG/BG)](https://github.com/huchenlei/ComfyUI-layerdiffuse/blob/main/example_workflows/layer_diffusion_cond_example.json) 24 | Blending given FG 25 | ![fg_cond](https://github.com/huchenlei/ComfyUI-layerdiffuse/assets/20929282/7f7dee80-6e57-4570-b304-d1f7e5dc3aad) 26 | 27 | Blending given BG 28 | ![bg_cond](https://github.com/huchenlei/ComfyUI-layerdiffuse/assets/20929282/e3a79218-6123-453b-a54b-2f338db1c12d) 29 | 30 | ### [Extract FG from Blended + BG](https://github.com/huchenlei/ComfyUI-layerdiffuse/blob/main/example_workflows/layer_diffusion_diff_fg.json) 31 | ![diff_bg](https://github.com/huchenlei/ComfyUI-layerdiffuse/assets/20929282/45c7207d-72ff-4fb0-9c91-687040781837) 32 | 33 | ### [Extract BG from Blended + FG](https://github.com/huchenlei/ComfyUI-layerdiffuse/blob/main/example_workflows/layer_diffusion_diff_bg.json) 34 | [Forge impl's sanity check](https://github.com/layerdiffuse/sd-forge-layerdiffuse#sanity-check) sets `Stop at` to 0.5 to get better quality BG. 35 | This workflow might be inferior compared to other object removal workflows. 36 | ![diff_fg](https://github.com/huchenlei/ComfyUI-layerdiffuse/assets/20929282/05a10add-68b0-473a-acee-5853e4720322) 37 | 38 | ### [Extract BG from Blended + FG (Stop at 0.5)](https://github.com/huchenlei/ComfyUI-layerdiffuse/blob/main/example_workflows/layer_diffusion_diff_bg_stop_at.json) 39 | In [SD Forge impl](https://github.com/layerdiffuse/sd-forge-layerdiffuse), there is a `stop at` param that determines when 40 | layer diffuse should stop in the denoising process. In the background, what this param does is unapply the LoRA and c_concat cond after a certain step 41 | threshold. This is hard/risky to implement directly in ComfyUI as it requires manually loading a model that has every change except the layer diffusion 42 | change applied. A workaround in ComfyUI is to have another img2img pass on the layer diffuse result to simulate the effect of `stop at` param. 43 | ![diff_fg_stop_at](https://github.com/huchenlei/ComfyUI-layerdiffuse/assets/20929282/e383c9d3-2d47-40c2-b764-b0bd48243ee8) 44 | 45 | 46 | ### [Generate FG from BG combined](https://github.com/huchenlei/ComfyUI-layerdiffuse/blob/main/example_workflows/layer_diffusion_cond_fg_all.json) 47 | Combines previous workflows to generate blended and FG given BG. We found that there are some color variations in the extracted FG. Need to confirm 48 | with layer diffusion authors whether this is expected. 49 | ![fg_all](https://github.com/huchenlei/ComfyUI-layerdiffuse/assets/20929282/f4c18585-961a-473a-a616-aa3776bacd41) 50 | 51 | ### [2024-3-9] [Generate FG + Blended given BG](https://github.com/huchenlei/ComfyUI-layerdiffuse/blob/main/example_workflows/layer_diffusion_cond_joint_bg.json) 52 | Need batch size = 2N. Currently only for SD15. 53 | ![sd15_cond_joint_bg](https://github.com/huchenlei/ComfyUI-layerdiffuse/assets/20929282/9bbfe5c1-14a0-421d-bf06-85e301bf8065) 54 | 55 | ### [2024-3-9] [Generate BG + Blended given FG](https://github.com/huchenlei/ComfyUI-layerdiffuse/blob/main/example_workflows/layer_diffusion_cond_joint_fg.json) 56 | Need batch size = 2N. Currently only for SD15. 57 | ![sd15_cond_joint_fg](https://github.com/huchenlei/ComfyUI-layerdiffuse/assets/20929282/65af8b38-cf4c-4667-b76f-3013a0be0a48) 58 | 59 | ### [2024-3-9] [Generate BG + FG + Blended together](https://github.com/huchenlei/ComfyUI-layerdiffuse/blob/main/example_workflows/layer_diffusion_joint.json) 60 | Need batch size = 3N. Currently only for SD15. 61 | ![sd15_joint](https://github.com/huchenlei/ComfyUI-layerdiffuse/assets/20929282/e5545809-e3fb-4683-acf5-8728195cb2bc) 62 | 63 | ## Note 64 | - Currently only SDXL/SD15 are supported. See https://github.com/layerdiffuse/sd-forge-layerdiffuse#model-notes for more details. 65 | - To decode RGBA result, the generation dimension must be multiple of 64. Otherwise, you will get decode error: ![image](https://github.com/huchenlei/ComfyUI-layerdiffuse/assets/20929282/ff055f99-9297-4ff1-9a33-065aaadcf98e) 66 | -------------------------------------------------------------------------------- /__init__.py: -------------------------------------------------------------------------------- 1 | from .layered_diffusion import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS 2 | 3 | __all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS'] -------------------------------------------------------------------------------- /example_workflows/layer_diffusion_cond_example.json: -------------------------------------------------------------------------------- 1 | { 2 | "last_node_id": 35, 3 | "last_link_id": 52, 4 | "nodes": [ 5 | { 6 | "id": 4, 7 | "type": "CheckpointLoaderSimple", 8 | "pos": [ 9 | 5, 10 | 479 11 | ], 12 | "size": { 13 | "0": 315, 14 | "1": 98 15 | }, 16 | "flags": {}, 17 | "order": 0, 18 | "mode": 0, 19 | "outputs": [ 20 | { 21 | "name": "MODEL", 22 | "type": "MODEL", 23 | "links": [ 24 | 38 25 | ], 26 | "slot_index": 0 27 | }, 28 | { 29 | "name": "CLIP", 30 | "type": "CLIP", 31 | "links": [ 32 | 3, 33 | 5 34 | ], 35 | "slot_index": 1 36 | }, 37 | { 38 | "name": "VAE", 39 | "type": "VAE", 40 | "links": [ 41 | 22, 42 | 49 43 | ], 44 | "slot_index": 2 45 | } 46 | ], 47 | "properties": { 48 | "Node name for S&R": "CheckpointLoaderSimple" 49 | }, 50 | "widgets_values": [ 51 | "juggernautXL_v8Rundiffusion.safetensors" 52 | ] 53 | }, 54 | { 55 | "id": 29, 56 | "type": "VAEEncode", 57 | "pos": [ 58 | 212, 59 | -22 60 | ], 61 | "size": { 62 | "0": 210, 63 | "1": 46 64 | }, 65 | "flags": {}, 66 | "order": 6, 67 | "mode": 0, 68 | "inputs": [ 69 | { 70 | "name": "pixels", 71 | "type": "IMAGE", 72 | "link": 51 73 | }, 74 | { 75 | "name": "vae", 76 | "type": "VAE", 77 | "link": 49, 78 | "slot_index": 1 79 | } 80 | ], 81 | "outputs": [ 82 | { 83 | "name": "LATENT", 84 | "type": "LATENT", 85 | "links": [ 86 | 47 87 | ], 88 | "shape": 3, 89 | "slot_index": 0 90 | } 91 | ], 92 | "properties": { 93 | "Node name for S&R": "VAEEncode" 94 | } 95 | }, 96 | { 97 | "id": 30, 98 | "type": "LoadImage", 99 | "pos": [ 100 | -363, 101 | 209 102 | ], 103 | "size": { 104 | "0": 315, 105 | "1": 314 106 | }, 107 | "flags": {}, 108 | "order": 1, 109 | "mode": 0, 110 | "outputs": [ 111 | { 112 | "name": "IMAGE", 113 | "type": "IMAGE", 114 | "links": [ 115 | 50 116 | ], 117 | "shape": 3, 118 | "slot_index": 0 119 | }, 120 | { 121 | "name": "MASK", 122 | "type": "MASK", 123 | "links": null, 124 | "shape": 3 125 | } 126 | ], 127 | "properties": { 128 | "Node name for S&R": "LoadImage" 129 | }, 130 | "widgets_values": [ 131 | "309219693-e7e2d80e-ffbe-4724-812a-5139a88027e3.png", 132 | "image" 133 | ] 134 | }, 135 | { 136 | "id": 20, 137 | "type": "PreviewImage", 138 | "pos": [ 139 | 1556, 140 | 138 141 | ], 142 | "size": { 143 | "0": 611.2340087890625, 144 | "1": 633.9354858398438 145 | }, 146 | "flags": {}, 147 | "order": 11, 148 | "mode": 0, 149 | "inputs": [ 150 | { 151 | "name": "images", 152 | "type": "IMAGE", 153 | "link": 29 154 | } 155 | ], 156 | "properties": { 157 | "Node name for S&R": "PreviewImage" 158 | } 159 | }, 160 | { 161 | "id": 6, 162 | "type": "CLIPTextEncode", 163 | "pos": [ 164 | 415, 165 | 186 166 | ], 167 | "size": { 168 | "0": 422.84503173828125, 169 | "1": 164.31304931640625 170 | }, 171 | "flags": {}, 172 | "order": 3, 173 | "mode": 0, 174 | "inputs": [ 175 | { 176 | "name": "clip", 177 | "type": "CLIP", 178 | "link": 3 179 | } 180 | ], 181 | "outputs": [ 182 | { 183 | "name": "CONDITIONING", 184 | "type": "CONDITIONING", 185 | "links": [ 186 | 39 187 | ], 188 | "slot_index": 0 189 | } 190 | ], 191 | "properties": { 192 | "Node name for S&R": "CLIPTextEncode" 193 | }, 194 | "widgets_values": [ 195 | "old man sitting, high quality\n\n" 196 | ] 197 | }, 198 | { 199 | "id": 7, 200 | "type": "CLIPTextEncode", 201 | "pos": [ 202 | 413, 203 | 389 204 | ], 205 | "size": { 206 | "0": 425.27801513671875, 207 | "1": 180.6060791015625 208 | }, 209 | "flags": {}, 210 | "order": 4, 211 | "mode": 0, 212 | "inputs": [ 213 | { 214 | "name": "clip", 215 | "type": "CLIP", 216 | "link": 5 217 | } 218 | ], 219 | "outputs": [ 220 | { 221 | "name": "CONDITIONING", 222 | "type": "CONDITIONING", 223 | "links": [ 224 | 40 225 | ], 226 | "slot_index": 0 227 | } 228 | ], 229 | "properties": { 230 | "Node name for S&R": "CLIPTextEncode" 231 | }, 232 | "widgets_values": [ 233 | "text, watermark" 234 | ] 235 | }, 236 | { 237 | "id": 34, 238 | "type": "PreviewImage", 239 | "pos": [ 240 | 213, 241 | -346 242 | ], 243 | "size": { 244 | "0": 210, 245 | "1": 246 246 | }, 247 | "flags": {}, 248 | "order": 7, 249 | "mode": 0, 250 | "inputs": [ 251 | { 252 | "name": "images", 253 | "type": "IMAGE", 254 | "link": 52 255 | } 256 | ], 257 | "properties": { 258 | "Node name for S&R": "PreviewImage" 259 | } 260 | }, 261 | { 262 | "id": 14, 263 | "type": "VAEDecode", 264 | "pos": [ 265 | 1275, 266 | 198 267 | ], 268 | "size": { 269 | "0": 210, 270 | "1": 46 271 | }, 272 | "flags": {}, 273 | "order": 10, 274 | "mode": 0, 275 | "inputs": [ 276 | { 277 | "name": "samples", 278 | "type": "LATENT", 279 | "link": 21 280 | }, 281 | { 282 | "name": "vae", 283 | "type": "VAE", 284 | "link": 22, 285 | "slot_index": 1 286 | } 287 | ], 288 | "outputs": [ 289 | { 290 | "name": "IMAGE", 291 | "type": "IMAGE", 292 | "links": [ 293 | 29 294 | ], 295 | "shape": 3, 296 | "slot_index": 0 297 | } 298 | ], 299 | "properties": { 300 | "Node name for S&R": "VAEDecode" 301 | } 302 | }, 303 | { 304 | "id": 3, 305 | "type": "KSampler", 306 | "pos": [ 307 | 913, 308 | 181 309 | ], 310 | "size": { 311 | "0": 315, 312 | "1": 262 313 | }, 314 | "flags": {}, 315 | "order": 9, 316 | "mode": 0, 317 | "inputs": [ 318 | { 319 | "name": "model", 320 | "type": "MODEL", 321 | "link": 41 322 | }, 323 | { 324 | "name": "positive", 325 | "type": "CONDITIONING", 326 | "link": 46 327 | }, 328 | { 329 | "name": "negative", 330 | "type": "CONDITIONING", 331 | "link": 45 332 | }, 333 | { 334 | "name": "latent_image", 335 | "type": "LATENT", 336 | "link": 2 337 | } 338 | ], 339 | "outputs": [ 340 | { 341 | "name": "LATENT", 342 | "type": "LATENT", 343 | "links": [ 344 | 21 345 | ], 346 | "slot_index": 0 347 | } 348 | ], 349 | "properties": { 350 | "Node name for S&R": "KSampler" 351 | }, 352 | "widgets_values": [ 353 | 100676796092754, 354 | "randomize", 355 | 20, 356 | 8, 357 | "euler", 358 | "normal", 359 | 1 360 | ] 361 | }, 362 | { 363 | "id": 5, 364 | "type": "EmptyLatentImage", 365 | "pos": [ 366 | 475, 367 | 666 368 | ], 369 | "size": { 370 | "0": 315, 371 | "1": 106 372 | }, 373 | "flags": {}, 374 | "order": 2, 375 | "mode": 0, 376 | "outputs": [ 377 | { 378 | "name": "LATENT", 379 | "type": "LATENT", 380 | "links": [ 381 | 2 382 | ], 383 | "slot_index": 0 384 | } 385 | ], 386 | "properties": { 387 | "Node name for S&R": "EmptyLatentImage" 388 | }, 389 | "widgets_values": [ 390 | 1024, 391 | 1024, 392 | 1 393 | ] 394 | }, 395 | { 396 | "id": 33, 397 | "type": "ImageResize+", 398 | "pos": [ 399 | -146, 400 | -16 401 | ], 402 | "size": { 403 | "0": 315, 404 | "1": 170 405 | }, 406 | "flags": {}, 407 | "order": 5, 408 | "mode": 0, 409 | "inputs": [ 410 | { 411 | "name": "image", 412 | "type": "IMAGE", 413 | "link": 50 414 | } 415 | ], 416 | "outputs": [ 417 | { 418 | "name": "IMAGE", 419 | "type": "IMAGE", 420 | "links": [ 421 | 51, 422 | 52 423 | ], 424 | "shape": 3, 425 | "slot_index": 0 426 | }, 427 | { 428 | "name": "width", 429 | "type": "INT", 430 | "links": null, 431 | "shape": 3 432 | }, 433 | { 434 | "name": "height", 435 | "type": "INT", 436 | "links": null, 437 | "shape": 3 438 | } 439 | ], 440 | "properties": { 441 | "Node name for S&R": "ImageResize+" 442 | }, 443 | "widgets_values": [ 444 | 1024, 445 | 1024, 446 | "nearest", 447 | false 448 | ] 449 | }, 450 | { 451 | "id": 28, 452 | "type": "LayeredDiffusionCondApply", 453 | "pos": [ 454 | 465, 455 | -26 456 | ], 457 | "size": { 458 | "0": 315, 459 | "1": 142 460 | }, 461 | "flags": {}, 462 | "order": 8, 463 | "mode": 0, 464 | "inputs": [ 465 | { 466 | "name": "model", 467 | "type": "MODEL", 468 | "link": 38 469 | }, 470 | { 471 | "name": "cond", 472 | "type": "CONDITIONING", 473 | "link": 39 474 | }, 475 | { 476 | "name": "uncond", 477 | "type": "CONDITIONING", 478 | "link": 40 479 | }, 480 | { 481 | "name": "latent", 482 | "type": "LATENT", 483 | "link": 47 484 | } 485 | ], 486 | "outputs": [ 487 | { 488 | "name": "MODEL", 489 | "type": "MODEL", 490 | "links": [ 491 | 41 492 | ], 493 | "shape": 3, 494 | "slot_index": 0 495 | }, 496 | { 497 | "name": "CONDITIONING", 498 | "type": "CONDITIONING", 499 | "links": [ 500 | 46 501 | ], 502 | "shape": 3, 503 | "slot_index": 1 504 | }, 505 | { 506 | "name": "CONDITIONING", 507 | "type": "CONDITIONING", 508 | "links": [ 509 | 45 510 | ], 511 | "shape": 3, 512 | "slot_index": 2 513 | } 514 | ], 515 | "properties": { 516 | "Node name for S&R": "LayeredDiffusionCondApply" 517 | }, 518 | "widgets_values": [ 519 | "SDXL, Background", 520 | 1 521 | ], 522 | "color": "#232", 523 | "bgcolor": "#353" 524 | } 525 | ], 526 | "links": [ 527 | [ 528 | 2, 529 | 5, 530 | 0, 531 | 3, 532 | 3, 533 | "LATENT" 534 | ], 535 | [ 536 | 3, 537 | 4, 538 | 1, 539 | 6, 540 | 0, 541 | "CLIP" 542 | ], 543 | [ 544 | 5, 545 | 4, 546 | 1, 547 | 7, 548 | 0, 549 | "CLIP" 550 | ], 551 | [ 552 | 21, 553 | 3, 554 | 0, 555 | 14, 556 | 0, 557 | "LATENT" 558 | ], 559 | [ 560 | 22, 561 | 4, 562 | 2, 563 | 14, 564 | 1, 565 | "VAE" 566 | ], 567 | [ 568 | 29, 569 | 14, 570 | 0, 571 | 20, 572 | 0, 573 | "IMAGE" 574 | ], 575 | [ 576 | 38, 577 | 4, 578 | 0, 579 | 28, 580 | 0, 581 | "MODEL" 582 | ], 583 | [ 584 | 39, 585 | 6, 586 | 0, 587 | 28, 588 | 1, 589 | "CONDITIONING" 590 | ], 591 | [ 592 | 40, 593 | 7, 594 | 0, 595 | 28, 596 | 2, 597 | "CONDITIONING" 598 | ], 599 | [ 600 | 41, 601 | 28, 602 | 0, 603 | 3, 604 | 0, 605 | "MODEL" 606 | ], 607 | [ 608 | 45, 609 | 28, 610 | 2, 611 | 3, 612 | 2, 613 | "CONDITIONING" 614 | ], 615 | [ 616 | 46, 617 | 28, 618 | 1, 619 | 3, 620 | 1, 621 | "CONDITIONING" 622 | ], 623 | [ 624 | 47, 625 | 29, 626 | 0, 627 | 28, 628 | 3, 629 | "LATENT" 630 | ], 631 | [ 632 | 49, 633 | 4, 634 | 2, 635 | 29, 636 | 1, 637 | "VAE" 638 | ], 639 | [ 640 | 50, 641 | 30, 642 | 0, 643 | 33, 644 | 0, 645 | "IMAGE" 646 | ], 647 | [ 648 | 51, 649 | 33, 650 | 0, 651 | 29, 652 | 0, 653 | "IMAGE" 654 | ], 655 | [ 656 | 52, 657 | 33, 658 | 0, 659 | 34, 660 | 0, 661 | "IMAGE" 662 | ] 663 | ], 664 | "groups": [], 665 | "config": {}, 666 | "extra": {}, 667 | "version": 0.4 668 | } -------------------------------------------------------------------------------- /example_workflows/layer_diffusion_cond_fg_all.json: -------------------------------------------------------------------------------- 1 | { 2 | "last_node_id": 56, 3 | "last_link_id": 104, 4 | "nodes": [ 5 | { 6 | "id": 14, 7 | "type": "VAEDecode", 8 | "pos": [ 9 | 1286, 10 | 187 11 | ], 12 | "size": { 13 | "0": 210, 14 | "1": 46 15 | }, 16 | "flags": {}, 17 | "order": 12, 18 | "mode": 0, 19 | "inputs": [ 20 | { 21 | "name": "samples", 22 | "type": "LATENT", 23 | "link": 21 24 | }, 25 | { 26 | "name": "vae", 27 | "type": "VAE", 28 | "link": 22, 29 | "slot_index": 1 30 | } 31 | ], 32 | "outputs": [ 33 | { 34 | "name": "IMAGE", 35 | "type": "IMAGE", 36 | "links": [ 37 | 65 38 | ], 39 | "shape": 3, 40 | "slot_index": 0 41 | } 42 | ], 43 | "properties": { 44 | "Node name for S&R": "VAEDecode" 45 | } 46 | }, 47 | { 48 | "id": 40, 49 | "type": "LayeredDiffusionDecodeRGBA", 50 | "pos": [ 51 | 1533, 52 | 189 53 | ], 54 | "size": { 55 | "0": 243.60000610351562, 56 | "1": 102 57 | }, 58 | "flags": {}, 59 | "order": 13, 60 | "mode": 0, 61 | "inputs": [ 62 | { 63 | "name": "samples", 64 | "type": "LATENT", 65 | "link": 67 66 | }, 67 | { 68 | "name": "images", 69 | "type": "IMAGE", 70 | "link": 65 71 | } 72 | ], 73 | "outputs": [ 74 | { 75 | "name": "IMAGE", 76 | "type": "IMAGE", 77 | "links": [ 78 | 66 79 | ], 80 | "shape": 3, 81 | "slot_index": 0 82 | } 83 | ], 84 | "properties": { 85 | "Node name for S&R": "LayeredDiffusionDecodeRGBA" 86 | }, 87 | "widgets_values": [ 88 | "SDXL", 89 | 16 90 | ], 91 | "color": "#232", 92 | "bgcolor": "#353" 93 | }, 94 | { 95 | "id": 47, 96 | "type": "VAEDecode", 97 | "pos": [ 98 | 1360, 99 | 900 100 | ], 101 | "size": { 102 | "0": 210, 103 | "1": 46 104 | }, 105 | "flags": {}, 106 | "order": 8, 107 | "mode": 0, 108 | "inputs": [ 109 | { 110 | "name": "samples", 111 | "type": "LATENT", 112 | "link": 74 113 | }, 114 | { 115 | "name": "vae", 116 | "type": "VAE", 117 | "link": 104, 118 | "slot_index": 1 119 | } 120 | ], 121 | "outputs": [ 122 | { 123 | "name": "IMAGE", 124 | "type": "IMAGE", 125 | "links": [ 126 | 96 127 | ], 128 | "shape": 3, 129 | "slot_index": 0 130 | } 131 | ], 132 | "properties": { 133 | "Node name for S&R": "VAEDecode" 134 | } 135 | }, 136 | { 137 | "id": 49, 138 | "type": "VAEEncode", 139 | "pos": [ 140 | 280, 141 | 690 142 | ], 143 | "size": { 144 | "0": 210, 145 | "1": 46 146 | }, 147 | "flags": {}, 148 | "order": 5, 149 | "mode": 0, 150 | "inputs": [ 151 | { 152 | "name": "pixels", 153 | "type": "IMAGE", 154 | "link": 77 155 | }, 156 | { 157 | "name": "vae", 158 | "type": "VAE", 159 | "link": 102, 160 | "slot_index": 1 161 | } 162 | ], 163 | "outputs": [ 164 | { 165 | "name": "LATENT", 166 | "type": "LATENT", 167 | "links": [ 168 | 89, 169 | 97 170 | ], 171 | "shape": 3, 172 | "slot_index": 0 173 | } 174 | ], 175 | "properties": { 176 | "Node name for S&R": "VAEEncode" 177 | } 178 | }, 179 | { 180 | "id": 56, 181 | "type": "PreviewImage", 182 | "pos": [ 183 | 1800, 184 | 900 185 | ], 186 | "size": { 187 | "0": 611.2340087890625, 188 | "1": 633.9354858398438 189 | }, 190 | "flags": {}, 191 | "order": 10, 192 | "mode": 0, 193 | "inputs": [ 194 | { 195 | "name": "images", 196 | "type": "IMAGE", 197 | "link": 96 198 | } 199 | ], 200 | "properties": { 201 | "Node name for S&R": "PreviewImage" 202 | } 203 | }, 204 | { 205 | "id": 6, 206 | "type": "CLIPTextEncode", 207 | "pos": [ 208 | 415, 209 | 186 210 | ], 211 | "size": { 212 | "0": 422.84503173828125, 213 | "1": 164.31304931640625 214 | }, 215 | "flags": {}, 216 | "order": 3, 217 | "mode": 0, 218 | "inputs": [ 219 | { 220 | "name": "clip", 221 | "type": "CLIP", 222 | "link": 3 223 | } 224 | ], 225 | "outputs": [ 226 | { 227 | "name": "CONDITIONING", 228 | "type": "CONDITIONING", 229 | "links": [ 230 | 56, 231 | 99 232 | ], 233 | "slot_index": 0 234 | } 235 | ], 236 | "properties": { 237 | "Node name for S&R": "CLIPTextEncode" 238 | }, 239 | "widgets_values": [ 240 | "an old man sitting, high quality\n\n" 241 | ] 242 | }, 243 | { 244 | "id": 7, 245 | "type": "CLIPTextEncode", 246 | "pos": [ 247 | 413, 248 | 389 249 | ], 250 | "size": { 251 | "0": 425.27801513671875, 252 | "1": 180.6060791015625 253 | }, 254 | "flags": {}, 255 | "order": 4, 256 | "mode": 0, 257 | "inputs": [ 258 | { 259 | "name": "clip", 260 | "type": "CLIP", 261 | "link": 5 262 | } 263 | ], 264 | "outputs": [ 265 | { 266 | "name": "CONDITIONING", 267 | "type": "CONDITIONING", 268 | "links": [ 269 | 57, 270 | 100 271 | ], 272 | "slot_index": 0 273 | } 274 | ], 275 | "properties": { 276 | "Node name for S&R": "CLIPTextEncode" 277 | }, 278 | "widgets_values": [ 279 | "text, watermark" 280 | ] 281 | }, 282 | { 283 | "id": 42, 284 | "type": "KSampler", 285 | "pos": [ 286 | 990, 287 | 850 288 | ], 289 | "size": { 290 | "0": 315, 291 | "1": 262 292 | }, 293 | "flags": {}, 294 | "order": 7, 295 | "mode": 0, 296 | "inputs": [ 297 | { 298 | "name": "model", 299 | "type": "MODEL", 300 | "link": 93 301 | }, 302 | { 303 | "name": "positive", 304 | "type": "CONDITIONING", 305 | "link": 94 306 | }, 307 | { 308 | "name": "negative", 309 | "type": "CONDITIONING", 310 | "link": 95 311 | }, 312 | { 313 | "name": "latent_image", 314 | "type": "LATENT", 315 | "link": 71 316 | } 317 | ], 318 | "outputs": [ 319 | { 320 | "name": "LATENT", 321 | "type": "LATENT", 322 | "links": [ 323 | 74, 324 | 98 325 | ], 326 | "slot_index": 0 327 | } 328 | ], 329 | "properties": { 330 | "Node name for S&R": "KSampler" 331 | }, 332 | "widgets_values": [ 333 | 216474886443753, 334 | "randomize", 335 | 20, 336 | 8, 337 | "euler", 338 | "normal", 339 | 1 340 | ] 341 | }, 342 | { 343 | "id": 3, 344 | "type": "KSampler", 345 | "pos": [ 346 | 913, 347 | 182 348 | ], 349 | "size": { 350 | "0": 315, 351 | "1": 262 352 | }, 353 | "flags": {}, 354 | "order": 11, 355 | "mode": 0, 356 | "inputs": [ 357 | { 358 | "name": "model", 359 | "type": "MODEL", 360 | "link": 62 361 | }, 362 | { 363 | "name": "positive", 364 | "type": "CONDITIONING", 365 | "link": 63 366 | }, 367 | { 368 | "name": "negative", 369 | "type": "CONDITIONING", 370 | "link": 64 371 | }, 372 | { 373 | "name": "latent_image", 374 | "type": "LATENT", 375 | "link": 101, 376 | "slot_index": 3 377 | } 378 | ], 379 | "outputs": [ 380 | { 381 | "name": "LATENT", 382 | "type": "LATENT", 383 | "links": [ 384 | 21, 385 | 67 386 | ], 387 | "slot_index": 0 388 | } 389 | ], 390 | "properties": { 391 | "Node name for S&R": "KSampler" 392 | }, 393 | "widgets_values": [ 394 | 137168876920770, 395 | "randomize", 396 | 20, 397 | 8, 398 | "euler", 399 | "normal", 400 | 1 401 | ] 402 | }, 403 | { 404 | "id": 4, 405 | "type": "CheckpointLoaderSimple", 406 | "pos": [ 407 | -54, 408 | 488 409 | ], 410 | "size": { 411 | "0": 315, 412 | "1": 98 413 | }, 414 | "flags": {}, 415 | "order": 0, 416 | "mode": 0, 417 | "outputs": [ 418 | { 419 | "name": "MODEL", 420 | "type": "MODEL", 421 | "links": [ 422 | 55, 423 | 103 424 | ], 425 | "slot_index": 0 426 | }, 427 | { 428 | "name": "CLIP", 429 | "type": "CLIP", 430 | "links": [ 431 | 3, 432 | 5 433 | ], 434 | "slot_index": 1 435 | }, 436 | { 437 | "name": "VAE", 438 | "type": "VAE", 439 | "links": [ 440 | 22, 441 | 102, 442 | 104 443 | ], 444 | "slot_index": 2 445 | } 446 | ], 447 | "properties": { 448 | "Node name for S&R": "CheckpointLoaderSimple" 449 | }, 450 | "widgets_values": [ 451 | "juggernautXL_v8Rundiffusion.safetensors" 452 | ] 453 | }, 454 | { 455 | "id": 50, 456 | "type": "LoadImage", 457 | "pos": [ 458 | -59, 459 | 686 460 | ], 461 | "size": { 462 | "0": 315, 463 | "1": 314 464 | }, 465 | "flags": {}, 466 | "order": 1, 467 | "mode": 0, 468 | "outputs": [ 469 | { 470 | "name": "IMAGE", 471 | "type": "IMAGE", 472 | "links": [ 473 | 77 474 | ], 475 | "shape": 3, 476 | "slot_index": 0 477 | }, 478 | { 479 | "name": "MASK", 480 | "type": "MASK", 481 | "links": null, 482 | "shape": 3 483 | } 484 | ], 485 | "properties": { 486 | "Node name for S&R": "LoadImage" 487 | }, 488 | "widgets_values": [ 489 | "chair.png", 490 | "image" 491 | ] 492 | }, 493 | { 494 | "id": 44, 495 | "type": "EmptyLatentImage", 496 | "pos": [ 497 | 524, 498 | 944 499 | ], 500 | "size": { 501 | "0": 315, 502 | "1": 106 503 | }, 504 | "flags": {}, 505 | "order": 2, 506 | "mode": 0, 507 | "outputs": [ 508 | { 509 | "name": "LATENT", 510 | "type": "LATENT", 511 | "links": [ 512 | 71, 513 | 101 514 | ], 515 | "slot_index": 0 516 | } 517 | ], 518 | "properties": { 519 | "Node name for S&R": "EmptyLatentImage" 520 | }, 521 | "widgets_values": [ 522 | 1024, 523 | 1024, 524 | 1 525 | ] 526 | }, 527 | { 528 | "id": 55, 529 | "type": "LayeredDiffusionCondApply", 530 | "pos": [ 531 | 530, 532 | 680 533 | ], 534 | "size": { 535 | "0": 315, 536 | "1": 142 537 | }, 538 | "flags": {}, 539 | "order": 6, 540 | "mode": 0, 541 | "inputs": [ 542 | { 543 | "name": "model", 544 | "type": "MODEL", 545 | "link": 103, 546 | "slot_index": 0 547 | }, 548 | { 549 | "name": "cond", 550 | "type": "CONDITIONING", 551 | "link": 99 552 | }, 553 | { 554 | "name": "uncond", 555 | "type": "CONDITIONING", 556 | "link": 100 557 | }, 558 | { 559 | "name": "latent", 560 | "type": "LATENT", 561 | "link": 89, 562 | "slot_index": 3 563 | } 564 | ], 565 | "outputs": [ 566 | { 567 | "name": "MODEL", 568 | "type": "MODEL", 569 | "links": [ 570 | 93 571 | ], 572 | "shape": 3, 573 | "slot_index": 0 574 | }, 575 | { 576 | "name": "CONDITIONING", 577 | "type": "CONDITIONING", 578 | "links": [ 579 | 94 580 | ], 581 | "shape": 3, 582 | "slot_index": 1 583 | }, 584 | { 585 | "name": "CONDITIONING", 586 | "type": "CONDITIONING", 587 | "links": [ 588 | 95 589 | ], 590 | "shape": 3, 591 | "slot_index": 2 592 | } 593 | ], 594 | "properties": { 595 | "Node name for S&R": "LayeredDiffusionCondApply" 596 | }, 597 | "widgets_values": [ 598 | "SDXL, Background", 599 | 1 600 | ], 601 | "color": "#232", 602 | "bgcolor": "#353" 603 | }, 604 | { 605 | "id": 37, 606 | "type": "LayeredDiffusionDiffApply", 607 | "pos": [ 608 | 457, 609 | -37 610 | ], 611 | "size": { 612 | "0": 342.5999755859375, 613 | "1": 162 614 | }, 615 | "flags": {}, 616 | "order": 9, 617 | "mode": 0, 618 | "inputs": [ 619 | { 620 | "name": "model", 621 | "type": "MODEL", 622 | "link": 55, 623 | "slot_index": 0 624 | }, 625 | { 626 | "name": "cond", 627 | "type": "CONDITIONING", 628 | "link": 56, 629 | "slot_index": 1 630 | }, 631 | { 632 | "name": "uncond", 633 | "type": "CONDITIONING", 634 | "link": 57, 635 | "slot_index": 2 636 | }, 637 | { 638 | "name": "blended_latent", 639 | "type": "LATENT", 640 | "link": 98 641 | }, 642 | { 643 | "name": "latent", 644 | "type": "LATENT", 645 | "link": 97 646 | } 647 | ], 648 | "outputs": [ 649 | { 650 | "name": "MODEL", 651 | "type": "MODEL", 652 | "links": [ 653 | 62 654 | ], 655 | "shape": 3, 656 | "slot_index": 0 657 | }, 658 | { 659 | "name": "CONDITIONING", 660 | "type": "CONDITIONING", 661 | "links": [ 662 | 63 663 | ], 664 | "shape": 3, 665 | "slot_index": 1 666 | }, 667 | { 668 | "name": "CONDITIONING", 669 | "type": "CONDITIONING", 670 | "links": [ 671 | 64 672 | ], 673 | "shape": 3, 674 | "slot_index": 2 675 | } 676 | ], 677 | "properties": { 678 | "Node name for S&R": "LayeredDiffusionDiffApply" 679 | }, 680 | "widgets_values": [ 681 | "SDXL, Background", 682 | 1 683 | ], 684 | "color": "#232", 685 | "bgcolor": "#353" 686 | }, 687 | { 688 | "id": 20, 689 | "type": "PreviewImage", 690 | "pos": [ 691 | 1815, 692 | 194 693 | ], 694 | "size": { 695 | "0": 611.2340087890625, 696 | "1": 633.9354858398438 697 | }, 698 | "flags": {}, 699 | "order": 14, 700 | "mode": 0, 701 | "inputs": [ 702 | { 703 | "name": "images", 704 | "type": "IMAGE", 705 | "link": 66 706 | } 707 | ], 708 | "properties": { 709 | "Node name for S&R": "PreviewImage" 710 | } 711 | } 712 | ], 713 | "links": [ 714 | [ 715 | 3, 716 | 4, 717 | 1, 718 | 6, 719 | 0, 720 | "CLIP" 721 | ], 722 | [ 723 | 5, 724 | 4, 725 | 1, 726 | 7, 727 | 0, 728 | "CLIP" 729 | ], 730 | [ 731 | 21, 732 | 3, 733 | 0, 734 | 14, 735 | 0, 736 | "LATENT" 737 | ], 738 | [ 739 | 22, 740 | 4, 741 | 2, 742 | 14, 743 | 1, 744 | "VAE" 745 | ], 746 | [ 747 | 55, 748 | 4, 749 | 0, 750 | 37, 751 | 0, 752 | "MODEL" 753 | ], 754 | [ 755 | 56, 756 | 6, 757 | 0, 758 | 37, 759 | 1, 760 | "CONDITIONING" 761 | ], 762 | [ 763 | 57, 764 | 7, 765 | 0, 766 | 37, 767 | 2, 768 | "CONDITIONING" 769 | ], 770 | [ 771 | 62, 772 | 37, 773 | 0, 774 | 3, 775 | 0, 776 | "MODEL" 777 | ], 778 | [ 779 | 63, 780 | 37, 781 | 1, 782 | 3, 783 | 1, 784 | "CONDITIONING" 785 | ], 786 | [ 787 | 64, 788 | 37, 789 | 2, 790 | 3, 791 | 2, 792 | "CONDITIONING" 793 | ], 794 | [ 795 | 65, 796 | 14, 797 | 0, 798 | 40, 799 | 1, 800 | "IMAGE" 801 | ], 802 | [ 803 | 66, 804 | 40, 805 | 0, 806 | 20, 807 | 0, 808 | "IMAGE" 809 | ], 810 | [ 811 | 67, 812 | 3, 813 | 0, 814 | 40, 815 | 0, 816 | "LATENT" 817 | ], 818 | [ 819 | 71, 820 | 44, 821 | 0, 822 | 42, 823 | 3, 824 | "LATENT" 825 | ], 826 | [ 827 | 74, 828 | 42, 829 | 0, 830 | 47, 831 | 0, 832 | "LATENT" 833 | ], 834 | [ 835 | 77, 836 | 50, 837 | 0, 838 | 49, 839 | 0, 840 | "IMAGE" 841 | ], 842 | [ 843 | 89, 844 | 49, 845 | 0, 846 | 55, 847 | 3, 848 | "LATENT" 849 | ], 850 | [ 851 | 93, 852 | 55, 853 | 0, 854 | 42, 855 | 0, 856 | "MODEL" 857 | ], 858 | [ 859 | 94, 860 | 55, 861 | 1, 862 | 42, 863 | 1, 864 | "CONDITIONING" 865 | ], 866 | [ 867 | 95, 868 | 55, 869 | 2, 870 | 42, 871 | 2, 872 | "CONDITIONING" 873 | ], 874 | [ 875 | 96, 876 | 47, 877 | 0, 878 | 56, 879 | 0, 880 | "IMAGE" 881 | ], 882 | [ 883 | 97, 884 | 49, 885 | 0, 886 | 37, 887 | 4, 888 | "LATENT" 889 | ], 890 | [ 891 | 98, 892 | 42, 893 | 0, 894 | 37, 895 | 3, 896 | "LATENT" 897 | ], 898 | [ 899 | 99, 900 | 6, 901 | 0, 902 | 55, 903 | 1, 904 | "CONDITIONING" 905 | ], 906 | [ 907 | 100, 908 | 7, 909 | 0, 910 | 55, 911 | 2, 912 | "CONDITIONING" 913 | ], 914 | [ 915 | 101, 916 | 44, 917 | 0, 918 | 3, 919 | 3, 920 | "LATENT" 921 | ], 922 | [ 923 | 102, 924 | 4, 925 | 2, 926 | 49, 927 | 1, 928 | "VAE" 929 | ], 930 | [ 931 | 103, 932 | 4, 933 | 0, 934 | 55, 935 | 0, 936 | "MODEL" 937 | ], 938 | [ 939 | 104, 940 | 4, 941 | 2, 942 | 47, 943 | 1, 944 | "VAE" 945 | ] 946 | ], 947 | "groups": [], 948 | "config": {}, 949 | "extra": {}, 950 | "version": 0.4 951 | } -------------------------------------------------------------------------------- /example_workflows/layer_diffusion_cond_joint_bg.json: -------------------------------------------------------------------------------- 1 | { 2 | "last_node_id": 53, 3 | "last_link_id": 88, 4 | "nodes": [ 5 | { 6 | "id": 33, 7 | "type": "ImageResize+", 8 | "pos": [ 9 | 50, 10 | -10 11 | ], 12 | "size": { 13 | "0": 315, 14 | "1": 170 15 | }, 16 | "flags": {}, 17 | "order": 5, 18 | "mode": 0, 19 | "inputs": [ 20 | { 21 | "name": "image", 22 | "type": "IMAGE", 23 | "link": 50 24 | } 25 | ], 26 | "outputs": [ 27 | { 28 | "name": "IMAGE", 29 | "type": "IMAGE", 30 | "links": [ 31 | 52, 32 | 54 33 | ], 34 | "shape": 3, 35 | "slot_index": 0 36 | }, 37 | { 38 | "name": "width", 39 | "type": "INT", 40 | "links": null, 41 | "shape": 3 42 | }, 43 | { 44 | "name": "height", 45 | "type": "INT", 46 | "links": null, 47 | "shape": 3 48 | } 49 | ], 50 | "properties": { 51 | "Node name for S&R": "ImageResize+" 52 | }, 53 | "widgets_values": [ 54 | 512, 55 | 512, 56 | "nearest", 57 | false 58 | ] 59 | }, 60 | { 61 | "id": 6, 62 | "type": "CLIPTextEncode", 63 | "pos": [ 64 | 415, 65 | 186 66 | ], 67 | "size": { 68 | "0": 422.84503173828125, 69 | "1": 164.31304931640625 70 | }, 71 | "flags": {}, 72 | "order": 3, 73 | "mode": 0, 74 | "inputs": [ 75 | { 76 | "name": "clip", 77 | "type": "CLIP", 78 | "link": 3 79 | } 80 | ], 81 | "outputs": [ 82 | { 83 | "name": "CONDITIONING", 84 | "type": "CONDITIONING", 85 | "links": [ 86 | 64 87 | ], 88 | "slot_index": 0 89 | } 90 | ], 91 | "properties": { 92 | "Node name for S&R": "CLIPTextEncode" 93 | }, 94 | "widgets_values": [ 95 | "old man sitting, high quality\n\n" 96 | ] 97 | }, 98 | { 99 | "id": 7, 100 | "type": "CLIPTextEncode", 101 | "pos": [ 102 | 413, 103 | 389 104 | ], 105 | "size": { 106 | "0": 425.27801513671875, 107 | "1": 180.6060791015625 108 | }, 109 | "flags": {}, 110 | "order": 4, 111 | "mode": 0, 112 | "inputs": [ 113 | { 114 | "name": "clip", 115 | "type": "CLIP", 116 | "link": 5 117 | } 118 | ], 119 | "outputs": [ 120 | { 121 | "name": "CONDITIONING", 122 | "type": "CONDITIONING", 123 | "links": [ 124 | 65 125 | ], 126 | "slot_index": 0 127 | } 128 | ], 129 | "properties": { 130 | "Node name for S&R": "CLIPTextEncode" 131 | }, 132 | "widgets_values": [ 133 | "text, watermark" 134 | ] 135 | }, 136 | { 137 | "id": 3, 138 | "type": "KSampler", 139 | "pos": [ 140 | 915, 141 | 176 142 | ], 143 | "size": { 144 | "0": 315, 145 | "1": 262 146 | }, 147 | "flags": {}, 148 | "order": 8, 149 | "mode": 0, 150 | "inputs": [ 151 | { 152 | "name": "model", 153 | "type": "MODEL", 154 | "link": 56 155 | }, 156 | { 157 | "name": "positive", 158 | "type": "CONDITIONING", 159 | "link": 64 160 | }, 161 | { 162 | "name": "negative", 163 | "type": "CONDITIONING", 164 | "link": 65 165 | }, 166 | { 167 | "name": "latent_image", 168 | "type": "LATENT", 169 | "link": 2 170 | } 171 | ], 172 | "outputs": [ 173 | { 174 | "name": "LATENT", 175 | "type": "LATENT", 176 | "links": [ 177 | 70, 178 | 84 179 | ], 180 | "slot_index": 0 181 | } 182 | ], 183 | "properties": { 184 | "Node name for S&R": "KSampler" 185 | }, 186 | "widgets_values": [ 187 | 674865838825506, 188 | "randomize", 189 | 20, 190 | 8, 191 | "euler", 192 | "normal", 193 | 1 194 | ] 195 | }, 196 | { 197 | "id": 50, 198 | "type": "PreviewImage", 199 | "pos": [ 200 | 2040, 201 | -120 202 | ], 203 | "size": { 204 | "0": 210, 205 | "1": 246 206 | }, 207 | "flags": {}, 208 | "order": 12, 209 | "mode": 0, 210 | "inputs": [ 211 | { 212 | "name": "images", 213 | "type": "IMAGE", 214 | "link": 85 215 | } 216 | ], 217 | "properties": { 218 | "Node name for S&R": "PreviewImage" 219 | } 220 | }, 221 | { 222 | "id": 5, 223 | "type": "EmptyLatentImage", 224 | "pos": [ 225 | 475, 226 | 666 227 | ], 228 | "size": { 229 | "0": 315, 230 | "1": 106 231 | }, 232 | "flags": {}, 233 | "order": 0, 234 | "mode": 0, 235 | "outputs": [ 236 | { 237 | "name": "LATENT", 238 | "type": "LATENT", 239 | "links": [ 240 | 2 241 | ], 242 | "slot_index": 0 243 | } 244 | ], 245 | "properties": { 246 | "Node name for S&R": "EmptyLatentImage" 247 | }, 248 | "widgets_values": [ 249 | 512, 250 | 512, 251 | 4 252 | ] 253 | }, 254 | { 255 | "id": 44, 256 | "type": "VAEDecode", 257 | "pos": [ 258 | 1260, 259 | 180 260 | ], 261 | "size": { 262 | "0": 210, 263 | "1": 46 264 | }, 265 | "flags": {}, 266 | "order": 9, 267 | "mode": 0, 268 | "inputs": [ 269 | { 270 | "name": "samples", 271 | "type": "LATENT", 272 | "link": 70 273 | }, 274 | { 275 | "name": "vae", 276 | "type": "VAE", 277 | "link": 88, 278 | "slot_index": 1 279 | } 280 | ], 281 | "outputs": [ 282 | { 283 | "name": "IMAGE", 284 | "type": "IMAGE", 285 | "links": [ 286 | 75, 287 | 83 288 | ], 289 | "shape": 3, 290 | "slot_index": 0 291 | } 292 | ], 293 | "properties": { 294 | "Node name for S&R": "VAEDecode" 295 | } 296 | }, 297 | { 298 | "id": 4, 299 | "type": "CheckpointLoaderSimple", 300 | "pos": [ 301 | 5, 302 | 479 303 | ], 304 | "size": { 305 | "0": 315, 306 | "1": 98 307 | }, 308 | "flags": {}, 309 | "order": 1, 310 | "mode": 0, 311 | "outputs": [ 312 | { 313 | "name": "MODEL", 314 | "type": "MODEL", 315 | "links": [ 316 | 55 317 | ], 318 | "slot_index": 0 319 | }, 320 | { 321 | "name": "CLIP", 322 | "type": "CLIP", 323 | "links": [ 324 | 3, 325 | 5 326 | ], 327 | "slot_index": 1 328 | }, 329 | { 330 | "name": "VAE", 331 | "type": "VAE", 332 | "links": [ 333 | 88 334 | ], 335 | "slot_index": 2 336 | } 337 | ], 338 | "properties": { 339 | "Node name for S&R": "CheckpointLoaderSimple" 340 | }, 341 | "widgets_values": [ 342 | "realisticVisionV20_v20.safetensors" 343 | ] 344 | }, 345 | { 346 | "id": 46, 347 | "type": "PreviewImage", 348 | "pos": [ 349 | 1460, 350 | 410 351 | ], 352 | "size": [ 353 | 406.59525756835933, 354 | 340.5699157714844 355 | ], 356 | "flags": {}, 357 | "order": 10, 358 | "mode": 0, 359 | "inputs": [ 360 | { 361 | "name": "images", 362 | "type": "IMAGE", 363 | "link": 75 364 | } 365 | ], 366 | "properties": { 367 | "Node name for S&R": "PreviewImage" 368 | } 369 | }, 370 | { 371 | "id": 34, 372 | "type": "PreviewImage", 373 | "pos": [ 374 | 471, 375 | -337 376 | ], 377 | "size": { 378 | "0": 210, 379 | "1": 246 380 | }, 381 | "flags": {}, 382 | "order": 6, 383 | "mode": 0, 384 | "inputs": [ 385 | { 386 | "name": "images", 387 | "type": "IMAGE", 388 | "link": 52 389 | } 390 | ], 391 | "properties": { 392 | "Node name for S&R": "PreviewImage" 393 | } 394 | }, 395 | { 396 | "id": 37, 397 | "type": "LayeredDiffusionCondJointApply", 398 | "pos": [ 399 | 429, 400 | -13 401 | ], 402 | "size": { 403 | "0": 388, 404 | "1": 138 405 | }, 406 | "flags": {}, 407 | "order": 7, 408 | "mode": 0, 409 | "inputs": [ 410 | { 411 | "name": "model", 412 | "type": "MODEL", 413 | "link": 55, 414 | "slot_index": 0 415 | }, 416 | { 417 | "name": "image", 418 | "type": "IMAGE", 419 | "link": 54, 420 | "slot_index": 1 421 | }, 422 | { 423 | "name": "cond", 424 | "type": "CONDITIONING", 425 | "link": null 426 | }, 427 | { 428 | "name": "blended_cond", 429 | "type": "CONDITIONING", 430 | "link": null 431 | } 432 | ], 433 | "outputs": [ 434 | { 435 | "name": "MODEL", 436 | "type": "MODEL", 437 | "links": [ 438 | 56 439 | ], 440 | "shape": 3, 441 | "slot_index": 0 442 | } 443 | ], 444 | "properties": { 445 | "Node name for S&R": "LayeredDiffusionCondJointApply" 446 | }, 447 | "widgets_values": [ 448 | "SD15, Background, attn_sharing, Batch size (2N)" 449 | ], 450 | "color": "#232", 451 | "bgcolor": "#353" 452 | }, 453 | { 454 | "id": 52, 455 | "type": "LayeredDiffusionDecodeSplit", 456 | "pos": [ 457 | 1544, 458 | 177 459 | ], 460 | "size": { 461 | "0": 315, 462 | "1": 146 463 | }, 464 | "flags": {}, 465 | "order": 11, 466 | "mode": 0, 467 | "inputs": [ 468 | { 469 | "name": "samples", 470 | "type": "LATENT", 471 | "link": 84 472 | }, 473 | { 474 | "name": "images", 475 | "type": "IMAGE", 476 | "link": 83 477 | } 478 | ], 479 | "outputs": [ 480 | { 481 | "name": "IMAGE", 482 | "type": "IMAGE", 483 | "links": [ 484 | 85 485 | ], 486 | "shape": 3, 487 | "slot_index": 0 488 | }, 489 | { 490 | "name": "IMAGE", 491 | "type": "IMAGE", 492 | "links": [ 493 | 86 494 | ], 495 | "shape": 3, 496 | "slot_index": 1 497 | }, 498 | { 499 | "name": "IMAGE", 500 | "type": "IMAGE", 501 | "links": null, 502 | "shape": 3 503 | } 504 | ], 505 | "properties": { 506 | "Node name for S&R": "LayeredDiffusionDecodeSplit" 507 | }, 508 | "widgets_values": [ 509 | 2, 510 | "SDXL", 511 | 16 512 | ], 513 | "color": "#232", 514 | "bgcolor": "#353" 515 | }, 516 | { 517 | "id": 51, 518 | "type": "PreviewImage", 519 | "pos": [ 520 | 2040, 521 | 201 522 | ], 523 | "size": { 524 | "0": 210, 525 | "1": 246 526 | }, 527 | "flags": {}, 528 | "order": 13, 529 | "mode": 0, 530 | "inputs": [ 531 | { 532 | "name": "images", 533 | "type": "IMAGE", 534 | "link": 86 535 | } 536 | ], 537 | "properties": { 538 | "Node name for S&R": "PreviewImage" 539 | } 540 | }, 541 | { 542 | "id": 30, 543 | "type": "LoadImage", 544 | "pos": [ 545 | -313, 546 | -10 547 | ], 548 | "size": { 549 | "0": 315, 550 | "1": 314 551 | }, 552 | "flags": {}, 553 | "order": 2, 554 | "mode": 0, 555 | "outputs": [ 556 | { 557 | "name": "IMAGE", 558 | "type": "IMAGE", 559 | "links": [ 560 | 50 561 | ], 562 | "shape": 3, 563 | "slot_index": 0 564 | }, 565 | { 566 | "name": "MASK", 567 | "type": "MASK", 568 | "links": null, 569 | "shape": 3 570 | } 571 | ], 572 | "properties": { 573 | "Node name for S&R": "LoadImage" 574 | }, 575 | "widgets_values": [ 576 | "309219693-e7e2d80e-ffbe-4724-812a-5139a88027e3.png", 577 | "image" 578 | ] 579 | } 580 | ], 581 | "links": [ 582 | [ 583 | 2, 584 | 5, 585 | 0, 586 | 3, 587 | 3, 588 | "LATENT" 589 | ], 590 | [ 591 | 3, 592 | 4, 593 | 1, 594 | 6, 595 | 0, 596 | "CLIP" 597 | ], 598 | [ 599 | 5, 600 | 4, 601 | 1, 602 | 7, 603 | 0, 604 | "CLIP" 605 | ], 606 | [ 607 | 50, 608 | 30, 609 | 0, 610 | 33, 611 | 0, 612 | "IMAGE" 613 | ], 614 | [ 615 | 52, 616 | 33, 617 | 0, 618 | 34, 619 | 0, 620 | "IMAGE" 621 | ], 622 | [ 623 | 54, 624 | 33, 625 | 0, 626 | 37, 627 | 1, 628 | "IMAGE" 629 | ], 630 | [ 631 | 55, 632 | 4, 633 | 0, 634 | 37, 635 | 0, 636 | "MODEL" 637 | ], 638 | [ 639 | 56, 640 | 37, 641 | 0, 642 | 3, 643 | 0, 644 | "MODEL" 645 | ], 646 | [ 647 | 64, 648 | 6, 649 | 0, 650 | 3, 651 | 1, 652 | "CONDITIONING" 653 | ], 654 | [ 655 | 65, 656 | 7, 657 | 0, 658 | 3, 659 | 2, 660 | "CONDITIONING" 661 | ], 662 | [ 663 | 70, 664 | 3, 665 | 0, 666 | 44, 667 | 0, 668 | "LATENT" 669 | ], 670 | [ 671 | 75, 672 | 44, 673 | 0, 674 | 46, 675 | 0, 676 | "IMAGE" 677 | ], 678 | [ 679 | 83, 680 | 44, 681 | 0, 682 | 52, 683 | 1, 684 | "IMAGE" 685 | ], 686 | [ 687 | 84, 688 | 3, 689 | 0, 690 | 52, 691 | 0, 692 | "LATENT" 693 | ], 694 | [ 695 | 85, 696 | 52, 697 | 0, 698 | 50, 699 | 0, 700 | "IMAGE" 701 | ], 702 | [ 703 | 86, 704 | 52, 705 | 1, 706 | 51, 707 | 0, 708 | "IMAGE" 709 | ], 710 | [ 711 | 88, 712 | 4, 713 | 2, 714 | 44, 715 | 1, 716 | "VAE" 717 | ] 718 | ], 719 | "groups": [], 720 | "config": {}, 721 | "extra": {}, 722 | "version": 0.4 723 | } -------------------------------------------------------------------------------- /example_workflows/layer_diffusion_cond_joint_fg.json: -------------------------------------------------------------------------------- 1 | { 2 | "last_node_id": 53, 3 | "last_link_id": 90, 4 | "nodes": [ 5 | { 6 | "id": 7, 7 | "type": "CLIPTextEncode", 8 | "pos": [ 9 | 413, 10 | 389 11 | ], 12 | "size": { 13 | "0": 425.27801513671875, 14 | "1": 180.6060791015625 15 | }, 16 | "flags": {}, 17 | "order": 4, 18 | "mode": 0, 19 | "inputs": [ 20 | { 21 | "name": "clip", 22 | "type": "CLIP", 23 | "link": 5 24 | } 25 | ], 26 | "outputs": [ 27 | { 28 | "name": "CONDITIONING", 29 | "type": "CONDITIONING", 30 | "links": [ 31 | 65 32 | ], 33 | "slot_index": 0 34 | } 35 | ], 36 | "properties": { 37 | "Node name for S&R": "CLIPTextEncode" 38 | }, 39 | "widgets_values": [ 40 | "text, watermark" 41 | ] 42 | }, 43 | { 44 | "id": 4, 45 | "type": "CheckpointLoaderSimple", 46 | "pos": [ 47 | 5, 48 | 479 49 | ], 50 | "size": { 51 | "0": 315, 52 | "1": 98 53 | }, 54 | "flags": {}, 55 | "order": 0, 56 | "mode": 0, 57 | "outputs": [ 58 | { 59 | "name": "MODEL", 60 | "type": "MODEL", 61 | "links": [ 62 | 55 63 | ], 64 | "slot_index": 0 65 | }, 66 | { 67 | "name": "CLIP", 68 | "type": "CLIP", 69 | "links": [ 70 | 3, 71 | 5 72 | ], 73 | "slot_index": 1 74 | }, 75 | { 76 | "name": "VAE", 77 | "type": "VAE", 78 | "links": [ 79 | 88 80 | ], 81 | "slot_index": 2 82 | } 83 | ], 84 | "properties": { 85 | "Node name for S&R": "CheckpointLoaderSimple" 86 | }, 87 | "widgets_values": [ 88 | "realisticVisionV20_v20.safetensors" 89 | ] 90 | }, 91 | { 92 | "id": 46, 93 | "type": "PreviewImage", 94 | "pos": [ 95 | 1525, 96 | 183 97 | ], 98 | "size": [ 99 | 406.59525756835933, 100 | 340.5699157714844 101 | ], 102 | "flags": {}, 103 | "order": 8, 104 | "mode": 0, 105 | "inputs": [ 106 | { 107 | "name": "images", 108 | "type": "IMAGE", 109 | "link": 75 110 | } 111 | ], 112 | "properties": { 113 | "Node name for S&R": "PreviewImage" 114 | } 115 | }, 116 | { 117 | "id": 37, 118 | "type": "LayeredDiffusionCondJointApply", 119 | "pos": [ 120 | 436, 121 | -13 122 | ], 123 | "size": { 124 | "0": 388, 125 | "1": 138 126 | }, 127 | "flags": {}, 128 | "order": 5, 129 | "mode": 0, 130 | "inputs": [ 131 | { 132 | "name": "model", 133 | "type": "MODEL", 134 | "link": 55, 135 | "slot_index": 0 136 | }, 137 | { 138 | "name": "image", 139 | "type": "IMAGE", 140 | "link": 90, 141 | "slot_index": 1 142 | }, 143 | { 144 | "name": "cond", 145 | "type": "CONDITIONING", 146 | "link": null 147 | }, 148 | { 149 | "name": "blended_cond", 150 | "type": "CONDITIONING", 151 | "link": null 152 | } 153 | ], 154 | "outputs": [ 155 | { 156 | "name": "MODEL", 157 | "type": "MODEL", 158 | "links": [ 159 | 56 160 | ], 161 | "shape": 3, 162 | "slot_index": 0 163 | } 164 | ], 165 | "properties": { 166 | "Node name for S&R": "LayeredDiffusionCondJointApply" 167 | }, 168 | "widgets_values": [ 169 | "SD15, Foreground, attn_sharing, Batch size (2N)" 170 | ], 171 | "color": "#232", 172 | "bgcolor": "#353" 173 | }, 174 | { 175 | "id": 5, 176 | "type": "EmptyLatentImage", 177 | "pos": [ 178 | 465, 179 | 671 180 | ], 181 | "size": { 182 | "0": 315, 183 | "1": 106 184 | }, 185 | "flags": {}, 186 | "order": 1, 187 | "mode": 0, 188 | "outputs": [ 189 | { 190 | "name": "LATENT", 191 | "type": "LATENT", 192 | "links": [ 193 | 2 194 | ], 195 | "slot_index": 0 196 | } 197 | ], 198 | "properties": { 199 | "Node name for S&R": "EmptyLatentImage" 200 | }, 201 | "widgets_values": [ 202 | 512, 203 | 512, 204 | 4 205 | ] 206 | }, 207 | { 208 | "id": 6, 209 | "type": "CLIPTextEncode", 210 | "pos": [ 211 | 415, 212 | 186 213 | ], 214 | "size": { 215 | "0": 422.84503173828125, 216 | "1": 164.31304931640625 217 | }, 218 | "flags": {}, 219 | "order": 3, 220 | "mode": 0, 221 | "inputs": [ 222 | { 223 | "name": "clip", 224 | "type": "CLIP", 225 | "link": 3 226 | } 227 | ], 228 | "outputs": [ 229 | { 230 | "name": "CONDITIONING", 231 | "type": "CONDITIONING", 232 | "links": [ 233 | 64 234 | ], 235 | "slot_index": 0 236 | } 237 | ], 238 | "properties": { 239 | "Node name for S&R": "CLIPTextEncode" 240 | }, 241 | "widgets_values": [ 242 | "\n" 243 | ] 244 | }, 245 | { 246 | "id": 3, 247 | "type": "KSampler", 248 | "pos": [ 249 | 903, 250 | 180 251 | ], 252 | "size": { 253 | "0": 315, 254 | "1": 262 255 | }, 256 | "flags": {}, 257 | "order": 6, 258 | "mode": 0, 259 | "inputs": [ 260 | { 261 | "name": "model", 262 | "type": "MODEL", 263 | "link": 56 264 | }, 265 | { 266 | "name": "positive", 267 | "type": "CONDITIONING", 268 | "link": 64 269 | }, 270 | { 271 | "name": "negative", 272 | "type": "CONDITIONING", 273 | "link": 65 274 | }, 275 | { 276 | "name": "latent_image", 277 | "type": "LATENT", 278 | "link": 2 279 | } 280 | ], 281 | "outputs": [ 282 | { 283 | "name": "LATENT", 284 | "type": "LATENT", 285 | "links": [ 286 | 70 287 | ], 288 | "slot_index": 0 289 | } 290 | ], 291 | "properties": { 292 | "Node name for S&R": "KSampler" 293 | }, 294 | "widgets_values": [ 295 | 748570836161213, 296 | "randomize", 297 | 20, 298 | 8, 299 | "euler", 300 | "normal", 301 | 1 302 | ] 303 | }, 304 | { 305 | "id": 44, 306 | "type": "VAEDecode", 307 | "pos": [ 308 | 1258, 309 | 184 310 | ], 311 | "size": { 312 | "0": 210, 313 | "1": 46 314 | }, 315 | "flags": {}, 316 | "order": 7, 317 | "mode": 0, 318 | "inputs": [ 319 | { 320 | "name": "samples", 321 | "type": "LATENT", 322 | "link": 70 323 | }, 324 | { 325 | "name": "vae", 326 | "type": "VAE", 327 | "link": 88, 328 | "slot_index": 1 329 | } 330 | ], 331 | "outputs": [ 332 | { 333 | "name": "IMAGE", 334 | "type": "IMAGE", 335 | "links": [ 336 | 75 337 | ], 338 | "shape": 3, 339 | "slot_index": 0 340 | } 341 | ], 342 | "properties": { 343 | "Node name for S&R": "VAEDecode" 344 | } 345 | }, 346 | { 347 | "id": 30, 348 | "type": "LoadImage", 349 | "pos": [ 350 | 6, 351 | 5 352 | ], 353 | "size": { 354 | "0": 315, 355 | "1": 314 356 | }, 357 | "flags": {}, 358 | "order": 2, 359 | "mode": 0, 360 | "outputs": [ 361 | { 362 | "name": "IMAGE", 363 | "type": "IMAGE", 364 | "links": [ 365 | 90 366 | ], 367 | "shape": 3, 368 | "slot_index": 0 369 | }, 370 | { 371 | "name": "MASK", 372 | "type": "MASK", 373 | "links": null, 374 | "shape": 3 375 | } 376 | ], 377 | "properties": { 378 | "Node name for S&R": "LoadImage" 379 | }, 380 | "widgets_values": [ 381 | "dog (2).png", 382 | "image" 383 | ] 384 | } 385 | ], 386 | "links": [ 387 | [ 388 | 2, 389 | 5, 390 | 0, 391 | 3, 392 | 3, 393 | "LATENT" 394 | ], 395 | [ 396 | 3, 397 | 4, 398 | 1, 399 | 6, 400 | 0, 401 | "CLIP" 402 | ], 403 | [ 404 | 5, 405 | 4, 406 | 1, 407 | 7, 408 | 0, 409 | "CLIP" 410 | ], 411 | [ 412 | 55, 413 | 4, 414 | 0, 415 | 37, 416 | 0, 417 | "MODEL" 418 | ], 419 | [ 420 | 56, 421 | 37, 422 | 0, 423 | 3, 424 | 0, 425 | "MODEL" 426 | ], 427 | [ 428 | 64, 429 | 6, 430 | 0, 431 | 3, 432 | 1, 433 | "CONDITIONING" 434 | ], 435 | [ 436 | 65, 437 | 7, 438 | 0, 439 | 3, 440 | 2, 441 | "CONDITIONING" 442 | ], 443 | [ 444 | 70, 445 | 3, 446 | 0, 447 | 44, 448 | 0, 449 | "LATENT" 450 | ], 451 | [ 452 | 75, 453 | 44, 454 | 0, 455 | 46, 456 | 0, 457 | "IMAGE" 458 | ], 459 | [ 460 | 88, 461 | 4, 462 | 2, 463 | 44, 464 | 1, 465 | "VAE" 466 | ], 467 | [ 468 | 90, 469 | 30, 470 | 0, 471 | 37, 472 | 1, 473 | "IMAGE" 474 | ] 475 | ], 476 | "groups": [], 477 | "config": {}, 478 | "extra": {}, 479 | "version": 0.4 480 | } -------------------------------------------------------------------------------- /example_workflows/layer_diffusion_diff_bg.json: -------------------------------------------------------------------------------- 1 | { 2 | "last_node_id": 40, 3 | "last_link_id": 67, 4 | "nodes": [ 5 | { 6 | "id": 4, 7 | "type": "CheckpointLoaderSimple", 8 | "pos": [ 9 | 5, 10 | 479 11 | ], 12 | "size": { 13 | "0": 315, 14 | "1": 98 15 | }, 16 | "flags": {}, 17 | "order": 0, 18 | "mode": 0, 19 | "outputs": [ 20 | { 21 | "name": "MODEL", 22 | "type": "MODEL", 23 | "links": [ 24 | 55 25 | ], 26 | "slot_index": 0 27 | }, 28 | { 29 | "name": "CLIP", 30 | "type": "CLIP", 31 | "links": [ 32 | 3, 33 | 5 34 | ], 35 | "slot_index": 1 36 | }, 37 | { 38 | "name": "VAE", 39 | "type": "VAE", 40 | "links": [ 41 | 22, 42 | 49, 43 | 58 44 | ], 45 | "slot_index": 2 46 | } 47 | ], 48 | "properties": { 49 | "Node name for S&R": "CheckpointLoaderSimple" 50 | }, 51 | "widgets_values": [ 52 | "juggernautXL_v8Rundiffusion.safetensors" 53 | ] 54 | }, 55 | { 56 | "id": 7, 57 | "type": "CLIPTextEncode", 58 | "pos": [ 59 | 413, 60 | 389 61 | ], 62 | "size": { 63 | "0": 425.27801513671875, 64 | "1": 180.6060791015625 65 | }, 66 | "flags": {}, 67 | "order": 5, 68 | "mode": 0, 69 | "inputs": [ 70 | { 71 | "name": "clip", 72 | "type": "CLIP", 73 | "link": 5 74 | } 75 | ], 76 | "outputs": [ 77 | { 78 | "name": "CONDITIONING", 79 | "type": "CONDITIONING", 80 | "links": [ 81 | 57 82 | ], 83 | "slot_index": 0 84 | } 85 | ], 86 | "properties": { 87 | "Node name for S&R": "CLIPTextEncode" 88 | }, 89 | "widgets_values": [ 90 | "text, watermark" 91 | ] 92 | }, 93 | { 94 | "id": 5, 95 | "type": "EmptyLatentImage", 96 | "pos": [ 97 | 475, 98 | 666 99 | ], 100 | "size": { 101 | "0": 315, 102 | "1": 106 103 | }, 104 | "flags": {}, 105 | "order": 1, 106 | "mode": 0, 107 | "outputs": [ 108 | { 109 | "name": "LATENT", 110 | "type": "LATENT", 111 | "links": [ 112 | 2 113 | ], 114 | "slot_index": 0 115 | } 116 | ], 117 | "properties": { 118 | "Node name for S&R": "EmptyLatentImage" 119 | }, 120 | "widgets_values": [ 121 | 1024, 122 | 1024, 123 | 1 124 | ] 125 | }, 126 | { 127 | "id": 39, 128 | "type": "VAEEncode", 129 | "pos": [ 130 | 201, 131 | -391 132 | ], 133 | "size": { 134 | "0": 210, 135 | "1": 46 136 | }, 137 | "flags": {}, 138 | "order": 6, 139 | "mode": 0, 140 | "inputs": [ 141 | { 142 | "name": "pixels", 143 | "type": "IMAGE", 144 | "link": 59, 145 | "slot_index": 0 146 | }, 147 | { 148 | "name": "vae", 149 | "type": "VAE", 150 | "link": 58, 151 | "slot_index": 1 152 | } 153 | ], 154 | "outputs": [ 155 | { 156 | "name": "LATENT", 157 | "type": "LATENT", 158 | "links": [ 159 | 60 160 | ], 161 | "shape": 3, 162 | "slot_index": 0 163 | } 164 | ], 165 | "properties": { 166 | "Node name for S&R": "VAEEncode" 167 | } 168 | }, 169 | { 170 | "id": 29, 171 | "type": "VAEEncode", 172 | "pos": [ 173 | 210, 174 | -20 175 | ], 176 | "size": { 177 | "0": 210, 178 | "1": 46 179 | }, 180 | "flags": {}, 181 | "order": 7, 182 | "mode": 0, 183 | "inputs": [ 184 | { 185 | "name": "pixels", 186 | "type": "IMAGE", 187 | "link": 53 188 | }, 189 | { 190 | "name": "vae", 191 | "type": "VAE", 192 | "link": 49, 193 | "slot_index": 1 194 | } 195 | ], 196 | "outputs": [ 197 | { 198 | "name": "LATENT", 199 | "type": "LATENT", 200 | "links": [ 201 | 61 202 | ], 203 | "shape": 3, 204 | "slot_index": 0 205 | } 206 | ], 207 | "properties": { 208 | "Node name for S&R": "VAEEncode" 209 | } 210 | }, 211 | { 212 | "id": 38, 213 | "type": "LoadImage", 214 | "pos": [ 215 | -137, 216 | -388 217 | ], 218 | "size": { 219 | "0": 288.47406005859375, 220 | "1": 317.46051025390625 221 | }, 222 | "flags": {}, 223 | "order": 2, 224 | "mode": 0, 225 | "outputs": [ 226 | { 227 | "name": "IMAGE", 228 | "type": "IMAGE", 229 | "links": [ 230 | 59 231 | ], 232 | "shape": 3 233 | }, 234 | { 235 | "name": "MASK", 236 | "type": "MASK", 237 | "links": null, 238 | "shape": 3 239 | } 240 | ], 241 | "properties": { 242 | "Node name for S&R": "LoadImage" 243 | }, 244 | "widgets_values": [ 245 | "old_man.png", 246 | "image" 247 | ] 248 | }, 249 | { 250 | "id": 30, 251 | "type": "LoadImage", 252 | "pos": [ 253 | -146, 254 | -22 255 | ], 256 | "size": { 257 | "0": 315, 258 | "1": 314 259 | }, 260 | "flags": {}, 261 | "order": 3, 262 | "mode": 0, 263 | "outputs": [ 264 | { 265 | "name": "IMAGE", 266 | "type": "IMAGE", 267 | "links": [ 268 | 53 269 | ], 270 | "shape": 3, 271 | "slot_index": 0 272 | }, 273 | { 274 | "name": "MASK", 275 | "type": "MASK", 276 | "links": null, 277 | "shape": 3 278 | } 279 | ], 280 | "properties": { 281 | "Node name for S&R": "LoadImage" 282 | }, 283 | "widgets_values": [ 284 | "chair.png", 285 | "image" 286 | ] 287 | }, 288 | { 289 | "id": 6, 290 | "type": "CLIPTextEncode", 291 | "pos": [ 292 | 415, 293 | 186 294 | ], 295 | "size": { 296 | "0": 422.84503173828125, 297 | "1": 164.31304931640625 298 | }, 299 | "flags": {}, 300 | "order": 4, 301 | "mode": 0, 302 | "inputs": [ 303 | { 304 | "name": "clip", 305 | "type": "CLIP", 306 | "link": 3 307 | } 308 | ], 309 | "outputs": [ 310 | { 311 | "name": "CONDITIONING", 312 | "type": "CONDITIONING", 313 | "links": [ 314 | 56 315 | ], 316 | "slot_index": 0 317 | } 318 | ], 319 | "properties": { 320 | "Node name for S&R": "CLIPTextEncode" 321 | }, 322 | "widgets_values": [ 323 | "an old man sitting, high quality\n\n" 324 | ] 325 | }, 326 | { 327 | "id": 14, 328 | "type": "VAEDecode", 329 | "pos": [ 330 | 1286, 331 | 187 332 | ], 333 | "size": { 334 | "0": 210, 335 | "1": 46 336 | }, 337 | "flags": {}, 338 | "order": 10, 339 | "mode": 0, 340 | "inputs": [ 341 | { 342 | "name": "samples", 343 | "type": "LATENT", 344 | "link": 21 345 | }, 346 | { 347 | "name": "vae", 348 | "type": "VAE", 349 | "link": 22, 350 | "slot_index": 1 351 | } 352 | ], 353 | "outputs": [ 354 | { 355 | "name": "IMAGE", 356 | "type": "IMAGE", 357 | "links": [ 358 | 65 359 | ], 360 | "shape": 3, 361 | "slot_index": 0 362 | } 363 | ], 364 | "properties": { 365 | "Node name for S&R": "VAEDecode" 366 | } 367 | }, 368 | { 369 | "id": 3, 370 | "type": "KSampler", 371 | "pos": [ 372 | 913, 373 | 182 374 | ], 375 | "size": { 376 | "0": 315, 377 | "1": 262 378 | }, 379 | "flags": {}, 380 | "order": 9, 381 | "mode": 0, 382 | "inputs": [ 383 | { 384 | "name": "model", 385 | "type": "MODEL", 386 | "link": 62 387 | }, 388 | { 389 | "name": "positive", 390 | "type": "CONDITIONING", 391 | "link": 63 392 | }, 393 | { 394 | "name": "negative", 395 | "type": "CONDITIONING", 396 | "link": 64 397 | }, 398 | { 399 | "name": "latent_image", 400 | "type": "LATENT", 401 | "link": 2 402 | } 403 | ], 404 | "outputs": [ 405 | { 406 | "name": "LATENT", 407 | "type": "LATENT", 408 | "links": [ 409 | 21, 410 | 67 411 | ], 412 | "slot_index": 0 413 | } 414 | ], 415 | "properties": { 416 | "Node name for S&R": "KSampler" 417 | }, 418 | "widgets_values": [ 419 | 462370085958750, 420 | "fixed", 421 | 20, 422 | 8, 423 | "euler", 424 | "normal", 425 | 1 426 | ] 427 | }, 428 | { 429 | "id": 20, 430 | "type": "PreviewImage", 431 | "pos": [ 432 | 1800, 433 | 190 434 | ], 435 | "size": { 436 | "0": 611.2340087890625, 437 | "1": 633.9354858398438 438 | }, 439 | "flags": {}, 440 | "order": 12, 441 | "mode": 0, 442 | "inputs": [ 443 | { 444 | "name": "images", 445 | "type": "IMAGE", 446 | "link": 66 447 | } 448 | ], 449 | "properties": { 450 | "Node name for S&R": "PreviewImage" 451 | } 452 | }, 453 | { 454 | "id": 37, 455 | "type": "LayeredDiffusionDiffApply", 456 | "pos": [ 457 | 457, 458 | -37 459 | ], 460 | "size": { 461 | "0": 342.5999755859375, 462 | "1": 162 463 | }, 464 | "flags": {}, 465 | "order": 8, 466 | "mode": 0, 467 | "inputs": [ 468 | { 469 | "name": "model", 470 | "type": "MODEL", 471 | "link": 55, 472 | "slot_index": 0 473 | }, 474 | { 475 | "name": "cond", 476 | "type": "CONDITIONING", 477 | "link": 56, 478 | "slot_index": 1 479 | }, 480 | { 481 | "name": "uncond", 482 | "type": "CONDITIONING", 483 | "link": 57, 484 | "slot_index": 2 485 | }, 486 | { 487 | "name": "blended_latent", 488 | "type": "LATENT", 489 | "link": 60 490 | }, 491 | { 492 | "name": "latent", 493 | "type": "LATENT", 494 | "link": 61 495 | } 496 | ], 497 | "outputs": [ 498 | { 499 | "name": "MODEL", 500 | "type": "MODEL", 501 | "links": [ 502 | 62 503 | ], 504 | "shape": 3, 505 | "slot_index": 0 506 | }, 507 | { 508 | "name": "CONDITIONING", 509 | "type": "CONDITIONING", 510 | "links": [ 511 | 63 512 | ], 513 | "shape": 3, 514 | "slot_index": 1 515 | }, 516 | { 517 | "name": "CONDITIONING", 518 | "type": "CONDITIONING", 519 | "links": [ 520 | 64 521 | ], 522 | "shape": 3, 523 | "slot_index": 2 524 | } 525 | ], 526 | "properties": { 527 | "Node name for S&R": "LayeredDiffusionDiffApply" 528 | }, 529 | "widgets_values": [ 530 | "SDXL, Background", 531 | 1 532 | ], 533 | "color": "#232", 534 | "bgcolor": "#353" 535 | }, 536 | { 537 | "id": 40, 538 | "type": "LayeredDiffusionDecodeRGBA", 539 | "pos": [ 540 | 1533, 541 | 189 542 | ], 543 | "size": { 544 | "0": 243.60000610351562, 545 | "1": 102 546 | }, 547 | "flags": {}, 548 | "order": 11, 549 | "mode": 0, 550 | "inputs": [ 551 | { 552 | "name": "samples", 553 | "type": "LATENT", 554 | "link": 67 555 | }, 556 | { 557 | "name": "images", 558 | "type": "IMAGE", 559 | "link": 65 560 | } 561 | ], 562 | "outputs": [ 563 | { 564 | "name": "IMAGE", 565 | "type": "IMAGE", 566 | "links": [ 567 | 66 568 | ], 569 | "shape": 3, 570 | "slot_index": 0 571 | } 572 | ], 573 | "properties": { 574 | "Node name for S&R": "LayeredDiffusionDecodeRGBA" 575 | }, 576 | "widgets_values": [ 577 | "SDXL", 578 | 16 579 | ], 580 | "color": "#232", 581 | "bgcolor": "#353" 582 | } 583 | ], 584 | "links": [ 585 | [ 586 | 2, 587 | 5, 588 | 0, 589 | 3, 590 | 3, 591 | "LATENT" 592 | ], 593 | [ 594 | 3, 595 | 4, 596 | 1, 597 | 6, 598 | 0, 599 | "CLIP" 600 | ], 601 | [ 602 | 5, 603 | 4, 604 | 1, 605 | 7, 606 | 0, 607 | "CLIP" 608 | ], 609 | [ 610 | 21, 611 | 3, 612 | 0, 613 | 14, 614 | 0, 615 | "LATENT" 616 | ], 617 | [ 618 | 22, 619 | 4, 620 | 2, 621 | 14, 622 | 1, 623 | "VAE" 624 | ], 625 | [ 626 | 49, 627 | 4, 628 | 2, 629 | 29, 630 | 1, 631 | "VAE" 632 | ], 633 | [ 634 | 53, 635 | 30, 636 | 0, 637 | 29, 638 | 0, 639 | "IMAGE" 640 | ], 641 | [ 642 | 55, 643 | 4, 644 | 0, 645 | 37, 646 | 0, 647 | "MODEL" 648 | ], 649 | [ 650 | 56, 651 | 6, 652 | 0, 653 | 37, 654 | 1, 655 | "CONDITIONING" 656 | ], 657 | [ 658 | 57, 659 | 7, 660 | 0, 661 | 37, 662 | 2, 663 | "CONDITIONING" 664 | ], 665 | [ 666 | 58, 667 | 4, 668 | 2, 669 | 39, 670 | 1, 671 | "VAE" 672 | ], 673 | [ 674 | 59, 675 | 38, 676 | 0, 677 | 39, 678 | 0, 679 | "IMAGE" 680 | ], 681 | [ 682 | 60, 683 | 39, 684 | 0, 685 | 37, 686 | 3, 687 | "LATENT" 688 | ], 689 | [ 690 | 61, 691 | 29, 692 | 0, 693 | 37, 694 | 4, 695 | "LATENT" 696 | ], 697 | [ 698 | 62, 699 | 37, 700 | 0, 701 | 3, 702 | 0, 703 | "MODEL" 704 | ], 705 | [ 706 | 63, 707 | 37, 708 | 1, 709 | 3, 710 | 1, 711 | "CONDITIONING" 712 | ], 713 | [ 714 | 64, 715 | 37, 716 | 2, 717 | 3, 718 | 2, 719 | "CONDITIONING" 720 | ], 721 | [ 722 | 65, 723 | 14, 724 | 0, 725 | 40, 726 | 1, 727 | "IMAGE" 728 | ], 729 | [ 730 | 66, 731 | 40, 732 | 0, 733 | 20, 734 | 0, 735 | "IMAGE" 736 | ], 737 | [ 738 | 67, 739 | 3, 740 | 0, 741 | 40, 742 | 0, 743 | "LATENT" 744 | ] 745 | ], 746 | "groups": [], 747 | "config": {}, 748 | "extra": {}, 749 | "version": 0.4 750 | } -------------------------------------------------------------------------------- /example_workflows/layer_diffusion_diff_bg_stop_at.json: -------------------------------------------------------------------------------- 1 | { 2 | "last_node_id": 45, 3 | "last_link_id": 86, 4 | "nodes": [ 5 | { 6 | "id": 5, 7 | "type": "EmptyLatentImage", 8 | "pos": [ 9 | 475, 10 | 666 11 | ], 12 | "size": { 13 | "0": 315, 14 | "1": 106 15 | }, 16 | "flags": {}, 17 | "order": 0, 18 | "mode": 0, 19 | "outputs": [ 20 | { 21 | "name": "LATENT", 22 | "type": "LATENT", 23 | "links": [ 24 | 2 25 | ], 26 | "slot_index": 0 27 | } 28 | ], 29 | "properties": { 30 | "Node name for S&R": "EmptyLatentImage" 31 | }, 32 | "widgets_values": [ 33 | 1024, 34 | 1024, 35 | 1 36 | ] 37 | }, 38 | { 39 | "id": 38, 40 | "type": "LoadImage", 41 | "pos": [ 42 | -137, 43 | -388 44 | ], 45 | "size": { 46 | "0": 288.47406005859375, 47 | "1": 317.46051025390625 48 | }, 49 | "flags": {}, 50 | "order": 1, 51 | "mode": 0, 52 | "outputs": [ 53 | { 54 | "name": "IMAGE", 55 | "type": "IMAGE", 56 | "links": [ 57 | 59 58 | ], 59 | "shape": 3 60 | }, 61 | { 62 | "name": "MASK", 63 | "type": "MASK", 64 | "links": null, 65 | "shape": 3 66 | } 67 | ], 68 | "properties": { 69 | "Node name for S&R": "LoadImage" 70 | }, 71 | "widgets_values": [ 72 | "blended.png", 73 | "image" 74 | ] 75 | }, 76 | { 77 | "id": 39, 78 | "type": "VAEEncode", 79 | "pos": [ 80 | 201, 81 | -391 82 | ], 83 | "size": { 84 | "0": 210, 85 | "1": 46 86 | }, 87 | "flags": {}, 88 | "order": 7, 89 | "mode": 0, 90 | "inputs": [ 91 | { 92 | "name": "pixels", 93 | "type": "IMAGE", 94 | "link": 59, 95 | "slot_index": 0 96 | }, 97 | { 98 | "name": "vae", 99 | "type": "VAE", 100 | "link": 58, 101 | "slot_index": 1 102 | } 103 | ], 104 | "outputs": [ 105 | { 106 | "name": "LATENT", 107 | "type": "LATENT", 108 | "links": [ 109 | 60 110 | ], 111 | "shape": 3, 112 | "slot_index": 0 113 | } 114 | ], 115 | "properties": { 116 | "Node name for S&R": "VAEEncode" 117 | } 118 | }, 119 | { 120 | "id": 29, 121 | "type": "VAEEncode", 122 | "pos": [ 123 | 210, 124 | -20 125 | ], 126 | "size": { 127 | "0": 210, 128 | "1": 46 129 | }, 130 | "flags": {}, 131 | "order": 6, 132 | "mode": 0, 133 | "inputs": [ 134 | { 135 | "name": "pixels", 136 | "type": "IMAGE", 137 | "link": 53 138 | }, 139 | { 140 | "name": "vae", 141 | "type": "VAE", 142 | "link": 49, 143 | "slot_index": 1 144 | } 145 | ], 146 | "outputs": [ 147 | { 148 | "name": "LATENT", 149 | "type": "LATENT", 150 | "links": [ 151 | 61 152 | ], 153 | "shape": 3, 154 | "slot_index": 0 155 | } 156 | ], 157 | "properties": { 158 | "Node name for S&R": "VAEEncode" 159 | } 160 | }, 161 | { 162 | "id": 30, 163 | "type": "LoadImage", 164 | "pos": [ 165 | -146, 166 | -22 167 | ], 168 | "size": { 169 | "0": 315, 170 | "1": 314 171 | }, 172 | "flags": {}, 173 | "order": 2, 174 | "mode": 0, 175 | "outputs": [ 176 | { 177 | "name": "IMAGE", 178 | "type": "IMAGE", 179 | "links": [ 180 | 53 181 | ], 182 | "shape": 3, 183 | "slot_index": 0 184 | }, 185 | { 186 | "name": "MASK", 187 | "type": "MASK", 188 | "links": null, 189 | "shape": 3 190 | } 191 | ], 192 | "properties": { 193 | "Node name for S&R": "LoadImage" 194 | }, 195 | "widgets_values": [ 196 | "dog.png", 197 | "image" 198 | ] 199 | }, 200 | { 201 | "id": 6, 202 | "type": "CLIPTextEncode", 203 | "pos": [ 204 | 415, 205 | 186 206 | ], 207 | "size": { 208 | "0": 422.84503173828125, 209 | "1": 164.31304931640625 210 | }, 211 | "flags": {}, 212 | "order": 4, 213 | "mode": 0, 214 | "inputs": [ 215 | { 216 | "name": "clip", 217 | "type": "CLIP", 218 | "link": 3 219 | } 220 | ], 221 | "outputs": [ 222 | { 223 | "name": "CONDITIONING", 224 | "type": "CONDITIONING", 225 | "links": [ 226 | 56, 227 | 81 228 | ], 229 | "slot_index": 0 230 | } 231 | ], 232 | "properties": { 233 | "Node name for S&R": "CLIPTextEncode" 234 | }, 235 | "widgets_values": [ 236 | "a room, high quality\n\n" 237 | ] 238 | }, 239 | { 240 | "id": 7, 241 | "type": "CLIPTextEncode", 242 | "pos": [ 243 | 413, 244 | 389 245 | ], 246 | "size": { 247 | "0": 425.27801513671875, 248 | "1": 180.6060791015625 249 | }, 250 | "flags": {}, 251 | "order": 5, 252 | "mode": 0, 253 | "inputs": [ 254 | { 255 | "name": "clip", 256 | "type": "CLIP", 257 | "link": 5 258 | } 259 | ], 260 | "outputs": [ 261 | { 262 | "name": "CONDITIONING", 263 | "type": "CONDITIONING", 264 | "links": [ 265 | 57, 266 | 82 267 | ], 268 | "slot_index": 0 269 | } 270 | ], 271 | "properties": { 272 | "Node name for S&R": "CLIPTextEncode" 273 | }, 274 | "widgets_values": [ 275 | "text, watermark" 276 | ] 277 | }, 278 | { 279 | "id": 42, 280 | "type": "PreviewImage", 281 | "pos": [ 282 | 1830, 283 | -500 284 | ], 285 | "size": { 286 | "0": 611.2340087890625, 287 | "1": 633.9354858398438 288 | }, 289 | "flags": {}, 290 | "order": 12, 291 | "mode": 0, 292 | "inputs": [ 293 | { 294 | "name": "images", 295 | "type": "IMAGE", 296 | "link": 76 297 | } 298 | ], 299 | "properties": { 300 | "Node name for S&R": "PreviewImage" 301 | } 302 | }, 303 | { 304 | "id": 20, 305 | "type": "PreviewImage", 306 | "pos": [ 307 | 1830, 308 | 186 309 | ], 310 | "size": { 311 | "0": 611.2340087890625, 312 | "1": 633.9354858398438 313 | }, 314 | "flags": {}, 315 | "order": 14, 316 | "mode": 0, 317 | "inputs": [ 318 | { 319 | "name": "images", 320 | "type": "IMAGE", 321 | "link": 29 322 | } 323 | ], 324 | "properties": { 325 | "Node name for S&R": "PreviewImage" 326 | } 327 | }, 328 | { 329 | "id": 4, 330 | "type": "CheckpointLoaderSimple", 331 | "pos": [ 332 | 5, 333 | 479 334 | ], 335 | "size": { 336 | "0": 315, 337 | "1": 98 338 | }, 339 | "flags": {}, 340 | "order": 3, 341 | "mode": 0, 342 | "outputs": [ 343 | { 344 | "name": "MODEL", 345 | "type": "MODEL", 346 | "links": [ 347 | 55, 348 | 80 349 | ], 350 | "slot_index": 0 351 | }, 352 | { 353 | "name": "CLIP", 354 | "type": "CLIP", 355 | "links": [ 356 | 3, 357 | 5 358 | ], 359 | "slot_index": 1 360 | }, 361 | { 362 | "name": "VAE", 363 | "type": "VAE", 364 | "links": [ 365 | 22, 366 | 49, 367 | 58, 368 | 75 369 | ], 370 | "slot_index": 2 371 | } 372 | ], 373 | "properties": { 374 | "Node name for S&R": "CheckpointLoaderSimple" 375 | }, 376 | "widgets_values": [ 377 | "juggernautXL_v8Rundiffusion.safetensors" 378 | ] 379 | }, 380 | { 381 | "id": 41, 382 | "type": "VAEDecode", 383 | "pos": [ 384 | 1600, 385 | -500 386 | ], 387 | "size": { 388 | "0": 210, 389 | "1": 46 390 | }, 391 | "flags": {}, 392 | "order": 10, 393 | "mode": 0, 394 | "inputs": [ 395 | { 396 | "name": "samples", 397 | "type": "LATENT", 398 | "link": 77 399 | }, 400 | { 401 | "name": "vae", 402 | "type": "VAE", 403 | "link": 75, 404 | "slot_index": 1 405 | } 406 | ], 407 | "outputs": [ 408 | { 409 | "name": "IMAGE", 410 | "type": "IMAGE", 411 | "links": [ 412 | 76 413 | ], 414 | "shape": 3, 415 | "slot_index": 0 416 | } 417 | ], 418 | "properties": { 419 | "Node name for S&R": "VAEDecode" 420 | } 421 | }, 422 | { 423 | "id": 14, 424 | "type": "VAEDecode", 425 | "pos": [ 426 | 1588, 427 | 186 428 | ], 429 | "size": { 430 | "0": 210, 431 | "1": 46 432 | }, 433 | "flags": {}, 434 | "order": 13, 435 | "mode": 0, 436 | "inputs": [ 437 | { 438 | "name": "samples", 439 | "type": "LATENT", 440 | "link": 85 441 | }, 442 | { 443 | "name": "vae", 444 | "type": "VAE", 445 | "link": 22, 446 | "slot_index": 1 447 | } 448 | ], 449 | "outputs": [ 450 | { 451 | "name": "IMAGE", 452 | "type": "IMAGE", 453 | "links": [ 454 | 29 455 | ], 456 | "shape": 3, 457 | "slot_index": 0 458 | } 459 | ], 460 | "properties": { 461 | "Node name for S&R": "VAEDecode" 462 | } 463 | }, 464 | { 465 | "id": 3, 466 | "type": "KSampler", 467 | "pos": [ 468 | 913, 469 | 181 470 | ], 471 | "size": { 472 | "0": 315, 473 | "1": 262 474 | }, 475 | "flags": {}, 476 | "order": 9, 477 | "mode": 0, 478 | "inputs": [ 479 | { 480 | "name": "model", 481 | "type": "MODEL", 482 | "link": 62 483 | }, 484 | { 485 | "name": "positive", 486 | "type": "CONDITIONING", 487 | "link": 63 488 | }, 489 | { 490 | "name": "negative", 491 | "type": "CONDITIONING", 492 | "link": 64 493 | }, 494 | { 495 | "name": "latent_image", 496 | "type": "LATENT", 497 | "link": 2 498 | } 499 | ], 500 | "outputs": [ 501 | { 502 | "name": "LATENT", 503 | "type": "LATENT", 504 | "links": [ 505 | 77, 506 | 86 507 | ], 508 | "slot_index": 0 509 | } 510 | ], 511 | "properties": { 512 | "Node name for S&R": "KSampler" 513 | }, 514 | "widgets_values": [ 515 | 462370085958750, 516 | "fixed", 517 | 20, 518 | 8, 519 | "euler", 520 | "normal", 521 | 1 522 | ] 523 | }, 524 | { 525 | "id": 45, 526 | "type": "KSamplerAdvanced", 527 | "pos": [ 528 | 1249, 529 | 179 530 | ], 531 | "size": { 532 | "0": 315, 533 | "1": 334 534 | }, 535 | "flags": {}, 536 | "order": 11, 537 | "mode": 0, 538 | "inputs": [ 539 | { 540 | "name": "model", 541 | "type": "MODEL", 542 | "link": 80 543 | }, 544 | { 545 | "name": "positive", 546 | "type": "CONDITIONING", 547 | "link": 81 548 | }, 549 | { 550 | "name": "negative", 551 | "type": "CONDITIONING", 552 | "link": 82 553 | }, 554 | { 555 | "name": "latent_image", 556 | "type": "LATENT", 557 | "link": 86 558 | } 559 | ], 560 | "outputs": [ 561 | { 562 | "name": "LATENT", 563 | "type": "LATENT", 564 | "links": [ 565 | 85 566 | ], 567 | "shape": 3, 568 | "slot_index": 0 569 | } 570 | ], 571 | "properties": { 572 | "Node name for S&R": "KSamplerAdvanced" 573 | }, 574 | "widgets_values": [ 575 | "enable", 576 | 0, 577 | "fixed", 578 | 20, 579 | 8, 580 | "euler", 581 | "normal", 582 | 10, 583 | 10000, 584 | "disable" 585 | ] 586 | }, 587 | { 588 | "id": 37, 589 | "type": "LayeredDiffusionDiffApply", 590 | "pos": [ 591 | 456, 592 | -44 593 | ], 594 | "size": { 595 | "0": 342.5999755859375, 596 | "1": 186 597 | }, 598 | "flags": {}, 599 | "order": 8, 600 | "mode": 0, 601 | "inputs": [ 602 | { 603 | "name": "model", 604 | "type": "MODEL", 605 | "link": 55, 606 | "slot_index": 0 607 | }, 608 | { 609 | "name": "cond", 610 | "type": "CONDITIONING", 611 | "link": 56, 612 | "slot_index": 1 613 | }, 614 | { 615 | "name": "uncond", 616 | "type": "CONDITIONING", 617 | "link": 57, 618 | "slot_index": 2 619 | }, 620 | { 621 | "name": "blended_latent", 622 | "type": "LATENT", 623 | "link": 60 624 | }, 625 | { 626 | "name": "latent", 627 | "type": "LATENT", 628 | "link": 61 629 | } 630 | ], 631 | "outputs": [ 632 | { 633 | "name": "MODEL", 634 | "type": "MODEL", 635 | "links": [ 636 | 62 637 | ], 638 | "shape": 3, 639 | "slot_index": 0 640 | }, 641 | { 642 | "name": "CONDITIONING", 643 | "type": "CONDITIONING", 644 | "links": [ 645 | 63 646 | ], 647 | "shape": 3, 648 | "slot_index": 1 649 | }, 650 | { 651 | "name": "CONDITIONING", 652 | "type": "CONDITIONING", 653 | "links": [ 654 | 64 655 | ], 656 | "shape": 3, 657 | "slot_index": 2 658 | } 659 | ], 660 | "properties": { 661 | "Node name for S&R": "LayeredDiffusionDiffApply" 662 | }, 663 | "widgets_values": [ 664 | "SDXL, Foreground", 665 | 1 666 | ], 667 | "color": "#232", 668 | "bgcolor": "#353" 669 | } 670 | ], 671 | "links": [ 672 | [ 673 | 2, 674 | 5, 675 | 0, 676 | 3, 677 | 3, 678 | "LATENT" 679 | ], 680 | [ 681 | 3, 682 | 4, 683 | 1, 684 | 6, 685 | 0, 686 | "CLIP" 687 | ], 688 | [ 689 | 5, 690 | 4, 691 | 1, 692 | 7, 693 | 0, 694 | "CLIP" 695 | ], 696 | [ 697 | 22, 698 | 4, 699 | 2, 700 | 14, 701 | 1, 702 | "VAE" 703 | ], 704 | [ 705 | 29, 706 | 14, 707 | 0, 708 | 20, 709 | 0, 710 | "IMAGE" 711 | ], 712 | [ 713 | 49, 714 | 4, 715 | 2, 716 | 29, 717 | 1, 718 | "VAE" 719 | ], 720 | [ 721 | 53, 722 | 30, 723 | 0, 724 | 29, 725 | 0, 726 | "IMAGE" 727 | ], 728 | [ 729 | 55, 730 | 4, 731 | 0, 732 | 37, 733 | 0, 734 | "MODEL" 735 | ], 736 | [ 737 | 56, 738 | 6, 739 | 0, 740 | 37, 741 | 1, 742 | "CONDITIONING" 743 | ], 744 | [ 745 | 57, 746 | 7, 747 | 0, 748 | 37, 749 | 2, 750 | "CONDITIONING" 751 | ], 752 | [ 753 | 58, 754 | 4, 755 | 2, 756 | 39, 757 | 1, 758 | "VAE" 759 | ], 760 | [ 761 | 59, 762 | 38, 763 | 0, 764 | 39, 765 | 0, 766 | "IMAGE" 767 | ], 768 | [ 769 | 60, 770 | 39, 771 | 0, 772 | 37, 773 | 3, 774 | "LATENT" 775 | ], 776 | [ 777 | 61, 778 | 29, 779 | 0, 780 | 37, 781 | 4, 782 | "LATENT" 783 | ], 784 | [ 785 | 62, 786 | 37, 787 | 0, 788 | 3, 789 | 0, 790 | "MODEL" 791 | ], 792 | [ 793 | 63, 794 | 37, 795 | 1, 796 | 3, 797 | 1, 798 | "CONDITIONING" 799 | ], 800 | [ 801 | 64, 802 | 37, 803 | 2, 804 | 3, 805 | 2, 806 | "CONDITIONING" 807 | ], 808 | [ 809 | 75, 810 | 4, 811 | 2, 812 | 41, 813 | 1, 814 | "VAE" 815 | ], 816 | [ 817 | 76, 818 | 41, 819 | 0, 820 | 42, 821 | 0, 822 | "IMAGE" 823 | ], 824 | [ 825 | 77, 826 | 3, 827 | 0, 828 | 41, 829 | 0, 830 | "LATENT" 831 | ], 832 | [ 833 | 80, 834 | 4, 835 | 0, 836 | 45, 837 | 0, 838 | "MODEL" 839 | ], 840 | [ 841 | 81, 842 | 6, 843 | 0, 844 | 45, 845 | 1, 846 | "CONDITIONING" 847 | ], 848 | [ 849 | 82, 850 | 7, 851 | 0, 852 | 45, 853 | 2, 854 | "CONDITIONING" 855 | ], 856 | [ 857 | 85, 858 | 45, 859 | 0, 860 | 14, 861 | 0, 862 | "LATENT" 863 | ], 864 | [ 865 | 86, 866 | 3, 867 | 0, 868 | 45, 869 | 3, 870 | "LATENT" 871 | ] 872 | ], 873 | "groups": [], 874 | "config": {}, 875 | "extra": {}, 876 | "version": 0.4 877 | } -------------------------------------------------------------------------------- /example_workflows/layer_diffusion_diff_fg.json: -------------------------------------------------------------------------------- 1 | { 2 | "last_node_id": 39, 3 | "last_link_id": 64, 4 | "nodes": [ 5 | { 6 | "id": 4, 7 | "type": "CheckpointLoaderSimple", 8 | "pos": [ 9 | 5, 10 | 479 11 | ], 12 | "size": { 13 | "0": 315, 14 | "1": 98 15 | }, 16 | "flags": {}, 17 | "order": 0, 18 | "mode": 0, 19 | "outputs": [ 20 | { 21 | "name": "MODEL", 22 | "type": "MODEL", 23 | "links": [ 24 | 55 25 | ], 26 | "slot_index": 0 27 | }, 28 | { 29 | "name": "CLIP", 30 | "type": "CLIP", 31 | "links": [ 32 | 3, 33 | 5 34 | ], 35 | "slot_index": 1 36 | }, 37 | { 38 | "name": "VAE", 39 | "type": "VAE", 40 | "links": [ 41 | 22, 42 | 49, 43 | 58 44 | ], 45 | "slot_index": 2 46 | } 47 | ], 48 | "properties": { 49 | "Node name for S&R": "CheckpointLoaderSimple" 50 | }, 51 | "widgets_values": [ 52 | "juggernautXL_v8Rundiffusion.safetensors" 53 | ] 54 | }, 55 | { 56 | "id": 7, 57 | "type": "CLIPTextEncode", 58 | "pos": [ 59 | 413, 60 | 389 61 | ], 62 | "size": { 63 | "0": 425.27801513671875, 64 | "1": 180.6060791015625 65 | }, 66 | "flags": {}, 67 | "order": 5, 68 | "mode": 0, 69 | "inputs": [ 70 | { 71 | "name": "clip", 72 | "type": "CLIP", 73 | "link": 5 74 | } 75 | ], 76 | "outputs": [ 77 | { 78 | "name": "CONDITIONING", 79 | "type": "CONDITIONING", 80 | "links": [ 81 | 57 82 | ], 83 | "slot_index": 0 84 | } 85 | ], 86 | "properties": { 87 | "Node name for S&R": "CLIPTextEncode" 88 | }, 89 | "widgets_values": [ 90 | "text, watermark" 91 | ] 92 | }, 93 | { 94 | "id": 5, 95 | "type": "EmptyLatentImage", 96 | "pos": [ 97 | 475, 98 | 666 99 | ], 100 | "size": { 101 | "0": 315, 102 | "1": 106 103 | }, 104 | "flags": {}, 105 | "order": 1, 106 | "mode": 0, 107 | "outputs": [ 108 | { 109 | "name": "LATENT", 110 | "type": "LATENT", 111 | "links": [ 112 | 2 113 | ], 114 | "slot_index": 0 115 | } 116 | ], 117 | "properties": { 118 | "Node name for S&R": "EmptyLatentImage" 119 | }, 120 | "widgets_values": [ 121 | 1024, 122 | 1024, 123 | 1 124 | ] 125 | }, 126 | { 127 | "id": 14, 128 | "type": "VAEDecode", 129 | "pos": [ 130 | 1286, 131 | 187 132 | ], 133 | "size": { 134 | "0": 210, 135 | "1": 46 136 | }, 137 | "flags": {}, 138 | "order": 10, 139 | "mode": 0, 140 | "inputs": [ 141 | { 142 | "name": "samples", 143 | "type": "LATENT", 144 | "link": 21 145 | }, 146 | { 147 | "name": "vae", 148 | "type": "VAE", 149 | "link": 22, 150 | "slot_index": 1 151 | } 152 | ], 153 | "outputs": [ 154 | { 155 | "name": "IMAGE", 156 | "type": "IMAGE", 157 | "links": [ 158 | 29 159 | ], 160 | "shape": 3, 161 | "slot_index": 0 162 | } 163 | ], 164 | "properties": { 165 | "Node name for S&R": "VAEDecode" 166 | } 167 | }, 168 | { 169 | "id": 20, 170 | "type": "PreviewImage", 171 | "pos": [ 172 | 1558, 173 | 189 174 | ], 175 | "size": { 176 | "0": 611.2340087890625, 177 | "1": 633.9354858398438 178 | }, 179 | "flags": {}, 180 | "order": 11, 181 | "mode": 0, 182 | "inputs": [ 183 | { 184 | "name": "images", 185 | "type": "IMAGE", 186 | "link": 29 187 | } 188 | ], 189 | "properties": { 190 | "Node name for S&R": "PreviewImage" 191 | } 192 | }, 193 | { 194 | "id": 3, 195 | "type": "KSampler", 196 | "pos": [ 197 | 913, 198 | 181 199 | ], 200 | "size": { 201 | "0": 315, 202 | "1": 262 203 | }, 204 | "flags": {}, 205 | "order": 9, 206 | "mode": 0, 207 | "inputs": [ 208 | { 209 | "name": "model", 210 | "type": "MODEL", 211 | "link": 62 212 | }, 213 | { 214 | "name": "positive", 215 | "type": "CONDITIONING", 216 | "link": 63 217 | }, 218 | { 219 | "name": "negative", 220 | "type": "CONDITIONING", 221 | "link": 64 222 | }, 223 | { 224 | "name": "latent_image", 225 | "type": "LATENT", 226 | "link": 2 227 | } 228 | ], 229 | "outputs": [ 230 | { 231 | "name": "LATENT", 232 | "type": "LATENT", 233 | "links": [ 234 | 21 235 | ], 236 | "slot_index": 0 237 | } 238 | ], 239 | "properties": { 240 | "Node name for S&R": "KSampler" 241 | }, 242 | "widgets_values": [ 243 | 462370085958750, 244 | "fixed", 245 | 20, 246 | 8, 247 | "euler", 248 | "normal", 249 | 1 250 | ] 251 | }, 252 | { 253 | "id": 38, 254 | "type": "LoadImage", 255 | "pos": [ 256 | -137, 257 | -388 258 | ], 259 | "size": { 260 | "0": 288.47406005859375, 261 | "1": 317.46051025390625 262 | }, 263 | "flags": {}, 264 | "order": 2, 265 | "mode": 0, 266 | "outputs": [ 267 | { 268 | "name": "IMAGE", 269 | "type": "IMAGE", 270 | "links": [ 271 | 59 272 | ], 273 | "shape": 3 274 | }, 275 | { 276 | "name": "MASK", 277 | "type": "MASK", 278 | "links": null, 279 | "shape": 3 280 | } 281 | ], 282 | "properties": { 283 | "Node name for S&R": "LoadImage" 284 | }, 285 | "widgets_values": [ 286 | "blended.png", 287 | "image" 288 | ] 289 | }, 290 | { 291 | "id": 39, 292 | "type": "VAEEncode", 293 | "pos": [ 294 | 201, 295 | -391 296 | ], 297 | "size": { 298 | "0": 210, 299 | "1": 46 300 | }, 301 | "flags": {}, 302 | "order": 6, 303 | "mode": 0, 304 | "inputs": [ 305 | { 306 | "name": "pixels", 307 | "type": "IMAGE", 308 | "link": 59, 309 | "slot_index": 0 310 | }, 311 | { 312 | "name": "vae", 313 | "type": "VAE", 314 | "link": 58, 315 | "slot_index": 1 316 | } 317 | ], 318 | "outputs": [ 319 | { 320 | "name": "LATENT", 321 | "type": "LATENT", 322 | "links": [ 323 | 60 324 | ], 325 | "shape": 3, 326 | "slot_index": 0 327 | } 328 | ], 329 | "properties": { 330 | "Node name for S&R": "VAEEncode" 331 | } 332 | }, 333 | { 334 | "id": 29, 335 | "type": "VAEEncode", 336 | "pos": [ 337 | 210, 338 | -20 339 | ], 340 | "size": { 341 | "0": 210, 342 | "1": 46 343 | }, 344 | "flags": {}, 345 | "order": 7, 346 | "mode": 0, 347 | "inputs": [ 348 | { 349 | "name": "pixels", 350 | "type": "IMAGE", 351 | "link": 53 352 | }, 353 | { 354 | "name": "vae", 355 | "type": "VAE", 356 | "link": 49, 357 | "slot_index": 1 358 | } 359 | ], 360 | "outputs": [ 361 | { 362 | "name": "LATENT", 363 | "type": "LATENT", 364 | "links": [ 365 | 61 366 | ], 367 | "shape": 3, 368 | "slot_index": 0 369 | } 370 | ], 371 | "properties": { 372 | "Node name for S&R": "VAEEncode" 373 | } 374 | }, 375 | { 376 | "id": 6, 377 | "type": "CLIPTextEncode", 378 | "pos": [ 379 | 415, 380 | 186 381 | ], 382 | "size": { 383 | "0": 422.84503173828125, 384 | "1": 164.31304931640625 385 | }, 386 | "flags": {}, 387 | "order": 4, 388 | "mode": 0, 389 | "inputs": [ 390 | { 391 | "name": "clip", 392 | "type": "CLIP", 393 | "link": 3 394 | } 395 | ], 396 | "outputs": [ 397 | { 398 | "name": "CONDITIONING", 399 | "type": "CONDITIONING", 400 | "links": [ 401 | 56 402 | ], 403 | "slot_index": 0 404 | } 405 | ], 406 | "properties": { 407 | "Node name for S&R": "CLIPTextEncode" 408 | }, 409 | "widgets_values": [ 410 | "a room, high quality\n\n" 411 | ] 412 | }, 413 | { 414 | "id": 30, 415 | "type": "LoadImage", 416 | "pos": [ 417 | -146, 418 | -22 419 | ], 420 | "size": { 421 | "0": 315, 422 | "1": 314 423 | }, 424 | "flags": {}, 425 | "order": 3, 426 | "mode": 0, 427 | "outputs": [ 428 | { 429 | "name": "IMAGE", 430 | "type": "IMAGE", 431 | "links": [ 432 | 53 433 | ], 434 | "shape": 3, 435 | "slot_index": 0 436 | }, 437 | { 438 | "name": "MASK", 439 | "type": "MASK", 440 | "links": null, 441 | "shape": 3 442 | } 443 | ], 444 | "properties": { 445 | "Node name for S&R": "LoadImage" 446 | }, 447 | "widgets_values": [ 448 | "dog.png", 449 | "image" 450 | ] 451 | }, 452 | { 453 | "id": 37, 454 | "type": "LayeredDiffusionDiffApply", 455 | "pos": [ 456 | 456, 457 | -44 458 | ], 459 | "size": { 460 | "0": 342.5999755859375, 461 | "1": 162 462 | }, 463 | "flags": {}, 464 | "order": 8, 465 | "mode": 0, 466 | "inputs": [ 467 | { 468 | "name": "model", 469 | "type": "MODEL", 470 | "link": 55, 471 | "slot_index": 0 472 | }, 473 | { 474 | "name": "cond", 475 | "type": "CONDITIONING", 476 | "link": 56, 477 | "slot_index": 1 478 | }, 479 | { 480 | "name": "uncond", 481 | "type": "CONDITIONING", 482 | "link": 57, 483 | "slot_index": 2 484 | }, 485 | { 486 | "name": "blended_latent", 487 | "type": "LATENT", 488 | "link": 60 489 | }, 490 | { 491 | "name": "latent", 492 | "type": "LATENT", 493 | "link": 61 494 | } 495 | ], 496 | "outputs": [ 497 | { 498 | "name": "MODEL", 499 | "type": "MODEL", 500 | "links": [ 501 | 62 502 | ], 503 | "shape": 3, 504 | "slot_index": 0 505 | }, 506 | { 507 | "name": "CONDITIONING", 508 | "type": "CONDITIONING", 509 | "links": [ 510 | 63 511 | ], 512 | "shape": 3, 513 | "slot_index": 1 514 | }, 515 | { 516 | "name": "CONDITIONING", 517 | "type": "CONDITIONING", 518 | "links": [ 519 | 64 520 | ], 521 | "shape": 3, 522 | "slot_index": 2 523 | } 524 | ], 525 | "properties": { 526 | "Node name for S&R": "LayeredDiffusionDiffApply" 527 | }, 528 | "widgets_values": [ 529 | "SDXL, Foreground", 530 | 1 531 | ], 532 | "color": "#232", 533 | "bgcolor": "#353" 534 | } 535 | ], 536 | "links": [ 537 | [ 538 | 2, 539 | 5, 540 | 0, 541 | 3, 542 | 3, 543 | "LATENT" 544 | ], 545 | [ 546 | 3, 547 | 4, 548 | 1, 549 | 6, 550 | 0, 551 | "CLIP" 552 | ], 553 | [ 554 | 5, 555 | 4, 556 | 1, 557 | 7, 558 | 0, 559 | "CLIP" 560 | ], 561 | [ 562 | 21, 563 | 3, 564 | 0, 565 | 14, 566 | 0, 567 | "LATENT" 568 | ], 569 | [ 570 | 22, 571 | 4, 572 | 2, 573 | 14, 574 | 1, 575 | "VAE" 576 | ], 577 | [ 578 | 29, 579 | 14, 580 | 0, 581 | 20, 582 | 0, 583 | "IMAGE" 584 | ], 585 | [ 586 | 49, 587 | 4, 588 | 2, 589 | 29, 590 | 1, 591 | "VAE" 592 | ], 593 | [ 594 | 53, 595 | 30, 596 | 0, 597 | 29, 598 | 0, 599 | "IMAGE" 600 | ], 601 | [ 602 | 55, 603 | 4, 604 | 0, 605 | 37, 606 | 0, 607 | "MODEL" 608 | ], 609 | [ 610 | 56, 611 | 6, 612 | 0, 613 | 37, 614 | 1, 615 | "CONDITIONING" 616 | ], 617 | [ 618 | 57, 619 | 7, 620 | 0, 621 | 37, 622 | 2, 623 | "CONDITIONING" 624 | ], 625 | [ 626 | 58, 627 | 4, 628 | 2, 629 | 39, 630 | 1, 631 | "VAE" 632 | ], 633 | [ 634 | 59, 635 | 38, 636 | 0, 637 | 39, 638 | 0, 639 | "IMAGE" 640 | ], 641 | [ 642 | 60, 643 | 39, 644 | 0, 645 | 37, 646 | 3, 647 | "LATENT" 648 | ], 649 | [ 650 | 61, 651 | 29, 652 | 0, 653 | 37, 654 | 4, 655 | "LATENT" 656 | ], 657 | [ 658 | 62, 659 | 37, 660 | 0, 661 | 3, 662 | 0, 663 | "MODEL" 664 | ], 665 | [ 666 | 63, 667 | 37, 668 | 1, 669 | 3, 670 | 1, 671 | "CONDITIONING" 672 | ], 673 | [ 674 | 64, 675 | 37, 676 | 2, 677 | 3, 678 | 2, 679 | "CONDITIONING" 680 | ] 681 | ], 682 | "groups": [], 683 | "config": {}, 684 | "extra": {}, 685 | "version": 0.4 686 | } -------------------------------------------------------------------------------- /example_workflows/layer_diffusion_fg_example.json: -------------------------------------------------------------------------------- 1 | { 2 | "last_node_id": 29, 3 | "last_link_id": 40, 4 | "nodes": [ 5 | { 6 | "id": 7, 7 | "type": "CLIPTextEncode", 8 | "pos": [ 9 | 413, 10 | 389 11 | ], 12 | "size": { 13 | "0": 425.27801513671875, 14 | "1": 180.6060791015625 15 | }, 16 | "flags": {}, 17 | "order": 4, 18 | "mode": 0, 19 | "inputs": [ 20 | { 21 | "name": "clip", 22 | "type": "CLIP", 23 | "link": 5 24 | } 25 | ], 26 | "outputs": [ 27 | { 28 | "name": "CONDITIONING", 29 | "type": "CONDITIONING", 30 | "links": [ 31 | 6 32 | ], 33 | "slot_index": 0 34 | } 35 | ], 36 | "properties": { 37 | "Node name for S&R": "CLIPTextEncode" 38 | }, 39 | "widgets_values": [ 40 | "text, watermark" 41 | ] 42 | }, 43 | { 44 | "id": 6, 45 | "type": "CLIPTextEncode", 46 | "pos": [ 47 | 415, 48 | 186 49 | ], 50 | "size": { 51 | "0": 422.84503173828125, 52 | "1": 164.31304931640625 53 | }, 54 | "flags": {}, 55 | "order": 3, 56 | "mode": 0, 57 | "inputs": [ 58 | { 59 | "name": "clip", 60 | "type": "CLIP", 61 | "link": 3 62 | } 63 | ], 64 | "outputs": [ 65 | { 66 | "name": "CONDITIONING", 67 | "type": "CONDITIONING", 68 | "links": [ 69 | 4 70 | ], 71 | "slot_index": 0 72 | } 73 | ], 74 | "properties": { 75 | "Node name for S&R": "CLIPTextEncode" 76 | }, 77 | "widgets_values": [ 78 | "beautiful scenery nature glass bottle landscape, , purple galaxy bottle," 79 | ] 80 | }, 81 | { 82 | "id": 4, 83 | "type": "CheckpointLoaderSimple", 84 | "pos": [ 85 | 5, 86 | 479 87 | ], 88 | "size": { 89 | "0": 315, 90 | "1": 98 91 | }, 92 | "flags": {}, 93 | "order": 0, 94 | "mode": 0, 95 | "outputs": [ 96 | { 97 | "name": "MODEL", 98 | "type": "MODEL", 99 | "links": [ 100 | 18 101 | ], 102 | "slot_index": 0 103 | }, 104 | { 105 | "name": "CLIP", 106 | "type": "CLIP", 107 | "links": [ 108 | 3, 109 | 5 110 | ], 111 | "slot_index": 1 112 | }, 113 | { 114 | "name": "VAE", 115 | "type": "VAE", 116 | "links": [ 117 | 22 118 | ], 119 | "slot_index": 2 120 | } 121 | ], 122 | "properties": { 123 | "Node name for S&R": "CheckpointLoaderSimple" 124 | }, 125 | "widgets_values": [ 126 | "juggernautXL_v8Rundiffusion.safetensors" 127 | ] 128 | }, 129 | { 130 | "id": 14, 131 | "type": "VAEDecode", 132 | "pos": [ 133 | 1275, 134 | 198 135 | ], 136 | "size": { 137 | "0": 210, 138 | "1": 46 139 | }, 140 | "flags": {}, 141 | "order": 6, 142 | "mode": 0, 143 | "inputs": [ 144 | { 145 | "name": "samples", 146 | "type": "LATENT", 147 | "link": 21 148 | }, 149 | { 150 | "name": "vae", 151 | "type": "VAE", 152 | "link": 22, 153 | "slot_index": 1 154 | } 155 | ], 156 | "outputs": [ 157 | { 158 | "name": "IMAGE", 159 | "type": "IMAGE", 160 | "links": [ 161 | 24, 162 | 29 163 | ], 164 | "shape": 3, 165 | "slot_index": 0 166 | } 167 | ], 168 | "properties": { 169 | "Node name for S&R": "VAEDecode" 170 | } 171 | }, 172 | { 173 | "id": 20, 174 | "type": "PreviewImage", 175 | "pos": [ 176 | 1547, 177 | 472 178 | ], 179 | "size": { 180 | "0": 289.6058349609375, 181 | "1": 299.6588134765625 182 | }, 183 | "flags": {}, 184 | "order": 8, 185 | "mode": 0, 186 | "inputs": [ 187 | { 188 | "name": "images", 189 | "type": "IMAGE", 190 | "link": 29 191 | } 192 | ], 193 | "properties": { 194 | "Node name for S&R": "PreviewImage" 195 | } 196 | }, 197 | { 198 | "id": 5, 199 | "type": "EmptyLatentImage", 200 | "pos": [ 201 | 475, 202 | 707 203 | ], 204 | "size": { 205 | "0": 315, 206 | "1": 106 207 | }, 208 | "flags": {}, 209 | "order": 1, 210 | "mode": 0, 211 | "outputs": [ 212 | { 213 | "name": "LATENT", 214 | "type": "LATENT", 215 | "links": [ 216 | 2 217 | ], 218 | "slot_index": 0 219 | } 220 | ], 221 | "properties": { 222 | "Node name for S&R": "EmptyLatentImage" 223 | }, 224 | "widgets_values": [ 225 | 1024, 226 | 1024, 227 | 1 228 | ] 229 | }, 230 | { 231 | "id": 3, 232 | "type": "KSampler", 233 | "pos": [ 234 | 911, 235 | 198 236 | ], 237 | "size": { 238 | "0": 315, 239 | "1": 262 240 | }, 241 | "flags": {}, 242 | "order": 5, 243 | "mode": 0, 244 | "inputs": [ 245 | { 246 | "name": "model", 247 | "type": "MODEL", 248 | "link": 19 249 | }, 250 | { 251 | "name": "positive", 252 | "type": "CONDITIONING", 253 | "link": 4 254 | }, 255 | { 256 | "name": "negative", 257 | "type": "CONDITIONING", 258 | "link": 6 259 | }, 260 | { 261 | "name": "latent_image", 262 | "type": "LATENT", 263 | "link": 2 264 | } 265 | ], 266 | "outputs": [ 267 | { 268 | "name": "LATENT", 269 | "type": "LATENT", 270 | "links": [ 271 | 21, 272 | 23 273 | ], 274 | "slot_index": 0 275 | } 276 | ], 277 | "properties": { 278 | "Node name for S&R": "KSampler" 279 | }, 280 | "widgets_values": [ 281 | 984560333937969, 282 | "randomize", 283 | 20, 284 | 8, 285 | "euler", 286 | "normal", 287 | 1 288 | ] 289 | }, 290 | { 291 | "id": 25, 292 | "type": "PreviewImage", 293 | "pos": [ 294 | 2244, 295 | 194 296 | ], 297 | "size": { 298 | "0": 289.6058349609375, 299 | "1": 299.6588134765625 300 | }, 301 | "flags": {}, 302 | "order": 12, 303 | "mode": 0, 304 | "inputs": [ 305 | { 306 | "name": "images", 307 | "type": "IMAGE", 308 | "link": 33 309 | } 310 | ], 311 | "properties": { 312 | "Node name for S&R": "PreviewImage" 313 | } 314 | }, 315 | { 316 | "id": 24, 317 | "type": "MaskToImage", 318 | "pos": [ 319 | 1921, 320 | 192 321 | ], 322 | "size": { 323 | "0": 210, 324 | "1": 26 325 | }, 326 | "flags": {}, 327 | "order": 10, 328 | "mode": 0, 329 | "inputs": [ 330 | { 331 | "name": "mask", 332 | "type": "MASK", 333 | "link": 32 334 | } 335 | ], 336 | "outputs": [ 337 | { 338 | "name": "IMAGE", 339 | "type": "IMAGE", 340 | "links": [ 341 | 33 342 | ], 343 | "shape": 3, 344 | "slot_index": 0 345 | } 346 | ], 347 | "properties": { 348 | "Node name for S&R": "MaskToImage" 349 | } 350 | }, 351 | { 352 | "id": 23, 353 | "type": "PreviewImage", 354 | "pos": [ 355 | 1965, 356 | 479 357 | ], 358 | "size": { 359 | "0": 289.6058349609375, 360 | "1": 299.6588134765625 361 | }, 362 | "flags": {}, 363 | "order": 9, 364 | "mode": 0, 365 | "inputs": [ 366 | { 367 | "name": "images", 368 | "type": "IMAGE", 369 | "link": 31 370 | } 371 | ], 372 | "properties": { 373 | "Node name for S&R": "PreviewImage" 374 | } 375 | }, 376 | { 377 | "id": 27, 378 | "type": "PreviewImage", 379 | "pos": [ 380 | 2243, 381 | -164 382 | ], 383 | "size": { 384 | "0": 289.6058349609375, 385 | "1": 299.6588134765625 386 | }, 387 | "flags": {}, 388 | "order": 14, 389 | "mode": 0, 390 | "inputs": [ 391 | { 392 | "name": "images", 393 | "type": "IMAGE", 394 | "link": 40 395 | } 396 | ], 397 | "properties": { 398 | "Node name for S&R": "PreviewImage" 399 | } 400 | }, 401 | { 402 | "id": 15, 403 | "type": "LayeredDiffusionDecode", 404 | "pos": [ 405 | 1586, 406 | 195 407 | ], 408 | "size": { 409 | "0": 210, 410 | "1": 102 411 | }, 412 | "flags": {}, 413 | "order": 7, 414 | "mode": 0, 415 | "inputs": [ 416 | { 417 | "name": "samples", 418 | "type": "LATENT", 419 | "link": 23 420 | }, 421 | { 422 | "name": "images", 423 | "type": "IMAGE", 424 | "link": 24 425 | } 426 | ], 427 | "outputs": [ 428 | { 429 | "name": "IMAGE", 430 | "type": "IMAGE", 431 | "links": [ 432 | 31, 433 | 37 434 | ], 435 | "shape": 3, 436 | "slot_index": 0 437 | }, 438 | { 439 | "name": "MASK", 440 | "type": "MASK", 441 | "links": [ 442 | 32, 443 | 38 444 | ], 445 | "shape": 3, 446 | "slot_index": 1 447 | } 448 | ], 449 | "properties": { 450 | "Node name for S&R": "LayeredDiffusionDecode" 451 | }, 452 | "widgets_values": [ 453 | "SDXL", 454 | 16 455 | ] 456 | }, 457 | { 458 | "id": 28, 459 | "type": "JoinImageWithAlpha", 460 | "pos": [ 461 | 1928, 462 | -59 463 | ], 464 | "size": { 465 | "0": 210, 466 | "1": 46 467 | }, 468 | "flags": {}, 469 | "order": 13, 470 | "mode": 0, 471 | "inputs": [ 472 | { 473 | "name": "image", 474 | "type": "IMAGE", 475 | "link": 37 476 | }, 477 | { 478 | "name": "alpha", 479 | "type": "MASK", 480 | "link": 39 481 | } 482 | ], 483 | "outputs": [ 484 | { 485 | "name": "IMAGE", 486 | "type": "IMAGE", 487 | "links": [ 488 | 40 489 | ], 490 | "shape": 3, 491 | "slot_index": 0 492 | } 493 | ], 494 | "properties": { 495 | "Node name for S&R": "JoinImageWithAlpha" 496 | } 497 | }, 498 | { 499 | "id": 29, 500 | "type": "InvertMask", 501 | "pos": [ 502 | 1931, 503 | 44 504 | ], 505 | "size": { 506 | "0": 210, 507 | "1": 26 508 | }, 509 | "flags": {}, 510 | "order": 11, 511 | "mode": 0, 512 | "inputs": [ 513 | { 514 | "name": "mask", 515 | "type": "MASK", 516 | "link": 38 517 | } 518 | ], 519 | "outputs": [ 520 | { 521 | "name": "MASK", 522 | "type": "MASK", 523 | "links": [ 524 | 39 525 | ], 526 | "shape": 3, 527 | "slot_index": 0 528 | } 529 | ], 530 | "properties": { 531 | "Node name for S&R": "InvertMask" 532 | } 533 | }, 534 | { 535 | "id": 13, 536 | "type": "LayeredDiffusionApply", 537 | "pos": [ 538 | 468, 539 | -2 540 | ], 541 | "size": { 542 | "0": 327.8314208984375, 543 | "1": 106.42147827148438 544 | }, 545 | "flags": {}, 546 | "order": 2, 547 | "mode": 0, 548 | "inputs": [ 549 | { 550 | "name": "model", 551 | "type": "MODEL", 552 | "link": 18 553 | } 554 | ], 555 | "outputs": [ 556 | { 557 | "name": "MODEL", 558 | "type": "MODEL", 559 | "links": [ 560 | 19 561 | ], 562 | "shape": 3, 563 | "slot_index": 0 564 | } 565 | ], 566 | "properties": { 567 | "Node name for S&R": "LayeredDiffusionApply" 568 | }, 569 | "widgets_values": [ 570 | "SDXL, Conv Injection", 571 | 1 572 | ] 573 | } 574 | ], 575 | "links": [ 576 | [ 577 | 2, 578 | 5, 579 | 0, 580 | 3, 581 | 3, 582 | "LATENT" 583 | ], 584 | [ 585 | 3, 586 | 4, 587 | 1, 588 | 6, 589 | 0, 590 | "CLIP" 591 | ], 592 | [ 593 | 4, 594 | 6, 595 | 0, 596 | 3, 597 | 1, 598 | "CONDITIONING" 599 | ], 600 | [ 601 | 5, 602 | 4, 603 | 1, 604 | 7, 605 | 0, 606 | "CLIP" 607 | ], 608 | [ 609 | 6, 610 | 7, 611 | 0, 612 | 3, 613 | 2, 614 | "CONDITIONING" 615 | ], 616 | [ 617 | 18, 618 | 4, 619 | 0, 620 | 13, 621 | 0, 622 | "MODEL" 623 | ], 624 | [ 625 | 19, 626 | 13, 627 | 0, 628 | 3, 629 | 0, 630 | "MODEL" 631 | ], 632 | [ 633 | 21, 634 | 3, 635 | 0, 636 | 14, 637 | 0, 638 | "LATENT" 639 | ], 640 | [ 641 | 22, 642 | 4, 643 | 2, 644 | 14, 645 | 1, 646 | "VAE" 647 | ], 648 | [ 649 | 23, 650 | 3, 651 | 0, 652 | 15, 653 | 0, 654 | "LATENT" 655 | ], 656 | [ 657 | 24, 658 | 14, 659 | 0, 660 | 15, 661 | 1, 662 | "IMAGE" 663 | ], 664 | [ 665 | 29, 666 | 14, 667 | 0, 668 | 20, 669 | 0, 670 | "IMAGE" 671 | ], 672 | [ 673 | 31, 674 | 15, 675 | 0, 676 | 23, 677 | 0, 678 | "IMAGE" 679 | ], 680 | [ 681 | 32, 682 | 15, 683 | 1, 684 | 24, 685 | 0, 686 | "MASK" 687 | ], 688 | [ 689 | 33, 690 | 24, 691 | 0, 692 | 25, 693 | 0, 694 | "IMAGE" 695 | ], 696 | [ 697 | 37, 698 | 15, 699 | 0, 700 | 28, 701 | 0, 702 | "IMAGE" 703 | ], 704 | [ 705 | 38, 706 | 15, 707 | 1, 708 | 29, 709 | 0, 710 | "MASK" 711 | ], 712 | [ 713 | 39, 714 | 29, 715 | 0, 716 | 28, 717 | 1, 718 | "MASK" 719 | ], 720 | [ 721 | 40, 722 | 28, 723 | 0, 724 | 27, 725 | 0, 726 | "IMAGE" 727 | ] 728 | ], 729 | "groups": [], 730 | "config": {}, 731 | "extra": {}, 732 | "version": 0.4 733 | } -------------------------------------------------------------------------------- /example_workflows/layer_diffusion_fg_example_rgba.json: -------------------------------------------------------------------------------- 1 | { 2 | "last_node_id": 36, 3 | "last_link_id": 51, 4 | "nodes": [ 5 | { 6 | "id": 7, 7 | "type": "CLIPTextEncode", 8 | "pos": [ 9 | 413, 10 | 389 11 | ], 12 | "size": { 13 | "0": 425.27801513671875, 14 | "1": 180.6060791015625 15 | }, 16 | "flags": {}, 17 | "order": 4, 18 | "mode": 0, 19 | "inputs": [ 20 | { 21 | "name": "clip", 22 | "type": "CLIP", 23 | "link": 5 24 | } 25 | ], 26 | "outputs": [ 27 | { 28 | "name": "CONDITIONING", 29 | "type": "CONDITIONING", 30 | "links": [ 31 | 6 32 | ], 33 | "slot_index": 0 34 | } 35 | ], 36 | "properties": { 37 | "Node name for S&R": "CLIPTextEncode" 38 | }, 39 | "widgets_values": [ 40 | "text, watermark" 41 | ] 42 | }, 43 | { 44 | "id": 6, 45 | "type": "CLIPTextEncode", 46 | "pos": [ 47 | 415, 48 | 186 49 | ], 50 | "size": { 51 | "0": 422.84503173828125, 52 | "1": 164.31304931640625 53 | }, 54 | "flags": {}, 55 | "order": 3, 56 | "mode": 0, 57 | "inputs": [ 58 | { 59 | "name": "clip", 60 | "type": "CLIP", 61 | "link": 3 62 | } 63 | ], 64 | "outputs": [ 65 | { 66 | "name": "CONDITIONING", 67 | "type": "CONDITIONING", 68 | "links": [ 69 | 4 70 | ], 71 | "slot_index": 0 72 | } 73 | ], 74 | "properties": { 75 | "Node name for S&R": "CLIPTextEncode" 76 | }, 77 | "widgets_values": [ 78 | "beautiful scenery nature glass bottle landscape, , purple galaxy bottle," 79 | ] 80 | }, 81 | { 82 | "id": 4, 83 | "type": "CheckpointLoaderSimple", 84 | "pos": [ 85 | 5, 86 | 479 87 | ], 88 | "size": { 89 | "0": 315, 90 | "1": 98 91 | }, 92 | "flags": {}, 93 | "order": 0, 94 | "mode": 0, 95 | "outputs": [ 96 | { 97 | "name": "MODEL", 98 | "type": "MODEL", 99 | "links": [ 100 | 18 101 | ], 102 | "slot_index": 0 103 | }, 104 | { 105 | "name": "CLIP", 106 | "type": "CLIP", 107 | "links": [ 108 | 3, 109 | 5 110 | ], 111 | "slot_index": 1 112 | }, 113 | { 114 | "name": "VAE", 115 | "type": "VAE", 116 | "links": [ 117 | 22 118 | ], 119 | "slot_index": 2 120 | } 121 | ], 122 | "properties": { 123 | "Node name for S&R": "CheckpointLoaderSimple" 124 | }, 125 | "widgets_values": [ 126 | "juggernautXL_v8Rundiffusion.safetensors" 127 | ] 128 | }, 129 | { 130 | "id": 14, 131 | "type": "VAEDecode", 132 | "pos": [ 133 | 1275, 134 | 198 135 | ], 136 | "size": { 137 | "0": 210, 138 | "1": 46 139 | }, 140 | "flags": {}, 141 | "order": 6, 142 | "mode": 0, 143 | "inputs": [ 144 | { 145 | "name": "samples", 146 | "type": "LATENT", 147 | "link": 21 148 | }, 149 | { 150 | "name": "vae", 151 | "type": "VAE", 152 | "link": 22, 153 | "slot_index": 1 154 | } 155 | ], 156 | "outputs": [ 157 | { 158 | "name": "IMAGE", 159 | "type": "IMAGE", 160 | "links": [ 161 | 29, 162 | 50 163 | ], 164 | "shape": 3, 165 | "slot_index": 0 166 | } 167 | ], 168 | "properties": { 169 | "Node name for S&R": "VAEDecode" 170 | } 171 | }, 172 | { 173 | "id": 3, 174 | "type": "KSampler", 175 | "pos": [ 176 | 911, 177 | 198 178 | ], 179 | "size": { 180 | "0": 315, 181 | "1": 262 182 | }, 183 | "flags": {}, 184 | "order": 5, 185 | "mode": 0, 186 | "inputs": [ 187 | { 188 | "name": "model", 189 | "type": "MODEL", 190 | "link": 19 191 | }, 192 | { 193 | "name": "positive", 194 | "type": "CONDITIONING", 195 | "link": 4 196 | }, 197 | { 198 | "name": "negative", 199 | "type": "CONDITIONING", 200 | "link": 6 201 | }, 202 | { 203 | "name": "latent_image", 204 | "type": "LATENT", 205 | "link": 2 206 | } 207 | ], 208 | "outputs": [ 209 | { 210 | "name": "LATENT", 211 | "type": "LATENT", 212 | "links": [ 213 | 21, 214 | 49 215 | ], 216 | "slot_index": 0 217 | } 218 | ], 219 | "properties": { 220 | "Node name for S&R": "KSampler" 221 | }, 222 | "widgets_values": [ 223 | 1029477926308287, 224 | "randomize", 225 | 20, 226 | 8, 227 | "euler", 228 | "normal", 229 | 1 230 | ] 231 | }, 232 | { 233 | "id": 5, 234 | "type": "EmptyLatentImage", 235 | "pos": [ 236 | 480, 237 | 691 238 | ], 239 | "size": { 240 | "0": 315, 241 | "1": 106 242 | }, 243 | "flags": {}, 244 | "order": 1, 245 | "mode": 0, 246 | "outputs": [ 247 | { 248 | "name": "LATENT", 249 | "type": "LATENT", 250 | "links": [ 251 | 2 252 | ], 253 | "slot_index": 0 254 | } 255 | ], 256 | "properties": { 257 | "Node name for S&R": "EmptyLatentImage" 258 | }, 259 | "widgets_values": [ 260 | 1024, 261 | 1024, 262 | 1 263 | ] 264 | }, 265 | { 266 | "id": 36, 267 | "type": "LayeredDiffusionDecodeRGBA", 268 | "pos": [ 269 | 1589, 270 | 199 271 | ], 272 | "size": { 273 | "0": 243.60000610351562, 274 | "1": 102 275 | }, 276 | "flags": {}, 277 | "order": 8, 278 | "mode": 0, 279 | "inputs": [ 280 | { 281 | "name": "samples", 282 | "type": "LATENT", 283 | "link": 49 284 | }, 285 | { 286 | "name": "images", 287 | "type": "IMAGE", 288 | "link": 50 289 | } 290 | ], 291 | "outputs": [ 292 | { 293 | "name": "IMAGE", 294 | "type": "IMAGE", 295 | "links": [ 296 | 51 297 | ], 298 | "shape": 3 299 | } 300 | ], 301 | "properties": { 302 | "Node name for S&R": "LayeredDiffusionDecodeRGBA" 303 | }, 304 | "widgets_values": [ 305 | "SDXL", 306 | 16 307 | ] 308 | }, 309 | { 310 | "id": 27, 311 | "type": "PreviewImage", 312 | "pos": [ 313 | 1930, 314 | 197 315 | ], 316 | "size": { 317 | "0": 289.6058349609375, 318 | "1": 299.6588134765625 319 | }, 320 | "flags": {}, 321 | "order": 9, 322 | "mode": 0, 323 | "inputs": [ 324 | { 325 | "name": "images", 326 | "type": "IMAGE", 327 | "link": 51, 328 | "slot_index": 0 329 | } 330 | ], 331 | "properties": { 332 | "Node name for S&R": "PreviewImage" 333 | } 334 | }, 335 | { 336 | "id": 20, 337 | "type": "PreviewImage", 338 | "pos": [ 339 | 1570, 340 | 365 341 | ], 342 | "size": { 343 | "0": 289.6058349609375, 344 | "1": 299.6588134765625 345 | }, 346 | "flags": {}, 347 | "order": 7, 348 | "mode": 0, 349 | "inputs": [ 350 | { 351 | "name": "images", 352 | "type": "IMAGE", 353 | "link": 29 354 | } 355 | ], 356 | "properties": { 357 | "Node name for S&R": "PreviewImage" 358 | } 359 | }, 360 | { 361 | "id": 13, 362 | "type": "LayeredDiffusionApply", 363 | "pos": [ 364 | 468, 365 | -2 366 | ], 367 | "size": { 368 | "0": 327.8314208984375, 369 | "1": 106.42147827148438 370 | }, 371 | "flags": {}, 372 | "order": 2, 373 | "mode": 0, 374 | "inputs": [ 375 | { 376 | "name": "model", 377 | "type": "MODEL", 378 | "link": 18 379 | } 380 | ], 381 | "outputs": [ 382 | { 383 | "name": "MODEL", 384 | "type": "MODEL", 385 | "links": [ 386 | 19 387 | ], 388 | "shape": 3, 389 | "slot_index": 0 390 | } 391 | ], 392 | "properties": { 393 | "Node name for S&R": "LayeredDiffusionApply" 394 | }, 395 | "widgets_values": [ 396 | "SDXL, Conv Injection", 397 | 1 398 | ] 399 | } 400 | ], 401 | "links": [ 402 | [ 403 | 2, 404 | 5, 405 | 0, 406 | 3, 407 | 3, 408 | "LATENT" 409 | ], 410 | [ 411 | 3, 412 | 4, 413 | 1, 414 | 6, 415 | 0, 416 | "CLIP" 417 | ], 418 | [ 419 | 4, 420 | 6, 421 | 0, 422 | 3, 423 | 1, 424 | "CONDITIONING" 425 | ], 426 | [ 427 | 5, 428 | 4, 429 | 1, 430 | 7, 431 | 0, 432 | "CLIP" 433 | ], 434 | [ 435 | 6, 436 | 7, 437 | 0, 438 | 3, 439 | 2, 440 | "CONDITIONING" 441 | ], 442 | [ 443 | 18, 444 | 4, 445 | 0, 446 | 13, 447 | 0, 448 | "MODEL" 449 | ], 450 | [ 451 | 19, 452 | 13, 453 | 0, 454 | 3, 455 | 0, 456 | "MODEL" 457 | ], 458 | [ 459 | 21, 460 | 3, 461 | 0, 462 | 14, 463 | 0, 464 | "LATENT" 465 | ], 466 | [ 467 | 22, 468 | 4, 469 | 2, 470 | 14, 471 | 1, 472 | "VAE" 473 | ], 474 | [ 475 | 29, 476 | 14, 477 | 0, 478 | 20, 479 | 0, 480 | "IMAGE" 481 | ], 482 | [ 483 | 49, 484 | 3, 485 | 0, 486 | 36, 487 | 0, 488 | "LATENT" 489 | ], 490 | [ 491 | 50, 492 | 14, 493 | 0, 494 | 36, 495 | 1, 496 | "IMAGE" 497 | ], 498 | [ 499 | 51, 500 | 36, 501 | 0, 502 | 27, 503 | 0, 504 | "IMAGE" 505 | ] 506 | ], 507 | "groups": [], 508 | "config": {}, 509 | "extra": {}, 510 | "version": 0.4 511 | } -------------------------------------------------------------------------------- /example_workflows/layer_diffusion_joint.json: -------------------------------------------------------------------------------- 1 | { 2 | "last_node_id": 27, 3 | "last_link_id": 42, 4 | "nodes": [ 5 | { 6 | "id": 7, 7 | "type": "CLIPTextEncode", 8 | "pos": [ 9 | 413, 10 | 389 11 | ], 12 | "size": { 13 | "0": 425.27801513671875, 14 | "1": 180.6060791015625 15 | }, 16 | "flags": {}, 17 | "order": 3, 18 | "mode": 0, 19 | "inputs": [ 20 | { 21 | "name": "clip", 22 | "type": "CLIP", 23 | "link": 5 24 | } 25 | ], 26 | "outputs": [ 27 | { 28 | "name": "CONDITIONING", 29 | "type": "CONDITIONING", 30 | "links": [ 31 | 6 32 | ], 33 | "slot_index": 0 34 | } 35 | ], 36 | "properties": { 37 | "Node name for S&R": "CLIPTextEncode" 38 | }, 39 | "widgets_values": [ 40 | "text, watermark" 41 | ] 42 | }, 43 | { 44 | "id": 3, 45 | "type": "KSampler", 46 | "pos": [ 47 | 891, 48 | 192 49 | ], 50 | "size": { 51 | "0": 315, 52 | "1": 262 53 | }, 54 | "flags": {}, 55 | "order": 7, 56 | "mode": 0, 57 | "inputs": [ 58 | { 59 | "name": "model", 60 | "type": "MODEL", 61 | "link": 32 62 | }, 63 | { 64 | "name": "positive", 65 | "type": "CONDITIONING", 66 | "link": 4 67 | }, 68 | { 69 | "name": "negative", 70 | "type": "CONDITIONING", 71 | "link": 6 72 | }, 73 | { 74 | "name": "latent_image", 75 | "type": "LATENT", 76 | "link": 2 77 | } 78 | ], 79 | "outputs": [ 80 | { 81 | "name": "LATENT", 82 | "type": "LATENT", 83 | "links": [ 84 | 21, 85 | 33 86 | ], 87 | "slot_index": 0 88 | } 89 | ], 90 | "properties": { 91 | "Node name for S&R": "KSampler" 92 | }, 93 | "widgets_values": [ 94 | 960762378448318, 95 | "randomize", 96 | 20, 97 | 8, 98 | "euler", 99 | "normal", 100 | 1 101 | ] 102 | }, 103 | { 104 | "id": 14, 105 | "type": "VAEDecode", 106 | "pos": [ 107 | 1275, 108 | 198 109 | ], 110 | "size": { 111 | "0": 210, 112 | "1": 46 113 | }, 114 | "flags": {}, 115 | "order": 8, 116 | "mode": 0, 117 | "inputs": [ 118 | { 119 | "name": "samples", 120 | "type": "LATENT", 121 | "link": 21 122 | }, 123 | { 124 | "name": "vae", 125 | "type": "VAE", 126 | "link": 22, 127 | "slot_index": 1 128 | } 129 | ], 130 | "outputs": [ 131 | { 132 | "name": "IMAGE", 133 | "type": "IMAGE", 134 | "links": [ 135 | 34 136 | ], 137 | "shape": 3, 138 | "slot_index": 0 139 | } 140 | ], 141 | "properties": { 142 | "Node name for S&R": "VAEDecode" 143 | } 144 | }, 145 | { 146 | "id": 4, 147 | "type": "CheckpointLoaderSimple", 148 | "pos": [ 149 | 5, 150 | 479 151 | ], 152 | "size": { 153 | "0": 315, 154 | "1": 98 155 | }, 156 | "flags": {}, 157 | "order": 0, 158 | "mode": 0, 159 | "outputs": [ 160 | { 161 | "name": "MODEL", 162 | "type": "MODEL", 163 | "links": [ 164 | 31 165 | ], 166 | "slot_index": 0 167 | }, 168 | { 169 | "name": "CLIP", 170 | "type": "CLIP", 171 | "links": [ 172 | 3, 173 | 5, 174 | 41, 175 | 42 176 | ], 177 | "slot_index": 1 178 | }, 179 | { 180 | "name": "VAE", 181 | "type": "VAE", 182 | "links": [ 183 | 22 184 | ], 185 | "slot_index": 2 186 | } 187 | ], 188 | "properties": { 189 | "Node name for S&R": "CheckpointLoaderSimple" 190 | }, 191 | "widgets_values": [ 192 | "realisticVisionV20_v20.safetensors" 193 | ] 194 | }, 195 | { 196 | "id": 27, 197 | "type": "CLIPTextEncode", 198 | "pos": [ 199 | -20, 200 | -20 201 | ], 202 | "size": { 203 | "0": 422.84503173828125, 204 | "1": 164.31304931640625 205 | }, 206 | "flags": {}, 207 | "order": 5, 208 | "mode": 0, 209 | "inputs": [ 210 | { 211 | "name": "clip", 212 | "type": "CLIP", 213 | "link": 42, 214 | "slot_index": 0 215 | } 216 | ], 217 | "outputs": [ 218 | { 219 | "name": "CONDITIONING", 220 | "type": "CONDITIONING", 221 | "links": [ 222 | 40 223 | ], 224 | "slot_index": 0 225 | } 226 | ], 227 | "properties": { 228 | "Node name for S&R": "CLIPTextEncode" 229 | }, 230 | "widgets_values": [ 231 | "a cozy room" 232 | ] 233 | }, 234 | { 235 | "id": 21, 236 | "type": "LayeredDiffusionJointApply", 237 | "pos": [ 238 | 469, 239 | -9 240 | ], 241 | "size": { 242 | "0": 315, 243 | "1": 118 244 | }, 245 | "flags": {}, 246 | "order": 6, 247 | "mode": 0, 248 | "inputs": [ 249 | { 250 | "name": "model", 251 | "type": "MODEL", 252 | "link": 31, 253 | "slot_index": 0 254 | }, 255 | { 256 | "name": "fg_cond", 257 | "type": "CONDITIONING", 258 | "link": 39 259 | }, 260 | { 261 | "name": "bg_cond", 262 | "type": "CONDITIONING", 263 | "link": 40 264 | }, 265 | { 266 | "name": "blended_cond", 267 | "type": "CONDITIONING", 268 | "link": 38 269 | } 270 | ], 271 | "outputs": [ 272 | { 273 | "name": "MODEL", 274 | "type": "MODEL", 275 | "links": [ 276 | 32 277 | ], 278 | "shape": 3, 279 | "slot_index": 0 280 | } 281 | ], 282 | "properties": { 283 | "Node name for S&R": "LayeredDiffusionJointApply" 284 | }, 285 | "widgets_values": [ 286 | "SD15, attn_sharing, Batch size (3N)" 287 | ], 288 | "color": "#232", 289 | "bgcolor": "#353" 290 | }, 291 | { 292 | "id": 22, 293 | "type": "LayeredDiffusionDecodeSplit", 294 | "pos": [ 295 | 1534, 296 | 193 297 | ], 298 | "size": { 299 | "0": 315, 300 | "1": 146 301 | }, 302 | "flags": {}, 303 | "order": 9, 304 | "mode": 0, 305 | "inputs": [ 306 | { 307 | "name": "samples", 308 | "type": "LATENT", 309 | "link": 33, 310 | "slot_index": 0 311 | }, 312 | { 313 | "name": "images", 314 | "type": "IMAGE", 315 | "link": 34 316 | } 317 | ], 318 | "outputs": [ 319 | { 320 | "name": "IMAGE", 321 | "type": "IMAGE", 322 | "links": [ 323 | 35 324 | ], 325 | "shape": 3, 326 | "slot_index": 0 327 | }, 328 | { 329 | "name": "IMAGE", 330 | "type": "IMAGE", 331 | "links": [ 332 | 36 333 | ], 334 | "shape": 3, 335 | "slot_index": 1 336 | }, 337 | { 338 | "name": "IMAGE", 339 | "type": "IMAGE", 340 | "links": [ 341 | 37 342 | ], 343 | "shape": 3, 344 | "slot_index": 2 345 | } 346 | ], 347 | "properties": { 348 | "Node name for S&R": "LayeredDiffusionDecodeSplit" 349 | }, 350 | "widgets_values": [ 351 | 3, 352 | "SD15", 353 | 16 354 | ], 355 | "color": "#232", 356 | "bgcolor": "#353" 357 | }, 358 | { 359 | "id": 5, 360 | "type": "EmptyLatentImage", 361 | "pos": [ 362 | 466, 363 | 645 364 | ], 365 | "size": { 366 | "0": 315, 367 | "1": 106 368 | }, 369 | "flags": {}, 370 | "order": 1, 371 | "mode": 0, 372 | "outputs": [ 373 | { 374 | "name": "LATENT", 375 | "type": "LATENT", 376 | "links": [ 377 | 2 378 | ], 379 | "slot_index": 0 380 | } 381 | ], 382 | "properties": { 383 | "Node name for S&R": "EmptyLatentImage" 384 | }, 385 | "widgets_values": [ 386 | 512, 387 | 512, 388 | 6 389 | ] 390 | }, 391 | { 392 | "id": 26, 393 | "type": "CLIPTextEncode", 394 | "pos": [ 395 | -20, 396 | -235 397 | ], 398 | "size": { 399 | "0": 422.84503173828125, 400 | "1": 164.31304931640625 401 | }, 402 | "flags": {}, 403 | "order": 4, 404 | "mode": 0, 405 | "inputs": [ 406 | { 407 | "name": "clip", 408 | "type": "CLIP", 409 | "link": 41, 410 | "slot_index": 0 411 | } 412 | ], 413 | "outputs": [ 414 | { 415 | "name": "CONDITIONING", 416 | "type": "CONDITIONING", 417 | "links": [ 418 | 39 419 | ], 420 | "slot_index": 0 421 | } 422 | ], 423 | "properties": { 424 | "Node name for S&R": "CLIPTextEncode" 425 | }, 426 | "widgets_values": [ 427 | "a sitting dog" 428 | ] 429 | }, 430 | { 431 | "id": 6, 432 | "type": "CLIPTextEncode", 433 | "pos": [ 434 | 413, 435 | 172 436 | ], 437 | "size": { 438 | "0": 422.84503173828125, 439 | "1": 164.31304931640625 440 | }, 441 | "flags": {}, 442 | "order": 2, 443 | "mode": 0, 444 | "inputs": [ 445 | { 446 | "name": "clip", 447 | "type": "CLIP", 448 | "link": 3 449 | } 450 | ], 451 | "outputs": [ 452 | { 453 | "name": "CONDITIONING", 454 | "type": "CONDITIONING", 455 | "links": [ 456 | 4, 457 | 38 458 | ], 459 | "slot_index": 0 460 | } 461 | ], 462 | "properties": { 463 | "Node name for S&R": "CLIPTextEncode" 464 | }, 465 | "widgets_values": [ 466 | "A dog sitting in a cozy room" 467 | ] 468 | }, 469 | { 470 | "id": 23, 471 | "type": "PreviewImage", 472 | "pos": [ 473 | 1931, 474 | -98 475 | ], 476 | "size": [ 477 | 522.1710021972658, 478 | 259.90739746093755 479 | ], 480 | "flags": {}, 481 | "order": 10, 482 | "mode": 0, 483 | "inputs": [ 484 | { 485 | "name": "images", 486 | "type": "IMAGE", 487 | "link": 35 488 | } 489 | ], 490 | "properties": { 491 | "Node name for S&R": "PreviewImage" 492 | } 493 | }, 494 | { 495 | "id": 24, 496 | "type": "PreviewImage", 497 | "pos": [ 498 | 1933, 499 | 222 500 | ], 501 | "size": [ 502 | 517.9710037231448, 503 | 258.9074523925782 504 | ], 505 | "flags": {}, 506 | "order": 11, 507 | "mode": 0, 508 | "inputs": [ 509 | { 510 | "name": "images", 511 | "type": "IMAGE", 512 | "link": 36 513 | } 514 | ], 515 | "properties": { 516 | "Node name for S&R": "PreviewImage" 517 | } 518 | }, 519 | { 520 | "id": 25, 521 | "type": "PreviewImage", 522 | "pos": [ 523 | 1933, 524 | 536 525 | ], 526 | "size": [ 527 | 516.8710037231444, 528 | 270.5074523925782 529 | ], 530 | "flags": {}, 531 | "order": 12, 532 | "mode": 0, 533 | "inputs": [ 534 | { 535 | "name": "images", 536 | "type": "IMAGE", 537 | "link": 37 538 | } 539 | ], 540 | "properties": { 541 | "Node name for S&R": "PreviewImage" 542 | } 543 | } 544 | ], 545 | "links": [ 546 | [ 547 | 2, 548 | 5, 549 | 0, 550 | 3, 551 | 3, 552 | "LATENT" 553 | ], 554 | [ 555 | 3, 556 | 4, 557 | 1, 558 | 6, 559 | 0, 560 | "CLIP" 561 | ], 562 | [ 563 | 4, 564 | 6, 565 | 0, 566 | 3, 567 | 1, 568 | "CONDITIONING" 569 | ], 570 | [ 571 | 5, 572 | 4, 573 | 1, 574 | 7, 575 | 0, 576 | "CLIP" 577 | ], 578 | [ 579 | 6, 580 | 7, 581 | 0, 582 | 3, 583 | 2, 584 | "CONDITIONING" 585 | ], 586 | [ 587 | 21, 588 | 3, 589 | 0, 590 | 14, 591 | 0, 592 | "LATENT" 593 | ], 594 | [ 595 | 22, 596 | 4, 597 | 2, 598 | 14, 599 | 1, 600 | "VAE" 601 | ], 602 | [ 603 | 31, 604 | 4, 605 | 0, 606 | 21, 607 | 0, 608 | "MODEL" 609 | ], 610 | [ 611 | 32, 612 | 21, 613 | 0, 614 | 3, 615 | 0, 616 | "MODEL" 617 | ], 618 | [ 619 | 33, 620 | 3, 621 | 0, 622 | 22, 623 | 0, 624 | "LATENT" 625 | ], 626 | [ 627 | 34, 628 | 14, 629 | 0, 630 | 22, 631 | 1, 632 | "IMAGE" 633 | ], 634 | [ 635 | 35, 636 | 22, 637 | 0, 638 | 23, 639 | 0, 640 | "IMAGE" 641 | ], 642 | [ 643 | 36, 644 | 22, 645 | 1, 646 | 24, 647 | 0, 648 | "IMAGE" 649 | ], 650 | [ 651 | 37, 652 | 22, 653 | 2, 654 | 25, 655 | 0, 656 | "IMAGE" 657 | ], 658 | [ 659 | 38, 660 | 6, 661 | 0, 662 | 21, 663 | 3, 664 | "CONDITIONING" 665 | ], 666 | [ 667 | 39, 668 | 26, 669 | 0, 670 | 21, 671 | 1, 672 | "CONDITIONING" 673 | ], 674 | [ 675 | 40, 676 | 27, 677 | 0, 678 | 21, 679 | 2, 680 | "CONDITIONING" 681 | ], 682 | [ 683 | 41, 684 | 4, 685 | 1, 686 | 26, 687 | 0, 688 | "CLIP" 689 | ], 690 | [ 691 | 42, 692 | 4, 693 | 1, 694 | 27, 695 | 0, 696 | "CLIP" 697 | ] 698 | ], 699 | "groups": [], 700 | "config": {}, 701 | "extra": {}, 702 | "version": 0.4 703 | } -------------------------------------------------------------------------------- /lib_layerdiffusion/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huchenlei/ComfyUI-layerdiffuse/b4f6a9e024064a4489f774a8b91049ce0b606ea3/lib_layerdiffusion/__init__.py -------------------------------------------------------------------------------- /lib_layerdiffusion/attention_sharing.py: -------------------------------------------------------------------------------- 1 | # Currently only sd15 2 | 3 | import functools 4 | import torch 5 | import einops 6 | 7 | from comfy import model_management 8 | from comfy.ldm.modules.attention import optimized_attention 9 | from comfy.model_patcher import ModelPatcher 10 | 11 | 12 | module_mapping_sd15 = { 13 | 0: "input_blocks.1.1.transformer_blocks.0.attn1", 14 | 1: "input_blocks.1.1.transformer_blocks.0.attn2", 15 | 2: "input_blocks.2.1.transformer_blocks.0.attn1", 16 | 3: "input_blocks.2.1.transformer_blocks.0.attn2", 17 | 4: "input_blocks.4.1.transformer_blocks.0.attn1", 18 | 5: "input_blocks.4.1.transformer_blocks.0.attn2", 19 | 6: "input_blocks.5.1.transformer_blocks.0.attn1", 20 | 7: "input_blocks.5.1.transformer_blocks.0.attn2", 21 | 8: "input_blocks.7.1.transformer_blocks.0.attn1", 22 | 9: "input_blocks.7.1.transformer_blocks.0.attn2", 23 | 10: "input_blocks.8.1.transformer_blocks.0.attn1", 24 | 11: "input_blocks.8.1.transformer_blocks.0.attn2", 25 | 12: "output_blocks.3.1.transformer_blocks.0.attn1", 26 | 13: "output_blocks.3.1.transformer_blocks.0.attn2", 27 | 14: "output_blocks.4.1.transformer_blocks.0.attn1", 28 | 15: "output_blocks.4.1.transformer_blocks.0.attn2", 29 | 16: "output_blocks.5.1.transformer_blocks.0.attn1", 30 | 17: "output_blocks.5.1.transformer_blocks.0.attn2", 31 | 18: "output_blocks.6.1.transformer_blocks.0.attn1", 32 | 19: "output_blocks.6.1.transformer_blocks.0.attn2", 33 | 20: "output_blocks.7.1.transformer_blocks.0.attn1", 34 | 21: "output_blocks.7.1.transformer_blocks.0.attn2", 35 | 22: "output_blocks.8.1.transformer_blocks.0.attn1", 36 | 23: "output_blocks.8.1.transformer_blocks.0.attn2", 37 | 24: "output_blocks.9.1.transformer_blocks.0.attn1", 38 | 25: "output_blocks.9.1.transformer_blocks.0.attn2", 39 | 26: "output_blocks.10.1.transformer_blocks.0.attn1", 40 | 27: "output_blocks.10.1.transformer_blocks.0.attn2", 41 | 28: "output_blocks.11.1.transformer_blocks.0.attn1", 42 | 29: "output_blocks.11.1.transformer_blocks.0.attn2", 43 | 30: "middle_block.1.transformer_blocks.0.attn1", 44 | 31: "middle_block.1.transformer_blocks.0.attn2", 45 | } 46 | 47 | 48 | def compute_cond_mark(cond_or_uncond, sigmas): 49 | cond_or_uncond_size = int(sigmas.shape[0]) 50 | 51 | cond_mark = [] 52 | for cx in cond_or_uncond: 53 | cond_mark += [cx] * cond_or_uncond_size 54 | 55 | cond_mark = torch.Tensor(cond_mark).to(sigmas) 56 | return cond_mark 57 | 58 | 59 | class LoRALinearLayer(torch.nn.Module): 60 | def __init__(self, in_features: int, out_features: int, rank: int = 256, org=None): 61 | super().__init__() 62 | self.down = torch.nn.Linear(in_features, rank, bias=False) 63 | self.up = torch.nn.Linear(rank, out_features, bias=False) 64 | self.org = [org] 65 | 66 | def forward(self, h): 67 | org_weight = self.org[0].weight.to(h) 68 | org_bias = self.org[0].bias.to(h) if self.org[0].bias is not None else None 69 | down_weight = self.down.weight 70 | up_weight = self.up.weight 71 | final_weight = org_weight + torch.mm(up_weight, down_weight) 72 | return torch.nn.functional.linear(h, final_weight, org_bias) 73 | 74 | 75 | class AttentionSharingUnit(torch.nn.Module): 76 | # `transformer_options` passed to the most recent BasicTransformerBlock.forward 77 | # call. 78 | transformer_options: dict = {} 79 | 80 | def __init__(self, module, frames=2, use_control=True, rank=256): 81 | super().__init__() 82 | 83 | self.heads = module.heads 84 | self.frames = frames 85 | self.original_module = [module] 86 | q_in_channels, q_out_channels = ( 87 | module.to_q.in_features, 88 | module.to_q.out_features, 89 | ) 90 | k_in_channels, k_out_channels = ( 91 | module.to_k.in_features, 92 | module.to_k.out_features, 93 | ) 94 | v_in_channels, v_out_channels = ( 95 | module.to_v.in_features, 96 | module.to_v.out_features, 97 | ) 98 | o_in_channels, o_out_channels = ( 99 | module.to_out[0].in_features, 100 | module.to_out[0].out_features, 101 | ) 102 | 103 | hidden_size = k_out_channels 104 | 105 | self.to_q_lora = [ 106 | LoRALinearLayer(q_in_channels, q_out_channels, rank, module.to_q) 107 | for _ in range(self.frames) 108 | ] 109 | self.to_k_lora = [ 110 | LoRALinearLayer(k_in_channels, k_out_channels, rank, module.to_k) 111 | for _ in range(self.frames) 112 | ] 113 | self.to_v_lora = [ 114 | LoRALinearLayer(v_in_channels, v_out_channels, rank, module.to_v) 115 | for _ in range(self.frames) 116 | ] 117 | self.to_out_lora = [ 118 | LoRALinearLayer(o_in_channels, o_out_channels, rank, module.to_out[0]) 119 | for _ in range(self.frames) 120 | ] 121 | 122 | self.to_q_lora = torch.nn.ModuleList(self.to_q_lora) 123 | self.to_k_lora = torch.nn.ModuleList(self.to_k_lora) 124 | self.to_v_lora = torch.nn.ModuleList(self.to_v_lora) 125 | self.to_out_lora = torch.nn.ModuleList(self.to_out_lora) 126 | 127 | self.temporal_i = torch.nn.Linear( 128 | in_features=hidden_size, out_features=hidden_size 129 | ) 130 | self.temporal_n = torch.nn.LayerNorm( 131 | hidden_size, elementwise_affine=True, eps=1e-6 132 | ) 133 | self.temporal_q = torch.nn.Linear( 134 | in_features=hidden_size, out_features=hidden_size 135 | ) 136 | self.temporal_k = torch.nn.Linear( 137 | in_features=hidden_size, out_features=hidden_size 138 | ) 139 | self.temporal_v = torch.nn.Linear( 140 | in_features=hidden_size, out_features=hidden_size 141 | ) 142 | self.temporal_o = torch.nn.Linear( 143 | in_features=hidden_size, out_features=hidden_size 144 | ) 145 | 146 | self.control_convs = None 147 | 148 | if use_control: 149 | self.control_convs = [ 150 | torch.nn.Sequential( 151 | torch.nn.Conv2d(256, 256, kernel_size=3, padding=1, stride=1), 152 | torch.nn.SiLU(), 153 | torch.nn.Conv2d(256, hidden_size, kernel_size=1), 154 | ) 155 | for _ in range(self.frames) 156 | ] 157 | self.control_convs = torch.nn.ModuleList(self.control_convs) 158 | 159 | self.control_signals = None 160 | 161 | def forward(self, h, context=None, value=None): 162 | transformer_options = self.transformer_options 163 | 164 | modified_hidden_states = einops.rearrange( 165 | h, "(b f) d c -> f b d c", f=self.frames 166 | ) 167 | 168 | if self.control_convs is not None: 169 | context_dim = int(modified_hidden_states.shape[2]) 170 | control_outs = [] 171 | for f in range(self.frames): 172 | control_signal = self.control_signals[context_dim].to( 173 | modified_hidden_states 174 | ) 175 | control = self.control_convs[f](control_signal) 176 | control = einops.rearrange(control, "b c h w -> b (h w) c") 177 | control_outs.append(control) 178 | control_outs = torch.stack(control_outs, dim=0) 179 | modified_hidden_states = modified_hidden_states + control_outs.to( 180 | modified_hidden_states 181 | ) 182 | 183 | if context is None: 184 | framed_context = modified_hidden_states 185 | else: 186 | framed_context = einops.rearrange( 187 | context, "(b f) d c -> f b d c", f=self.frames 188 | ) 189 | 190 | framed_cond_mark = einops.rearrange( 191 | compute_cond_mark( 192 | transformer_options["cond_or_uncond"], 193 | transformer_options["sigmas"], 194 | ), 195 | "(b f) -> f b", 196 | f=self.frames, 197 | ).to(modified_hidden_states) 198 | 199 | attn_outs = [] 200 | for f in range(self.frames): 201 | fcf = framed_context[f] 202 | 203 | if context is not None: 204 | cond_overwrite = transformer_options.get("cond_overwrite", []) 205 | if len(cond_overwrite) > f: 206 | cond_overwrite = cond_overwrite[f] 207 | else: 208 | cond_overwrite = None 209 | if cond_overwrite is not None: 210 | cond_mark = framed_cond_mark[f][:, None, None] 211 | fcf = cond_overwrite.to(fcf) * (1.0 - cond_mark) + fcf * cond_mark 212 | 213 | q = self.to_q_lora[f](modified_hidden_states[f]) 214 | k = self.to_k_lora[f](fcf) 215 | v = self.to_v_lora[f](fcf) 216 | o = optimized_attention(q, k, v, self.heads) 217 | o = self.to_out_lora[f](o) 218 | o = self.original_module[0].to_out[1](o) 219 | attn_outs.append(o) 220 | 221 | attn_outs = torch.stack(attn_outs, dim=0) 222 | modified_hidden_states = modified_hidden_states + attn_outs.to( 223 | modified_hidden_states 224 | ) 225 | modified_hidden_states = einops.rearrange( 226 | modified_hidden_states, "f b d c -> (b f) d c", f=self.frames 227 | ) 228 | 229 | x = modified_hidden_states 230 | x = self.temporal_n(x) 231 | x = self.temporal_i(x) 232 | d = x.shape[1] 233 | 234 | x = einops.rearrange(x, "(b f) d c -> (b d) f c", f=self.frames) 235 | 236 | q = self.temporal_q(x) 237 | k = self.temporal_k(x) 238 | v = self.temporal_v(x) 239 | 240 | x = optimized_attention(q, k, v, self.heads) 241 | x = self.temporal_o(x) 242 | x = einops.rearrange(x, "(b d) f c -> (b f) d c", d=d) 243 | 244 | modified_hidden_states = modified_hidden_states + x 245 | 246 | return modified_hidden_states - h 247 | 248 | @classmethod 249 | def hijack_transformer_block(cls): 250 | def register_get_transformer_options(func): 251 | @functools.wraps(func) 252 | def forward(self, x, context=None, transformer_options={}): 253 | cls.transformer_options = transformer_options 254 | return func(self, x, context, transformer_options) 255 | 256 | return forward 257 | 258 | from comfy.ldm.modules.attention import BasicTransformerBlock 259 | 260 | BasicTransformerBlock.forward = register_get_transformer_options( 261 | BasicTransformerBlock.forward 262 | ) 263 | 264 | 265 | AttentionSharingUnit.hijack_transformer_block() 266 | 267 | 268 | class AdditionalAttentionCondsEncoder(torch.nn.Module): 269 | def __init__(self): 270 | super().__init__() 271 | 272 | self.blocks_0 = torch.nn.Sequential( 273 | torch.nn.Conv2d(3, 32, kernel_size=3, padding=1, stride=1), 274 | torch.nn.SiLU(), 275 | torch.nn.Conv2d(32, 32, kernel_size=3, padding=1, stride=1), 276 | torch.nn.SiLU(), 277 | torch.nn.Conv2d(32, 64, kernel_size=3, padding=1, stride=2), 278 | torch.nn.SiLU(), 279 | torch.nn.Conv2d(64, 64, kernel_size=3, padding=1, stride=1), 280 | torch.nn.SiLU(), 281 | torch.nn.Conv2d(64, 128, kernel_size=3, padding=1, stride=2), 282 | torch.nn.SiLU(), 283 | torch.nn.Conv2d(128, 128, kernel_size=3, padding=1, stride=1), 284 | torch.nn.SiLU(), 285 | torch.nn.Conv2d(128, 256, kernel_size=3, padding=1, stride=2), 286 | torch.nn.SiLU(), 287 | torch.nn.Conv2d(256, 256, kernel_size=3, padding=1, stride=1), 288 | torch.nn.SiLU(), 289 | ) # 64*64*256 290 | 291 | self.blocks_1 = torch.nn.Sequential( 292 | torch.nn.Conv2d(256, 256, kernel_size=3, padding=1, stride=2), 293 | torch.nn.SiLU(), 294 | torch.nn.Conv2d(256, 256, kernel_size=3, padding=1, stride=1), 295 | torch.nn.SiLU(), 296 | ) # 32*32*256 297 | 298 | self.blocks_2 = torch.nn.Sequential( 299 | torch.nn.Conv2d(256, 256, kernel_size=3, padding=1, stride=2), 300 | torch.nn.SiLU(), 301 | torch.nn.Conv2d(256, 256, kernel_size=3, padding=1, stride=1), 302 | torch.nn.SiLU(), 303 | ) # 16*16*256 304 | 305 | self.blocks_3 = torch.nn.Sequential( 306 | torch.nn.Conv2d(256, 256, kernel_size=3, padding=1, stride=2), 307 | torch.nn.SiLU(), 308 | torch.nn.Conv2d(256, 256, kernel_size=3, padding=1, stride=1), 309 | torch.nn.SiLU(), 310 | ) # 8*8*256 311 | 312 | self.blks = [self.blocks_0, self.blocks_1, self.blocks_2, self.blocks_3] 313 | 314 | def __call__(self, h): 315 | results = {} 316 | for b in self.blks: 317 | h = b(h) 318 | results[int(h.shape[2]) * int(h.shape[3])] = h 319 | return results 320 | 321 | 322 | class HookerLayers(torch.nn.Module): 323 | def __init__(self, layer_list): 324 | super().__init__() 325 | self.layers = torch.nn.ModuleList(layer_list) 326 | 327 | 328 | class AttentionSharingPatcher(torch.nn.Module): 329 | def __init__(self, unet: ModelPatcher, frames=2, use_control=True, rank=256): 330 | super().__init__() 331 | 332 | units = [] 333 | for i in range(32): 334 | key = "diffusion_model." + module_mapping_sd15[i] 335 | attn_module = unet.get_model_object(key) 336 | u = AttentionSharingUnit( 337 | attn_module, frames=frames, use_control=use_control, rank=rank 338 | ) 339 | units.append(u) 340 | unet.add_object_patch(key, u) 341 | 342 | self.hookers = HookerLayers(units) 343 | 344 | if use_control: 345 | self.kwargs_encoder = AdditionalAttentionCondsEncoder() 346 | else: 347 | self.kwargs_encoder = None 348 | 349 | self.dtype = torch.float32 350 | if model_management.should_use_fp16(model_management.get_torch_device()): 351 | self.dtype = torch.float16 352 | self.hookers.half() 353 | return 354 | 355 | def set_control(self, img): 356 | img = img.cpu().float() * 2.0 - 1.0 357 | signals = self.kwargs_encoder(img) 358 | for m in self.hookers.layers: 359 | m.control_signals = signals 360 | return 361 | -------------------------------------------------------------------------------- /lib_layerdiffusion/enums.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | 3 | 4 | class ResizeMode(Enum): 5 | RESIZE = "Just Resize" 6 | CROP_AND_RESIZE = "Crop and Resize" 7 | RESIZE_AND_FILL = "Resize and Fill" 8 | 9 | def int_value(self): 10 | if self == ResizeMode.RESIZE: 11 | return 0 12 | elif self == ResizeMode.CROP_AND_RESIZE: 13 | return 1 14 | elif self == ResizeMode.RESIZE_AND_FILL: 15 | return 2 16 | return 0 17 | 18 | 19 | class StableDiffusionVersion(Enum): 20 | """The version family of stable diffusion model.""" 21 | 22 | SD1x = "SD15" 23 | SDXL = "SDXL" 24 | -------------------------------------------------------------------------------- /lib_layerdiffusion/models.py: -------------------------------------------------------------------------------- 1 | import torch.nn as nn 2 | import torch 3 | import cv2 4 | import numpy as np 5 | 6 | from tqdm import tqdm 7 | from typing import Optional, Tuple 8 | from diffusers.configuration_utils import ConfigMixin, register_to_config 9 | from diffusers.models.modeling_utils import ModelMixin 10 | import importlib.metadata 11 | from packaging.version import parse 12 | 13 | diffusers_version = importlib.metadata.version('diffusers') 14 | 15 | def check_diffusers_version(min_version="0.25.0"): 16 | assert parse(diffusers_version) >= parse( 17 | min_version 18 | ), f"diffusers>={min_version} requirement not satisfied. Please install correct diffusers version." 19 | 20 | check_diffusers_version() 21 | 22 | if parse(diffusers_version) >= parse("0.29.0"): 23 | from diffusers.models.unets.unet_2d_blocks import UNetMidBlock2D, get_down_block, get_up_block 24 | else: 25 | from diffusers.models.unet_2d_blocks import UNetMidBlock2D, get_down_block, get_up_block 26 | 27 | 28 | def zero_module(module): 29 | """ 30 | Zero out the parameters of a module and return it. 31 | """ 32 | for p in module.parameters(): 33 | p.detach().zero_() 34 | return module 35 | 36 | 37 | class LatentTransparencyOffsetEncoder(torch.nn.Module): 38 | def __init__(self, *args, **kwargs): 39 | super().__init__(*args, **kwargs) 40 | self.blocks = torch.nn.Sequential( 41 | torch.nn.Conv2d(4, 32, kernel_size=3, padding=1, stride=1), 42 | nn.SiLU(), 43 | torch.nn.Conv2d(32, 32, kernel_size=3, padding=1, stride=1), 44 | nn.SiLU(), 45 | torch.nn.Conv2d(32, 64, kernel_size=3, padding=1, stride=2), 46 | nn.SiLU(), 47 | torch.nn.Conv2d(64, 64, kernel_size=3, padding=1, stride=1), 48 | nn.SiLU(), 49 | torch.nn.Conv2d(64, 128, kernel_size=3, padding=1, stride=2), 50 | nn.SiLU(), 51 | torch.nn.Conv2d(128, 128, kernel_size=3, padding=1, stride=1), 52 | nn.SiLU(), 53 | torch.nn.Conv2d(128, 256, kernel_size=3, padding=1, stride=2), 54 | nn.SiLU(), 55 | torch.nn.Conv2d(256, 256, kernel_size=3, padding=1, stride=1), 56 | nn.SiLU(), 57 | zero_module(torch.nn.Conv2d(256, 4, kernel_size=3, padding=1, stride=1)), 58 | ) 59 | 60 | def __call__(self, x): 61 | return self.blocks(x) 62 | 63 | 64 | # 1024 * 1024 * 3 -> 16 * 16 * 512 -> 1024 * 1024 * 3 65 | class UNet1024(ModelMixin, ConfigMixin): 66 | @register_to_config 67 | def __init__( 68 | self, 69 | in_channels: int = 3, 70 | out_channels: int = 3, 71 | down_block_types: Tuple[str] = ( 72 | "DownBlock2D", 73 | "DownBlock2D", 74 | "DownBlock2D", 75 | "DownBlock2D", 76 | "AttnDownBlock2D", 77 | "AttnDownBlock2D", 78 | "AttnDownBlock2D", 79 | ), 80 | up_block_types: Tuple[str] = ( 81 | "AttnUpBlock2D", 82 | "AttnUpBlock2D", 83 | "AttnUpBlock2D", 84 | "UpBlock2D", 85 | "UpBlock2D", 86 | "UpBlock2D", 87 | "UpBlock2D", 88 | ), 89 | block_out_channels: Tuple[int] = (32, 32, 64, 128, 256, 512, 512), 90 | layers_per_block: int = 2, 91 | mid_block_scale_factor: float = 1, 92 | downsample_padding: int = 1, 93 | downsample_type: str = "conv", 94 | upsample_type: str = "conv", 95 | dropout: float = 0.0, 96 | act_fn: str = "silu", 97 | attention_head_dim: Optional[int] = 8, 98 | norm_num_groups: int = 4, 99 | norm_eps: float = 1e-5, 100 | ): 101 | super().__init__() 102 | 103 | # input 104 | self.conv_in = nn.Conv2d( 105 | in_channels, block_out_channels[0], kernel_size=3, padding=(1, 1) 106 | ) 107 | self.latent_conv_in = zero_module( 108 | nn.Conv2d(4, block_out_channels[2], kernel_size=1) 109 | ) 110 | 111 | self.down_blocks = nn.ModuleList([]) 112 | self.mid_block = None 113 | self.up_blocks = nn.ModuleList([]) 114 | 115 | # down 116 | output_channel = block_out_channels[0] 117 | for i, down_block_type in enumerate(down_block_types): 118 | input_channel = output_channel 119 | output_channel = block_out_channels[i] 120 | is_final_block = i == len(block_out_channels) - 1 121 | 122 | down_block = get_down_block( 123 | down_block_type, 124 | num_layers=layers_per_block, 125 | in_channels=input_channel, 126 | out_channels=output_channel, 127 | temb_channels=None, 128 | add_downsample=not is_final_block, 129 | resnet_eps=norm_eps, 130 | resnet_act_fn=act_fn, 131 | resnet_groups=norm_num_groups, 132 | attention_head_dim=( 133 | attention_head_dim 134 | if attention_head_dim is not None 135 | else output_channel 136 | ), 137 | downsample_padding=downsample_padding, 138 | resnet_time_scale_shift="default", 139 | downsample_type=downsample_type, 140 | dropout=dropout, 141 | ) 142 | self.down_blocks.append(down_block) 143 | 144 | # mid 145 | self.mid_block = UNetMidBlock2D( 146 | in_channels=block_out_channels[-1], 147 | temb_channels=None, 148 | dropout=dropout, 149 | resnet_eps=norm_eps, 150 | resnet_act_fn=act_fn, 151 | output_scale_factor=mid_block_scale_factor, 152 | resnet_time_scale_shift="default", 153 | attention_head_dim=( 154 | attention_head_dim 155 | if attention_head_dim is not None 156 | else block_out_channels[-1] 157 | ), 158 | resnet_groups=norm_num_groups, 159 | attn_groups=None, 160 | add_attention=True, 161 | ) 162 | 163 | # up 164 | reversed_block_out_channels = list(reversed(block_out_channels)) 165 | output_channel = reversed_block_out_channels[0] 166 | for i, up_block_type in enumerate(up_block_types): 167 | prev_output_channel = output_channel 168 | output_channel = reversed_block_out_channels[i] 169 | input_channel = reversed_block_out_channels[ 170 | min(i + 1, len(block_out_channels) - 1) 171 | ] 172 | 173 | is_final_block = i == len(block_out_channels) - 1 174 | 175 | up_block = get_up_block( 176 | up_block_type, 177 | num_layers=layers_per_block + 1, 178 | in_channels=input_channel, 179 | out_channels=output_channel, 180 | prev_output_channel=prev_output_channel, 181 | temb_channels=None, 182 | add_upsample=not is_final_block, 183 | resnet_eps=norm_eps, 184 | resnet_act_fn=act_fn, 185 | resnet_groups=norm_num_groups, 186 | attention_head_dim=( 187 | attention_head_dim 188 | if attention_head_dim is not None 189 | else output_channel 190 | ), 191 | resnet_time_scale_shift="default", 192 | upsample_type=upsample_type, 193 | dropout=dropout, 194 | ) 195 | self.up_blocks.append(up_block) 196 | prev_output_channel = output_channel 197 | 198 | # out 199 | self.conv_norm_out = nn.GroupNorm( 200 | num_channels=block_out_channels[0], num_groups=norm_num_groups, eps=norm_eps 201 | ) 202 | self.conv_act = nn.SiLU() 203 | self.conv_out = nn.Conv2d( 204 | block_out_channels[0], out_channels, kernel_size=3, padding=1 205 | ) 206 | 207 | def forward(self, x, latent): 208 | sample_latent = self.latent_conv_in(latent) 209 | sample = self.conv_in(x) 210 | emb = None 211 | 212 | down_block_res_samples = (sample,) 213 | for i, downsample_block in enumerate(self.down_blocks): 214 | if i == 3: 215 | sample = sample + sample_latent 216 | 217 | sample, res_samples = downsample_block(hidden_states=sample, temb=emb) 218 | down_block_res_samples += res_samples 219 | 220 | sample = self.mid_block(sample, emb) 221 | 222 | for upsample_block in self.up_blocks: 223 | res_samples = down_block_res_samples[-len(upsample_block.resnets) :] 224 | down_block_res_samples = down_block_res_samples[ 225 | : -len(upsample_block.resnets) 226 | ] 227 | sample = upsample_block(sample, res_samples, emb) 228 | 229 | sample = self.conv_norm_out(sample) 230 | sample = self.conv_act(sample) 231 | sample = self.conv_out(sample) 232 | return sample 233 | 234 | 235 | def checkerboard(shape): 236 | return np.indices(shape).sum(axis=0) % 2 237 | 238 | 239 | def fill_checkerboard_bg(y: torch.Tensor) -> torch.Tensor: 240 | alpha = y[..., :1] 241 | fg = y[..., 1:] 242 | B, H, W, C = fg.shape 243 | cb = checkerboard(shape=(H // 64, W // 64)) 244 | cb = cv2.resize(cb, (W, H), interpolation=cv2.INTER_NEAREST) 245 | cb = (0.5 + (cb - 0.5) * 0.1)[None, ..., None] 246 | cb = torch.from_numpy(cb).to(fg) 247 | vis = fg * alpha + cb * (1 - alpha) 248 | return vis 249 | 250 | 251 | class TransparentVAEDecoder: 252 | def __init__(self, sd, device, dtype): 253 | self.load_device = device 254 | self.dtype = dtype 255 | 256 | model = UNet1024(in_channels=3, out_channels=4) 257 | model.load_state_dict(sd, strict=True) 258 | model.to(self.load_device, dtype=self.dtype) 259 | model.eval() 260 | self.model = model 261 | 262 | @torch.no_grad() 263 | def estimate_single_pass(self, pixel, latent): 264 | y = self.model(pixel, latent) 265 | return y 266 | 267 | @torch.no_grad() 268 | def estimate_augmented(self, pixel, latent): 269 | args = [ 270 | [False, 0], 271 | [False, 1], 272 | [False, 2], 273 | [False, 3], 274 | [True, 0], 275 | [True, 1], 276 | [True, 2], 277 | [True, 3], 278 | ] 279 | 280 | result = [] 281 | 282 | for flip, rok in tqdm(args): 283 | feed_pixel = pixel.clone() 284 | feed_latent = latent.clone() 285 | 286 | if flip: 287 | feed_pixel = torch.flip(feed_pixel, dims=(3,)) 288 | feed_latent = torch.flip(feed_latent, dims=(3,)) 289 | 290 | feed_pixel = torch.rot90(feed_pixel, k=rok, dims=(2, 3)) 291 | feed_latent = torch.rot90(feed_latent, k=rok, dims=(2, 3)) 292 | 293 | eps = self.estimate_single_pass(feed_pixel, feed_latent).clip(0, 1) 294 | eps = torch.rot90(eps, k=-rok, dims=(2, 3)) 295 | 296 | if flip: 297 | eps = torch.flip(eps, dims=(3,)) 298 | 299 | result += [eps] 300 | 301 | result = torch.stack(result, dim=0) 302 | if self.load_device == torch.device("mps"): 303 | ''' 304 | In case that apple silicon devices would crash when calling torch.median() on tensors 305 | in gpu vram with dimensions higher than 4, we move it to cpu, call torch.median() 306 | and then move the result back to gpu. 307 | ''' 308 | median = torch.median(result.cpu(), dim=0).values 309 | median = median.to(device=self.load_device, dtype=self.dtype) 310 | else: 311 | median = torch.median(result, dim=0).values 312 | return median 313 | 314 | @torch.no_grad() 315 | def decode_pixel( 316 | self, pixel: torch.TensorType, latent: torch.TensorType 317 | ) -> torch.TensorType: 318 | # pixel.shape = [B, C=3, H, W] 319 | assert pixel.shape[1] == 3 320 | pixel_device = pixel.device 321 | pixel_dtype = pixel.dtype 322 | 323 | pixel = pixel.to(device=self.load_device, dtype=self.dtype) 324 | latent = latent.to(device=self.load_device, dtype=self.dtype) 325 | # y.shape = [B, C=4, H, W] 326 | y = self.estimate_augmented(pixel, latent) 327 | y = y.clip(0, 1) 328 | assert y.shape[1] == 4 329 | # Restore image to original device of input image. 330 | return y.to(pixel_device, dtype=pixel_dtype) 331 | -------------------------------------------------------------------------------- /lib_layerdiffusion/utils.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from .enums import ResizeMode 3 | import cv2 4 | import torch 5 | import os 6 | from urllib.parse import urlparse 7 | from typing import Optional 8 | 9 | 10 | def rgba2rgbfp32(x): 11 | rgb = x[..., :3].astype(np.float32) / 255.0 12 | a = x[..., 3:4].astype(np.float32) / 255.0 13 | return 0.5 + (rgb - 0.5) * a 14 | 15 | 16 | def to255unit8(x): 17 | return (x * 255.0).clip(0, 255).astype(np.uint8) 18 | 19 | 20 | def safe_numpy(x): 21 | # A very safe method to make sure that Apple/Mac works 22 | y = x 23 | 24 | # below is very boring but do not change these. If you change these Apple or Mac may fail. 25 | y = y.copy() 26 | y = np.ascontiguousarray(y) 27 | y = y.copy() 28 | return y 29 | 30 | 31 | def high_quality_resize(x, size): 32 | if x.shape[0] != size[1] or x.shape[1] != size[0]: 33 | if (size[0] * size[1]) < (x.shape[0] * x.shape[1]): 34 | interpolation = cv2.INTER_AREA 35 | else: 36 | interpolation = cv2.INTER_LANCZOS4 37 | 38 | y = cv2.resize(x, size, interpolation=interpolation) 39 | else: 40 | y = x 41 | return y 42 | 43 | 44 | def crop_and_resize_image(detected_map, resize_mode, h, w): 45 | if resize_mode == ResizeMode.RESIZE: 46 | detected_map = high_quality_resize(detected_map, (w, h)) 47 | detected_map = safe_numpy(detected_map) 48 | return detected_map 49 | 50 | old_h, old_w, _ = detected_map.shape 51 | old_w = float(old_w) 52 | old_h = float(old_h) 53 | k0 = float(h) / old_h 54 | k1 = float(w) / old_w 55 | 56 | def safeint(x): 57 | return int(np.round(x)) 58 | 59 | if resize_mode == ResizeMode.RESIZE_AND_FILL: 60 | k = min(k0, k1) 61 | borders = np.concatenate([detected_map[0, :, :], detected_map[-1, :, :], detected_map[:, 0, :], detected_map[:, -1, :]], axis=0) 62 | high_quality_border_color = np.median(borders, axis=0).astype(detected_map.dtype) 63 | high_quality_background = np.tile(high_quality_border_color[None, None], [h, w, 1]) 64 | detected_map = high_quality_resize(detected_map, (safeint(old_w * k), safeint(old_h * k))) 65 | new_h, new_w, _ = detected_map.shape 66 | pad_h = max(0, (h - new_h) // 2) 67 | pad_w = max(0, (w - new_w) // 2) 68 | high_quality_background[pad_h:pad_h + new_h, pad_w:pad_w + new_w] = detected_map 69 | detected_map = high_quality_background 70 | detected_map = safe_numpy(detected_map) 71 | return detected_map 72 | else: 73 | k = max(k0, k1) 74 | detected_map = high_quality_resize(detected_map, (safeint(old_w * k), safeint(old_h * k))) 75 | new_h, new_w, _ = detected_map.shape 76 | pad_h = max(0, (new_h - h) // 2) 77 | pad_w = max(0, (new_w - w) // 2) 78 | detected_map = detected_map[pad_h:pad_h+h, pad_w:pad_w+w] 79 | detected_map = safe_numpy(detected_map) 80 | return detected_map 81 | 82 | 83 | def pytorch_to_numpy(x): 84 | return [np.clip(255. * y.cpu().numpy(), 0, 255).astype(np.uint8) for y in x] 85 | 86 | 87 | def numpy_to_pytorch(x): 88 | y = x.astype(np.float32) / 255.0 89 | y = y[None] 90 | y = np.ascontiguousarray(y.copy()) 91 | y = torch.from_numpy(y).float() 92 | return y 93 | 94 | 95 | def load_file_from_url( 96 | url: str, 97 | *, 98 | model_dir: str, 99 | progress: bool = True, 100 | file_name: Optional[str] = None, 101 | ) -> str: 102 | """Download a file from `url` into `model_dir`, using the file present if possible. 103 | 104 | Returns the path to the downloaded file. 105 | """ 106 | os.makedirs(model_dir, exist_ok=True) 107 | if not file_name: 108 | parts = urlparse(url) 109 | file_name = os.path.basename(parts.path) 110 | cached_file = os.path.abspath(os.path.join(model_dir, file_name)) 111 | if not os.path.exists(cached_file): 112 | print(f'Downloading: "{url}" to {cached_file}\n') 113 | from torch.hub import download_url_to_file 114 | download_url_to_file(url, cached_file, progress=progress) 115 | return cached_file 116 | 117 | 118 | def to_lora_patch_dict(state_dict: dict) -> dict: 119 | """ Convert raw lora state_dict to patch_dict that can be applied on 120 | modelpatcher.""" 121 | patch_dict = {} 122 | for k, w in state_dict.items(): 123 | model_key, patch_type, weight_index = k.split('::') 124 | if model_key not in patch_dict: 125 | patch_dict[model_key] = {} 126 | if patch_type not in patch_dict[model_key]: 127 | patch_dict[model_key][patch_type] = [None] * 16 128 | patch_dict[model_key][patch_type][int(weight_index)] = w 129 | 130 | patch_flat = {} 131 | for model_key, v in patch_dict.items(): 132 | for patch_type, weight_list in v.items(): 133 | patch_flat[model_key] = (patch_type, weight_list) 134 | 135 | return patch_flat 136 | -------------------------------------------------------------------------------- /locales/en/main.json: -------------------------------------------------------------------------------- 1 | { 2 | "nodeCategories": { 3 | "layer_diffuse": "layer_diffuse" 4 | } 5 | } -------------------------------------------------------------------------------- /locales/en/nodeDefs.json: -------------------------------------------------------------------------------- 1 | { 2 | "LayeredDiffusionApply": { 3 | "display_name": "Layer Diffuse Apply", 4 | "inputs": { 5 | "model": { 6 | "name": "model" 7 | }, 8 | "config": { 9 | "name": "config" 10 | }, 11 | "weight": { 12 | "name": "weight" 13 | } 14 | } 15 | }, 16 | "LayeredDiffusionCondApply": { 17 | "display_name": "Layer Diffuse Cond Apply", 18 | "inputs": { 19 | "model": { 20 | "name": "model" 21 | }, 22 | "cond": { 23 | "name": "cond" 24 | }, 25 | "uncond": { 26 | "name": "uncond" 27 | }, 28 | "latent": { 29 | "name": "latent" 30 | }, 31 | "config": { 32 | "name": "config" 33 | }, 34 | "weight": { 35 | "name": "weight" 36 | } 37 | } 38 | }, 39 | "LayeredDiffusionCondJointApply": { 40 | "display_name": "Layer Diffuse Cond Joint Apply", 41 | "inputs": { 42 | "model": { 43 | "name": "model" 44 | }, 45 | "image": { 46 | "name": "image" 47 | }, 48 | "config": { 49 | "name": "config" 50 | }, 51 | "cond": { 52 | "name": "cond" 53 | }, 54 | "blended_cond": { 55 | "name": "blended_cond" 56 | } 57 | } 58 | }, 59 | "LayeredDiffusionDecode": { 60 | "display_name": "Layer Diffuse Decode", 61 | "inputs": { 62 | "samples": { 63 | "name": "samples" 64 | }, 65 | "images": { 66 | "name": "images" 67 | }, 68 | "sd_version": { 69 | "name": "sd_version" 70 | }, 71 | "sub_batch_size": { 72 | "name": "sub_batch_size" 73 | } 74 | } 75 | }, 76 | "LayeredDiffusionDecodeRGBA": { 77 | "display_name": "Layer Diffuse Decode (RGBA)", 78 | "inputs": { 79 | "samples": { 80 | "name": "samples" 81 | }, 82 | "images": { 83 | "name": "images" 84 | }, 85 | "sd_version": { 86 | "name": "sd_version" 87 | }, 88 | "sub_batch_size": { 89 | "name": "sub_batch_size" 90 | } 91 | } 92 | }, 93 | "LayeredDiffusionDecodeSplit": { 94 | "display_name": "Layer Diffuse Decode (Split)", 95 | "inputs": { 96 | "samples": { 97 | "name": "samples" 98 | }, 99 | "images": { 100 | "name": "images" 101 | }, 102 | "frames": { 103 | "name": "frames" 104 | }, 105 | "sd_version": { 106 | "name": "sd_version" 107 | }, 108 | "sub_batch_size": { 109 | "name": "sub_batch_size" 110 | } 111 | } 112 | }, 113 | "LayeredDiffusionDiffApply": { 114 | "display_name": "Layer Diffuse Diff Apply", 115 | "inputs": { 116 | "model": { 117 | "name": "model" 118 | }, 119 | "cond": { 120 | "name": "cond" 121 | }, 122 | "uncond": { 123 | "name": "uncond" 124 | }, 125 | "blended_latent": { 126 | "name": "blended_latent" 127 | }, 128 | "latent": { 129 | "name": "latent" 130 | }, 131 | "config": { 132 | "name": "config" 133 | }, 134 | "weight": { 135 | "name": "weight" 136 | } 137 | } 138 | }, 139 | "LayeredDiffusionJointApply": { 140 | "display_name": "Layer Diffuse Joint Apply", 141 | "inputs": { 142 | "model": { 143 | "name": "model" 144 | }, 145 | "config": { 146 | "name": "config" 147 | }, 148 | "fg_cond": { 149 | "name": "fg_cond" 150 | }, 151 | "bg_cond": { 152 | "name": "bg_cond" 153 | }, 154 | "blended_cond": { 155 | "name": "blended_cond" 156 | } 157 | } 158 | } 159 | } -------------------------------------------------------------------------------- /locales/fr/main.json: -------------------------------------------------------------------------------- 1 | { 2 | "nodeCategories": { 3 | "layer_diffuse": "couche_diffuse" 4 | } 5 | } -------------------------------------------------------------------------------- /locales/fr/nodeDefs.json: -------------------------------------------------------------------------------- 1 | { 2 | "LayeredDiffusionApply": { 3 | "display_name": "Appliquer Diffusion en Couches", 4 | "inputs": { 5 | "config": { 6 | "name": "config" 7 | }, 8 | "model": { 9 | "name": "modèle" 10 | }, 11 | "weight": { 12 | "name": "poids" 13 | } 14 | } 15 | }, 16 | "LayeredDiffusionCondApply": { 17 | "display_name": "Appliquer Diffusion Conditionnelle en Couches", 18 | "inputs": { 19 | "cond": { 20 | "name": "cond" 21 | }, 22 | "config": { 23 | "name": "config" 24 | }, 25 | "latent": { 26 | "name": "latent" 27 | }, 28 | "model": { 29 | "name": "modèle" 30 | }, 31 | "uncond": { 32 | "name": "non cond" 33 | }, 34 | "weight": { 35 | "name": "poids" 36 | } 37 | } 38 | }, 39 | "LayeredDiffusionCondJointApply": { 40 | "display_name": "Appliquer Diffusion Conditionnelle Conjointe en Couches", 41 | "inputs": { 42 | "blended_cond": { 43 | "name": "cond mélangé" 44 | }, 45 | "cond": { 46 | "name": "cond" 47 | }, 48 | "config": { 49 | "name": "config" 50 | }, 51 | "image": { 52 | "name": "image" 53 | }, 54 | "model": { 55 | "name": "modèle" 56 | } 57 | } 58 | }, 59 | "LayeredDiffusionDecode": { 60 | "display_name": "Décoder Diffusion en Couches", 61 | "inputs": { 62 | "images": { 63 | "name": "images" 64 | }, 65 | "samples": { 66 | "name": "échantillons" 67 | }, 68 | "sd_version": { 69 | "name": "version_sd" 70 | }, 71 | "sub_batch_size": { 72 | "name": "taille_sous_lot" 73 | } 74 | } 75 | }, 76 | "LayeredDiffusionDecodeRGBA": { 77 | "display_name": "Décoder Diffusion en Couches (RGBA)", 78 | "inputs": { 79 | "images": { 80 | "name": "images" 81 | }, 82 | "samples": { 83 | "name": "échantillons" 84 | }, 85 | "sd_version": { 86 | "name": "version_sd" 87 | }, 88 | "sub_batch_size": { 89 | "name": "taille_sous_lot" 90 | } 91 | } 92 | }, 93 | "LayeredDiffusionDecodeSplit": { 94 | "display_name": "Décoder Diffusion en Couches (Split)", 95 | "inputs": { 96 | "frames": { 97 | "name": "cadres" 98 | }, 99 | "images": { 100 | "name": "images" 101 | }, 102 | "samples": { 103 | "name": "échantillons" 104 | }, 105 | "sd_version": { 106 | "name": "version_sd" 107 | }, 108 | "sub_batch_size": { 109 | "name": "taille_sous_lot" 110 | } 111 | } 112 | }, 113 | "LayeredDiffusionDiffApply": { 114 | "display_name": "Appliquer Différence de Diffusion en Couches", 115 | "inputs": { 116 | "blended_latent": { 117 | "name": "latent mélangé" 118 | }, 119 | "cond": { 120 | "name": "cond" 121 | }, 122 | "config": { 123 | "name": "config" 124 | }, 125 | "latent": { 126 | "name": "latent" 127 | }, 128 | "model": { 129 | "name": "modèle" 130 | }, 131 | "uncond": { 132 | "name": "non cond" 133 | }, 134 | "weight": { 135 | "name": "poids" 136 | } 137 | } 138 | }, 139 | "LayeredDiffusionJointApply": { 140 | "display_name": "Appliquer Diffusion Conjointe en Couches", 141 | "inputs": { 142 | "bg_cond": { 143 | "name": "cond_bg" 144 | }, 145 | "blended_cond": { 146 | "name": "cond mélangé" 147 | }, 148 | "config": { 149 | "name": "config" 150 | }, 151 | "fg_cond": { 152 | "name": "cond_fg" 153 | }, 154 | "model": { 155 | "name": "modèle" 156 | } 157 | } 158 | } 159 | } -------------------------------------------------------------------------------- /locales/ja/main.json: -------------------------------------------------------------------------------- 1 | { 2 | "nodeCategories": { 3 | "layer_diffuse": "レイヤー_拡散" 4 | } 5 | } -------------------------------------------------------------------------------- /locales/ja/nodeDefs.json: -------------------------------------------------------------------------------- 1 | { 2 | "LayeredDiffusionApply": { 3 | "display_name": "レイヤー拡散適用", 4 | "inputs": { 5 | "config": { 6 | "name": "設定" 7 | }, 8 | "model": { 9 | "name": "モデル" 10 | }, 11 | "weight": { 12 | "name": "重み" 13 | } 14 | } 15 | }, 16 | "LayeredDiffusionCondApply": { 17 | "display_name": "レイヤー拡散条件付き適用", 18 | "inputs": { 19 | "cond": { 20 | "name": "条件" 21 | }, 22 | "config": { 23 | "name": "設定" 24 | }, 25 | "latent": { 26 | "name": "潜在" 27 | }, 28 | "model": { 29 | "name": "モデル" 30 | }, 31 | "uncond": { 32 | "name": "非条件" 33 | }, 34 | "weight": { 35 | "name": "重み" 36 | } 37 | } 38 | }, 39 | "LayeredDiffusionCondJointApply": { 40 | "display_name": "レイヤー拡散条件付き共同適用", 41 | "inputs": { 42 | "blended_cond": { 43 | "name": "ブレンド条件" 44 | }, 45 | "cond": { 46 | "name": "条件" 47 | }, 48 | "config": { 49 | "name": "設定" 50 | }, 51 | "image": { 52 | "name": "画像" 53 | }, 54 | "model": { 55 | "name": "モデル" 56 | } 57 | } 58 | }, 59 | "LayeredDiffusionDecode": { 60 | "display_name": "レイヤー拡散デコード", 61 | "inputs": { 62 | "images": { 63 | "name": "画像" 64 | }, 65 | "samples": { 66 | "name": "サンプル" 67 | }, 68 | "sd_version": { 69 | "name": "sdバージョン" 70 | }, 71 | "sub_batch_size": { 72 | "name": "サブバッチサイズ" 73 | } 74 | } 75 | }, 76 | "LayeredDiffusionDecodeRGBA": { 77 | "display_name": "レイヤー拡散デコード(RGBA)", 78 | "inputs": { 79 | "images": { 80 | "name": "画像" 81 | }, 82 | "samples": { 83 | "name": "サンプル" 84 | }, 85 | "sd_version": { 86 | "name": "sdバージョン" 87 | }, 88 | "sub_batch_size": { 89 | "name": "サブバッチサイズ" 90 | } 91 | } 92 | }, 93 | "LayeredDiffusionDecodeSplit": { 94 | "display_name": "レイヤー拡散デコード(スプリット)", 95 | "inputs": { 96 | "frames": { 97 | "name": "フレーム" 98 | }, 99 | "images": { 100 | "name": "画像" 101 | }, 102 | "samples": { 103 | "name": "サンプル" 104 | }, 105 | "sd_version": { 106 | "name": "sdバージョン" 107 | }, 108 | "sub_batch_size": { 109 | "name": "サブバッチサイズ" 110 | } 111 | } 112 | }, 113 | "LayeredDiffusionDiffApply": { 114 | "display_name": "レイヤー拡散差分適用", 115 | "inputs": { 116 | "blended_latent": { 117 | "name": "ブレンド潜在" 118 | }, 119 | "cond": { 120 | "name": "条件" 121 | }, 122 | "config": { 123 | "name": "設定" 124 | }, 125 | "latent": { 126 | "name": "潜在" 127 | }, 128 | "model": { 129 | "name": "モデル" 130 | }, 131 | "uncond": { 132 | "name": "非条件" 133 | }, 134 | "weight": { 135 | "name": "重み" 136 | } 137 | } 138 | }, 139 | "LayeredDiffusionJointApply": { 140 | "display_name": "レイヤー拡散共同適用", 141 | "inputs": { 142 | "bg_cond": { 143 | "name": "bg条件" 144 | }, 145 | "blended_cond": { 146 | "name": "ブレンド条件" 147 | }, 148 | "config": { 149 | "name": "設定" 150 | }, 151 | "fg_cond": { 152 | "name": "fg条件" 153 | }, 154 | "model": { 155 | "name": "モデル" 156 | } 157 | } 158 | } 159 | } -------------------------------------------------------------------------------- /locales/ko/main.json: -------------------------------------------------------------------------------- 1 | { 2 | "nodeCategories": { 3 | "layer_diffuse": "레이어_확산" 4 | } 5 | } -------------------------------------------------------------------------------- /locales/ko/nodeDefs.json: -------------------------------------------------------------------------------- 1 | { 2 | "LayeredDiffusionApply": { 3 | "display_name": "레이어 확산 적용", 4 | "inputs": { 5 | "config": { 6 | "name": "설정" 7 | }, 8 | "model": { 9 | "name": "모델" 10 | }, 11 | "weight": { 12 | "name": "가중치" 13 | } 14 | } 15 | }, 16 | "LayeredDiffusionCondApply": { 17 | "display_name": "레이어 확산 조건 적용", 18 | "inputs": { 19 | "cond": { 20 | "name": "조건" 21 | }, 22 | "config": { 23 | "name": "설정" 24 | }, 25 | "latent": { 26 | "name": "잠재" 27 | }, 28 | "model": { 29 | "name": "모델" 30 | }, 31 | "uncond": { 32 | "name": "비조건" 33 | }, 34 | "weight": { 35 | "name": "가중치" 36 | } 37 | } 38 | }, 39 | "LayeredDiffusionCondJointApply": { 40 | "display_name": "레이어 확산 조건 결합 적용", 41 | "inputs": { 42 | "blended_cond": { 43 | "name": "혼합된 조건" 44 | }, 45 | "cond": { 46 | "name": "조건" 47 | }, 48 | "config": { 49 | "name": "설정" 50 | }, 51 | "image": { 52 | "name": "이미지" 53 | }, 54 | "model": { 55 | "name": "모델" 56 | } 57 | } 58 | }, 59 | "LayeredDiffusionDecode": { 60 | "display_name": "레이어 확산 디코드", 61 | "inputs": { 62 | "images": { 63 | "name": "이미지" 64 | }, 65 | "samples": { 66 | "name": "샘플" 67 | }, 68 | "sd_version": { 69 | "name": "sd_version" 70 | }, 71 | "sub_batch_size": { 72 | "name": "sub_batch_size" 73 | } 74 | } 75 | }, 76 | "LayeredDiffusionDecodeRGBA": { 77 | "display_name": "레이어 확산 디코드 (RGBA)", 78 | "inputs": { 79 | "images": { 80 | "name": "이미지" 81 | }, 82 | "samples": { 83 | "name": "샘플" 84 | }, 85 | "sd_version": { 86 | "name": "sd_version" 87 | }, 88 | "sub_batch_size": { 89 | "name": "sub_batch_size" 90 | } 91 | } 92 | }, 93 | "LayeredDiffusionDecodeSplit": { 94 | "display_name": "레이어 확산 디코드 (분할)", 95 | "inputs": { 96 | "frames": { 97 | "name": "프레임" 98 | }, 99 | "images": { 100 | "name": "이미지" 101 | }, 102 | "samples": { 103 | "name": "샘플" 104 | }, 105 | "sd_version": { 106 | "name": "sd_version" 107 | }, 108 | "sub_batch_size": { 109 | "name": "sub_batch_size" 110 | } 111 | } 112 | }, 113 | "LayeredDiffusionDiffApply": { 114 | "display_name": "레이어 확산 차이 적용", 115 | "inputs": { 116 | "blended_latent": { 117 | "name": "혼합된 잠재" 118 | }, 119 | "cond": { 120 | "name": "조건" 121 | }, 122 | "config": { 123 | "name": "설정" 124 | }, 125 | "latent": { 126 | "name": "잠재" 127 | }, 128 | "model": { 129 | "name": "모델" 130 | }, 131 | "uncond": { 132 | "name": "비조건" 133 | }, 134 | "weight": { 135 | "name": "가중치" 136 | } 137 | } 138 | }, 139 | "LayeredDiffusionJointApply": { 140 | "display_name": "레이어 확산 결합 적용", 141 | "inputs": { 142 | "bg_cond": { 143 | "name": "배경 조건" 144 | }, 145 | "blended_cond": { 146 | "name": "혼합된 조건" 147 | }, 148 | "config": { 149 | "name": "설정" 150 | }, 151 | "fg_cond": { 152 | "name": "전경 조건" 153 | }, 154 | "model": { 155 | "name": "모델" 156 | } 157 | } 158 | } 159 | } -------------------------------------------------------------------------------- /locales/ru/main.json: -------------------------------------------------------------------------------- 1 | { 2 | "nodeCategories": { 3 | "layer_diffuse": "слой_рассеивания" 4 | } 5 | } -------------------------------------------------------------------------------- /locales/ru/nodeDefs.json: -------------------------------------------------------------------------------- 1 | { 2 | "LayeredDiffusionApply": { 3 | "display_name": "Применение слоя диффузии", 4 | "inputs": { 5 | "config": { 6 | "name": "конфиг" 7 | }, 8 | "model": { 9 | "name": "модель" 10 | }, 11 | "weight": { 12 | "name": "вес" 13 | } 14 | } 15 | }, 16 | "LayeredDiffusionCondApply": { 17 | "display_name": "Применение условной диффузии слоя", 18 | "inputs": { 19 | "cond": { 20 | "name": "условие" 21 | }, 22 | "config": { 23 | "name": "конфиг" 24 | }, 25 | "latent": { 26 | "name": "скрытый" 27 | }, 28 | "model": { 29 | "name": "модель" 30 | }, 31 | "uncond": { 32 | "name": "безусловный" 33 | }, 34 | "weight": { 35 | "name": "вес" 36 | } 37 | } 38 | }, 39 | "LayeredDiffusionCondJointApply": { 40 | "display_name": "Совместное применение условной диффузии слоя", 41 | "inputs": { 42 | "blended_cond": { 43 | "name": "смешанное условие" 44 | }, 45 | "cond": { 46 | "name": "условие" 47 | }, 48 | "config": { 49 | "name": "конфиг" 50 | }, 51 | "image": { 52 | "name": "изображение" 53 | }, 54 | "model": { 55 | "name": "модель" 56 | } 57 | } 58 | }, 59 | "LayeredDiffusionDecode": { 60 | "display_name": "Декодирование слоя диффузии", 61 | "inputs": { 62 | "images": { 63 | "name": "изображения" 64 | }, 65 | "samples": { 66 | "name": "образцы" 67 | }, 68 | "sd_version": { 69 | "name": "версия_sd" 70 | }, 71 | "sub_batch_size": { 72 | "name": "размер_подпакета" 73 | } 74 | } 75 | }, 76 | "LayeredDiffusionDecodeRGBA": { 77 | "display_name": "Декодирование слоя диффузии (RGBA)", 78 | "inputs": { 79 | "images": { 80 | "name": "изображения" 81 | }, 82 | "samples": { 83 | "name": "образцы" 84 | }, 85 | "sd_version": { 86 | "name": "версия_sd" 87 | }, 88 | "sub_batch_size": { 89 | "name": "размер_подпакета" 90 | } 91 | } 92 | }, 93 | "LayeredDiffusionDecodeSplit": { 94 | "display_name": "Декодирование слоя диффузии (Разделение)", 95 | "inputs": { 96 | "frames": { 97 | "name": "кадры" 98 | }, 99 | "images": { 100 | "name": "изображения" 101 | }, 102 | "samples": { 103 | "name": "образцы" 104 | }, 105 | "sd_version": { 106 | "name": "версия_sd" 107 | }, 108 | "sub_batch_size": { 109 | "name": "размер_подпакета" 110 | } 111 | } 112 | }, 113 | "LayeredDiffusionDiffApply": { 114 | "display_name": "Применение дифференцирования диффузии слоя", 115 | "inputs": { 116 | "blended_latent": { 117 | "name": "смешанное скрытое" 118 | }, 119 | "cond": { 120 | "name": "условие" 121 | }, 122 | "config": { 123 | "name": "конфиг" 124 | }, 125 | "latent": { 126 | "name": "скрытый" 127 | }, 128 | "model": { 129 | "name": "модель" 130 | }, 131 | "uncond": { 132 | "name": "безусловный" 133 | }, 134 | "weight": { 135 | "name": "вес" 136 | } 137 | } 138 | }, 139 | "LayeredDiffusionJointApply": { 140 | "display_name": "Совместное применение слоя диффузии", 141 | "inputs": { 142 | "bg_cond": { 143 | "name": "bg_условие" 144 | }, 145 | "blended_cond": { 146 | "name": "смешанное условие" 147 | }, 148 | "config": { 149 | "name": "конфиг" 150 | }, 151 | "fg_cond": { 152 | "name": "fg_условие" 153 | }, 154 | "model": { 155 | "name": "модель" 156 | } 157 | } 158 | } 159 | } -------------------------------------------------------------------------------- /locales/zh/main.json: -------------------------------------------------------------------------------- 1 | { 2 | "nodeCategories": { 3 | "layer_diffuse": "扩散层" 4 | } 5 | } -------------------------------------------------------------------------------- /locales/zh/nodeDefs.json: -------------------------------------------------------------------------------- 1 | { 2 | "LayeredDiffusionApply": { 3 | "display_name": "层次扩散应用", 4 | "inputs": { 5 | "config": { 6 | "name": "配置" 7 | }, 8 | "model": { 9 | "name": "模型" 10 | }, 11 | "weight": { 12 | "name": "权重" 13 | } 14 | } 15 | }, 16 | "LayeredDiffusionCondApply": { 17 | "display_name": "层次扩散条件应用", 18 | "inputs": { 19 | "cond": { 20 | "name": "条件" 21 | }, 22 | "config": { 23 | "name": "配置" 24 | }, 25 | "latent": { 26 | "name": "潜在" 27 | }, 28 | "model": { 29 | "name": "模型" 30 | }, 31 | "uncond": { 32 | "name": "无条件" 33 | }, 34 | "weight": { 35 | "name": "权重" 36 | } 37 | } 38 | }, 39 | "LayeredDiffusionCondJointApply": { 40 | "display_name": "层次扩散条件联合应用", 41 | "inputs": { 42 | "blended_cond": { 43 | "name": "混合条件" 44 | }, 45 | "cond": { 46 | "name": "条件" 47 | }, 48 | "config": { 49 | "name": "配置" 50 | }, 51 | "image": { 52 | "name": "图像" 53 | }, 54 | "model": { 55 | "name": "模型" 56 | } 57 | } 58 | }, 59 | "LayeredDiffusionDecode": { 60 | "display_name": "层次扩散解码", 61 | "inputs": { 62 | "images": { 63 | "name": "图像" 64 | }, 65 | "samples": { 66 | "name": "样本" 67 | }, 68 | "sd_version": { 69 | "name": "sd版本" 70 | }, 71 | "sub_batch_size": { 72 | "name": "子批量大小" 73 | } 74 | } 75 | }, 76 | "LayeredDiffusionDecodeRGBA": { 77 | "display_name": "层次扩散解码(RGBA)", 78 | "inputs": { 79 | "images": { 80 | "name": "图像" 81 | }, 82 | "samples": { 83 | "name": "样本" 84 | }, 85 | "sd_version": { 86 | "name": "sd版本" 87 | }, 88 | "sub_batch_size": { 89 | "name": "子批量大小" 90 | } 91 | } 92 | }, 93 | "LayeredDiffusionDecodeSplit": { 94 | "display_name": "层次扩散解码(分割)", 95 | "inputs": { 96 | "frames": { 97 | "name": "帧" 98 | }, 99 | "images": { 100 | "name": "图像" 101 | }, 102 | "samples": { 103 | "name": "样本" 104 | }, 105 | "sd_version": { 106 | "name": "sd版本" 107 | }, 108 | "sub_batch_size": { 109 | "name": "子批量大小" 110 | } 111 | } 112 | }, 113 | "LayeredDiffusionDiffApply": { 114 | "display_name": "层次扩散差异应用", 115 | "inputs": { 116 | "blended_latent": { 117 | "name": "混合潜在" 118 | }, 119 | "cond": { 120 | "name": "条件" 121 | }, 122 | "config": { 123 | "name": "配置" 124 | }, 125 | "latent": { 126 | "name": "潜在" 127 | }, 128 | "model": { 129 | "name": "模型" 130 | }, 131 | "uncond": { 132 | "name": "无条件" 133 | }, 134 | "weight": { 135 | "name": "权重" 136 | } 137 | } 138 | }, 139 | "LayeredDiffusionJointApply": { 140 | "display_name": "层次扩散联合应用", 141 | "inputs": { 142 | "bg_cond": { 143 | "name": "背景条件" 144 | }, 145 | "blended_cond": { 146 | "name": "混合条件" 147 | }, 148 | "config": { 149 | "name": "配置" 150 | }, 151 | "fg_cond": { 152 | "name": "前景条件" 153 | }, 154 | "model": { 155 | "name": "模型" 156 | } 157 | } 158 | } 159 | } -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | name = "comfyui-layerdiffuse" 3 | description = "Transparent Image Layer Diffusion using Latent Transparency" 4 | version = "1.0.4" 5 | license = { file = "LICENSE" } 6 | dependencies = ["diffusers>=0.25.0", "opencv-python"] 7 | 8 | [project.urls] 9 | Repository = "https://github.com/huchenlei/ComfyUI-layerdiffuse" 10 | 11 | # Used by Comfy Registry https://comfyregistry.org 12 | [tool.comfy] 13 | PublisherId = "huchenlei" 14 | DisplayName = "ComfyUI-layerdiffuse" 15 | Icon = "" 16 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | diffusers>=0.29.0 2 | opencv-python 3 | --------------------------------------------------------------------------------