StupidGame commited on
Commit
baa8e90
β€’
1 Parent(s): c30520a

Upload 1941 files

Browse files
This view is limited to 50 files because it contains too many changes. Β  See raw diff
Files changed (50) hide show
  1. .gitattributes +3 -0
  2. custom_nodes/ComfyUI-Advanced-ControlNet/.gitignore +160 -0
  3. custom_nodes/ComfyUI-Advanced-ControlNet/LICENSE +674 -0
  4. custom_nodes/ComfyUI-Advanced-ControlNet/README.md +151 -0
  5. custom_nodes/ComfyUI-Advanced-ControlNet/__init__.py +3 -0
  6. custom_nodes/ComfyUI-Advanced-ControlNet/__pycache__/__init__.cpython-310.pyc +0 -0
  7. custom_nodes/ComfyUI-Advanced-ControlNet/__pycache__/__init__.cpython-311.pyc +0 -0
  8. custom_nodes/ComfyUI-Advanced-ControlNet/control/__pycache__/control.cpython-310.pyc +0 -0
  9. custom_nodes/ComfyUI-Advanced-ControlNet/control/__pycache__/control.cpython-311.pyc +0 -0
  10. custom_nodes/ComfyUI-Advanced-ControlNet/control/__pycache__/deprecated_nodes.cpython-310.pyc +0 -0
  11. custom_nodes/ComfyUI-Advanced-ControlNet/control/__pycache__/deprecated_nodes.cpython-311.pyc +0 -0
  12. custom_nodes/ComfyUI-Advanced-ControlNet/control/__pycache__/latent_keyframe_nodes.cpython-310.pyc +0 -0
  13. custom_nodes/ComfyUI-Advanced-ControlNet/control/__pycache__/latent_keyframe_nodes.cpython-311.pyc +0 -0
  14. custom_nodes/ComfyUI-Advanced-ControlNet/control/__pycache__/logger.cpython-310.pyc +0 -0
  15. custom_nodes/ComfyUI-Advanced-ControlNet/control/__pycache__/logger.cpython-311.pyc +0 -0
  16. custom_nodes/ComfyUI-Advanced-ControlNet/control/__pycache__/nodes.cpython-310.pyc +0 -0
  17. custom_nodes/ComfyUI-Advanced-ControlNet/control/__pycache__/nodes.cpython-311.pyc +0 -0
  18. custom_nodes/ComfyUI-Advanced-ControlNet/control/__pycache__/weight_nodes.cpython-310.pyc +0 -0
  19. custom_nodes/ComfyUI-Advanced-ControlNet/control/__pycache__/weight_nodes.cpython-311.pyc +0 -0
  20. custom_nodes/ComfyUI-Advanced-ControlNet/control/control.py +770 -0
  21. custom_nodes/ComfyUI-Advanced-ControlNet/control/control_lllite.py +1 -0
  22. custom_nodes/ComfyUI-Advanced-ControlNet/control/deprecated_nodes.py +103 -0
  23. custom_nodes/ComfyUI-Advanced-ControlNet/control/latent_keyframe_nodes.py +283 -0
  24. custom_nodes/ComfyUI-Advanced-ControlNet/control/logger.py +36 -0
  25. custom_nodes/ComfyUI-Advanced-ControlNet/control/nodes.py +243 -0
  26. custom_nodes/ComfyUI-Advanced-ControlNet/control/reference_nodes.py +12 -0
  27. custom_nodes/ComfyUI-Advanced-ControlNet/control/weight_nodes.py +201 -0
  28. custom_nodes/ComfyUI-Advanced-ControlNet/requirements.txt +0 -0
  29. custom_nodes/ComfyUI-Custom-Scripts/.gitignore +1 -0
  30. custom_nodes/ComfyUI-Custom-Scripts/LICENSE +21 -0
  31. custom_nodes/ComfyUI-Custom-Scripts/README.md +394 -0
  32. custom_nodes/ComfyUI-Custom-Scripts/__init__.py +25 -0
  33. custom_nodes/ComfyUI-Custom-Scripts/__pycache__/__init__.cpython-310.pyc +0 -0
  34. custom_nodes/ComfyUI-Custom-Scripts/__pycache__/__init__.cpython-311.pyc +0 -0
  35. custom_nodes/ComfyUI-Custom-Scripts/__pycache__/pysssss.cpython-310.pyc +0 -0
  36. custom_nodes/ComfyUI-Custom-Scripts/__pycache__/pysssss.cpython-311.pyc +0 -0
  37. custom_nodes/ComfyUI-Custom-Scripts/py/__pycache__/autocomplete.cpython-310.pyc +0 -0
  38. custom_nodes/ComfyUI-Custom-Scripts/py/__pycache__/autocomplete.cpython-311.pyc +0 -0
  39. custom_nodes/ComfyUI-Custom-Scripts/py/__pycache__/better_combos.cpython-310.pyc +0 -0
  40. custom_nodes/ComfyUI-Custom-Scripts/py/__pycache__/better_combos.cpython-311.pyc +0 -0
  41. custom_nodes/ComfyUI-Custom-Scripts/py/__pycache__/constrain_image.cpython-310.pyc +0 -0
  42. custom_nodes/ComfyUI-Custom-Scripts/py/__pycache__/constrain_image.cpython-311.pyc +0 -0
  43. custom_nodes/ComfyUI-Custom-Scripts/py/__pycache__/math_expression.cpython-310.pyc +0 -0
  44. custom_nodes/ComfyUI-Custom-Scripts/py/__pycache__/math_expression.cpython-311.pyc +0 -0
  45. custom_nodes/ComfyUI-Custom-Scripts/py/__pycache__/model_info.cpython-310.pyc +0 -0
  46. custom_nodes/ComfyUI-Custom-Scripts/py/__pycache__/model_info.cpython-311.pyc +0 -0
  47. custom_nodes/ComfyUI-Custom-Scripts/py/__pycache__/play_sound.cpython-310.pyc +0 -0
  48. custom_nodes/ComfyUI-Custom-Scripts/py/__pycache__/play_sound.cpython-311.pyc +0 -0
  49. custom_nodes/ComfyUI-Custom-Scripts/py/__pycache__/repeater.cpython-310.pyc +0 -0
  50. custom_nodes/ComfyUI-Custom-Scripts/py/__pycache__/repeater.cpython-311.pyc +0 -0
.gitattributes CHANGED
@@ -33,3 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ custom_nodes/ComfyUI_TiledKSampler/examples/ComfyUI_02006_.png filter=lfs diff=lfs merge=lfs -text
37
+ custom_nodes/ComfyUI_TiledKSampler/examples/ComfyUI_02010_.png filter=lfs diff=lfs merge=lfs -text
38
+ custom_nodes/ComfyUI-sampler-lcm-alternative/SamplerLCMCycle-example.png filter=lfs diff=lfs merge=lfs -text
custom_nodes/ComfyUI-Advanced-ControlNet/.gitignore ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/
custom_nodes/ComfyUI-Advanced-ControlNet/LICENSE ADDED
@@ -0,0 +1,674 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ Preamble
9
+
10
+ The GNU General Public License is a free, copyleft license for
11
+ software and other kinds of works.
12
+
13
+ The licenses for most software and other practical works are designed
14
+ to take away your freedom to share and change the works. By contrast,
15
+ the GNU General Public License is intended to guarantee your freedom to
16
+ share and change all versions of a program--to make sure it remains free
17
+ software for all its users. We, the Free Software Foundation, use the
18
+ GNU General Public License for most of our software; it applies also to
19
+ any other work released this way by its authors. You can apply it to
20
+ your programs, too.
21
+
22
+ When we speak of free software, we are referring to freedom, not
23
+ price. Our General Public Licenses are designed to make sure that you
24
+ have the freedom to distribute copies of free software (and charge for
25
+ them if you wish), that you receive source code or can get it if you
26
+ want it, that you can change the software or use pieces of it in new
27
+ free programs, and that you know you can do these things.
28
+
29
+ To protect your rights, we need to prevent others from denying you
30
+ these rights or asking you to surrender the rights. Therefore, you have
31
+ certain responsibilities if you distribute copies of the software, or if
32
+ you modify it: responsibilities to respect the freedom of others.
33
+
34
+ For example, if you distribute copies of such a program, whether
35
+ gratis or for a fee, you must pass on to the recipients the same
36
+ freedoms that you received. You must make sure that they, too, receive
37
+ or can get the source code. And you must show them these terms so they
38
+ know their rights.
39
+
40
+ Developers that use the GNU GPL protect your rights with two steps:
41
+ (1) assert copyright on the software, and (2) offer you this License
42
+ giving you legal permission to copy, distribute and/or modify it.
43
+
44
+ For the developers' and authors' protection, the GPL clearly explains
45
+ that there is no warranty for this free software. For both users' and
46
+ authors' sake, the GPL requires that modified versions be marked as
47
+ changed, so that their problems will not be attributed erroneously to
48
+ authors of previous versions.
49
+
50
+ Some devices are designed to deny users access to install or run
51
+ modified versions of the software inside them, although the manufacturer
52
+ can do so. This is fundamentally incompatible with the aim of
53
+ protecting users' freedom to change the software. The systematic
54
+ pattern of such abuse occurs in the area of products for individuals to
55
+ use, which is precisely where it is most unacceptable. Therefore, we
56
+ have designed this version of the GPL to prohibit the practice for those
57
+ products. If such problems arise substantially in other domains, we
58
+ stand ready to extend this provision to those domains in future versions
59
+ of the GPL, as needed to protect the freedom of users.
60
+
61
+ Finally, every program is threatened constantly by software patents.
62
+ States should not allow patents to restrict development and use of
63
+ software on general-purpose computers, but in those that do, we wish to
64
+ avoid the special danger that patents applied to a free program could
65
+ make it effectively proprietary. To prevent this, the GPL assures that
66
+ patents cannot be used to render the program non-free.
67
+
68
+ The precise terms and conditions for copying, distribution and
69
+ modification follow.
70
+
71
+ TERMS AND CONDITIONS
72
+
73
+ 0. Definitions.
74
+
75
+ "This License" refers to version 3 of the GNU General Public License.
76
+
77
+ "Copyright" also means copyright-like laws that apply to other kinds of
78
+ works, such as semiconductor masks.
79
+
80
+ "The Program" refers to any copyrightable work licensed under this
81
+ License. Each licensee is addressed as "you". "Licensees" and
82
+ "recipients" may be individuals or organizations.
83
+
84
+ To "modify" a work means to copy from or adapt all or part of the work
85
+ in a fashion requiring copyright permission, other than the making of an
86
+ exact copy. The resulting work is called a "modified version" of the
87
+ earlier work or a work "based on" the earlier work.
88
+
89
+ A "covered work" means either the unmodified Program or a work based
90
+ on the Program.
91
+
92
+ To "propagate" a work means to do anything with it that, without
93
+ permission, would make you directly or secondarily liable for
94
+ infringement under applicable copyright law, except executing it on a
95
+ computer or modifying a private copy. Propagation includes copying,
96
+ distribution (with or without modification), making available to the
97
+ public, and in some countries other activities as well.
98
+
99
+ To "convey" a work means any kind of propagation that enables other
100
+ parties to make or receive copies. Mere interaction with a user through
101
+ a computer network, with no transfer of a copy, is not conveying.
102
+
103
+ An interactive user interface displays "Appropriate Legal Notices"
104
+ to the extent that it includes a convenient and prominently visible
105
+ feature that (1) displays an appropriate copyright notice, and (2)
106
+ tells the user that there is no warranty for the work (except to the
107
+ extent that warranties are provided), that licensees may convey the
108
+ work under this License, and how to view a copy of this License. If
109
+ the interface presents a list of user commands or options, such as a
110
+ menu, a prominent item in the list meets this criterion.
111
+
112
+ 1. Source Code.
113
+
114
+ The "source code" for a work means the preferred form of the work
115
+ for making modifications to it. "Object code" means any non-source
116
+ form of a work.
117
+
118
+ A "Standard Interface" means an interface that either is an official
119
+ standard defined by a recognized standards body, or, in the case of
120
+ interfaces specified for a particular programming language, one that
121
+ is widely used among developers working in that language.
122
+
123
+ The "System Libraries" of an executable work include anything, other
124
+ than the work as a whole, that (a) is included in the normal form of
125
+ packaging a Major Component, but which is not part of that Major
126
+ Component, and (b) serves only to enable use of the work with that
127
+ Major Component, or to implement a Standard Interface for which an
128
+ implementation is available to the public in source code form. A
129
+ "Major Component", in this context, means a major essential component
130
+ (kernel, window system, and so on) of the specific operating system
131
+ (if any) on which the executable work runs, or a compiler used to
132
+ produce the work, or an object code interpreter used to run it.
133
+
134
+ The "Corresponding Source" for a work in object code form means all
135
+ the source code needed to generate, install, and (for an executable
136
+ work) run the object code and to modify the work, including scripts to
137
+ control those activities. However, it does not include the work's
138
+ System Libraries, or general-purpose tools or generally available free
139
+ programs which are used unmodified in performing those activities but
140
+ which are not part of the work. For example, Corresponding Source
141
+ includes interface definition files associated with source files for
142
+ the work, and the source code for shared libraries and dynamically
143
+ linked subprograms that the work is specifically designed to require,
144
+ such as by intimate data communication or control flow between those
145
+ subprograms and other parts of the work.
146
+
147
+ The Corresponding Source need not include anything that users
148
+ can regenerate automatically from other parts of the Corresponding
149
+ Source.
150
+
151
+ The Corresponding Source for a work in source code form is that
152
+ same work.
153
+
154
+ 2. Basic Permissions.
155
+
156
+ All rights granted under this License are granted for the term of
157
+ copyright on the Program, and are irrevocable provided the stated
158
+ conditions are met. This License explicitly affirms your unlimited
159
+ permission to run the unmodified Program. The output from running a
160
+ covered work is covered by this License only if the output, given its
161
+ content, constitutes a covered work. This License acknowledges your
162
+ rights of fair use or other equivalent, as provided by copyright law.
163
+
164
+ You may make, run and propagate covered works that you do not
165
+ convey, without conditions so long as your license otherwise remains
166
+ in force. You may convey covered works to others for the sole purpose
167
+ of having them make modifications exclusively for you, or provide you
168
+ with facilities for running those works, provided that you comply with
169
+ the terms of this License in conveying all material for which you do
170
+ not control copyright. Those thus making or running the covered works
171
+ for you must do so exclusively on your behalf, under your direction
172
+ and control, on terms that prohibit them from making any copies of
173
+ your copyrighted material outside their relationship with you.
174
+
175
+ Conveying under any other circumstances is permitted solely under
176
+ the conditions stated below. Sublicensing is not allowed; section 10
177
+ makes it unnecessary.
178
+
179
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
+
181
+ No covered work shall be deemed part of an effective technological
182
+ measure under any applicable law fulfilling obligations under article
183
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184
+ similar laws prohibiting or restricting circumvention of such
185
+ measures.
186
+
187
+ When you convey a covered work, you waive any legal power to forbid
188
+ circumvention of technological measures to the extent such circumvention
189
+ is effected by exercising rights under this License with respect to
190
+ the covered work, and you disclaim any intention to limit operation or
191
+ modification of the work as a means of enforcing, against the work's
192
+ users, your or third parties' legal rights to forbid circumvention of
193
+ technological measures.
194
+
195
+ 4. Conveying Verbatim Copies.
196
+
197
+ You may convey verbatim copies of the Program's source code as you
198
+ receive it, in any medium, provided that you conspicuously and
199
+ appropriately publish on each copy an appropriate copyright notice;
200
+ keep intact all notices stating that this License and any
201
+ non-permissive terms added in accord with section 7 apply to the code;
202
+ keep intact all notices of the absence of any warranty; and give all
203
+ recipients a copy of this License along with the Program.
204
+
205
+ You may charge any price or no price for each copy that you convey,
206
+ and you may offer support or warranty protection for a fee.
207
+
208
+ 5. Conveying Modified Source Versions.
209
+
210
+ You may convey a work based on the Program, or the modifications to
211
+ produce it from the Program, in the form of source code under the
212
+ terms of section 4, provided that you also meet all of these conditions:
213
+
214
+ a) The work must carry prominent notices stating that you modified
215
+ it, and giving a relevant date.
216
+
217
+ b) The work must carry prominent notices stating that it is
218
+ released under this License and any conditions added under section
219
+ 7. This requirement modifies the requirement in section 4 to
220
+ "keep intact all notices".
221
+
222
+ c) You must license the entire work, as a whole, under this
223
+ License to anyone who comes into possession of a copy. This
224
+ License will therefore apply, along with any applicable section 7
225
+ additional terms, to the whole of the work, and all its parts,
226
+ regardless of how they are packaged. This License gives no
227
+ permission to license the work in any other way, but it does not
228
+ invalidate such permission if you have separately received it.
229
+
230
+ d) If the work has interactive user interfaces, each must display
231
+ Appropriate Legal Notices; however, if the Program has interactive
232
+ interfaces that do not display Appropriate Legal Notices, your
233
+ work need not make them do so.
234
+
235
+ A compilation of a covered work with other separate and independent
236
+ works, which are not by their nature extensions of the covered work,
237
+ and which are not combined with it such as to form a larger program,
238
+ in or on a volume of a storage or distribution medium, is called an
239
+ "aggregate" if the compilation and its resulting copyright are not
240
+ used to limit the access or legal rights of the compilation's users
241
+ beyond what the individual works permit. Inclusion of a covered work
242
+ in an aggregate does not cause this License to apply to the other
243
+ parts of the aggregate.
244
+
245
+ 6. Conveying Non-Source Forms.
246
+
247
+ You may convey a covered work in object code form under the terms
248
+ of sections 4 and 5, provided that you also convey the
249
+ machine-readable Corresponding Source under the terms of this License,
250
+ in one of these ways:
251
+
252
+ a) Convey the object code in, or embodied in, a physical product
253
+ (including a physical distribution medium), accompanied by the
254
+ Corresponding Source fixed on a durable physical medium
255
+ customarily used for software interchange.
256
+
257
+ b) Convey the object code in, or embodied in, a physical product
258
+ (including a physical distribution medium), accompanied by a
259
+ written offer, valid for at least three years and valid for as
260
+ long as you offer spare parts or customer support for that product
261
+ model, to give anyone who possesses the object code either (1) a
262
+ copy of the Corresponding Source for all the software in the
263
+ product that is covered by this License, on a durable physical
264
+ medium customarily used for software interchange, for a price no
265
+ more than your reasonable cost of physically performing this
266
+ conveying of source, or (2) access to copy the
267
+ Corresponding Source from a network server at no charge.
268
+
269
+ c) Convey individual copies of the object code with a copy of the
270
+ written offer to provide the Corresponding Source. This
271
+ alternative is allowed only occasionally and noncommercially, and
272
+ only if you received the object code with such an offer, in accord
273
+ with subsection 6b.
274
+
275
+ d) Convey the object code by offering access from a designated
276
+ place (gratis or for a charge), and offer equivalent access to the
277
+ Corresponding Source in the same way through the same place at no
278
+ further charge. You need not require recipients to copy the
279
+ Corresponding Source along with the object code. If the place to
280
+ copy the object code is a network server, the Corresponding Source
281
+ may be on a different server (operated by you or a third party)
282
+ that supports equivalent copying facilities, provided you maintain
283
+ clear directions next to the object code saying where to find the
284
+ Corresponding Source. Regardless of what server hosts the
285
+ Corresponding Source, you remain obligated to ensure that it is
286
+ available for as long as needed to satisfy these requirements.
287
+
288
+ e) Convey the object code using peer-to-peer transmission, provided
289
+ you inform other peers where the object code and Corresponding
290
+ Source of the work are being offered to the general public at no
291
+ charge under subsection 6d.
292
+
293
+ A separable portion of the object code, whose source code is excluded
294
+ from the Corresponding Source as a System Library, need not be
295
+ included in conveying the object code work.
296
+
297
+ A "User Product" is either (1) a "consumer product", which means any
298
+ tangible personal property which is normally used for personal, family,
299
+ or household purposes, or (2) anything designed or sold for incorporation
300
+ into a dwelling. In determining whether a product is a consumer product,
301
+ doubtful cases shall be resolved in favor of coverage. For a particular
302
+ product received by a particular user, "normally used" refers to a
303
+ typical or common use of that class of product, regardless of the status
304
+ of the particular user or of the way in which the particular user
305
+ actually uses, or expects or is expected to use, the product. A product
306
+ is a consumer product regardless of whether the product has substantial
307
+ commercial, industrial or non-consumer uses, unless such uses represent
308
+ the only significant mode of use of the product.
309
+
310
+ "Installation Information" for a User Product means any methods,
311
+ procedures, authorization keys, or other information required to install
312
+ and execute modified versions of a covered work in that User Product from
313
+ a modified version of its Corresponding Source. The information must
314
+ suffice to ensure that the continued functioning of the modified object
315
+ code is in no case prevented or interfered with solely because
316
+ modification has been made.
317
+
318
+ If you convey an object code work under this section in, or with, or
319
+ specifically for use in, a User Product, and the conveying occurs as
320
+ part of a transaction in which the right of possession and use of the
321
+ User Product is transferred to the recipient in perpetuity or for a
322
+ fixed term (regardless of how the transaction is characterized), the
323
+ Corresponding Source conveyed under this section must be accompanied
324
+ by the Installation Information. But this requirement does not apply
325
+ if neither you nor any third party retains the ability to install
326
+ modified object code on the User Product (for example, the work has
327
+ been installed in ROM).
328
+
329
+ The requirement to provide Installation Information does not include a
330
+ requirement to continue to provide support service, warranty, or updates
331
+ for a work that has been modified or installed by the recipient, or for
332
+ the User Product in which it has been modified or installed. Access to a
333
+ network may be denied when the modification itself materially and
334
+ adversely affects the operation of the network or violates the rules and
335
+ protocols for communication across the network.
336
+
337
+ Corresponding Source conveyed, and Installation Information provided,
338
+ in accord with this section must be in a format that is publicly
339
+ documented (and with an implementation available to the public in
340
+ source code form), and must require no special password or key for
341
+ unpacking, reading or copying.
342
+
343
+ 7. Additional Terms.
344
+
345
+ "Additional permissions" are terms that supplement the terms of this
346
+ License by making exceptions from one or more of its conditions.
347
+ Additional permissions that are applicable to the entire Program shall
348
+ be treated as though they were included in this License, to the extent
349
+ that they are valid under applicable law. If additional permissions
350
+ apply only to part of the Program, that part may be used separately
351
+ under those permissions, but the entire Program remains governed by
352
+ this License without regard to the additional permissions.
353
+
354
+ When you convey a copy of a covered work, you may at your option
355
+ remove any additional permissions from that copy, or from any part of
356
+ it. (Additional permissions may be written to require their own
357
+ removal in certain cases when you modify the work.) You may place
358
+ additional permissions on material, added by you to a covered work,
359
+ for which you have or can give appropriate copyright permission.
360
+
361
+ Notwithstanding any other provision of this License, for material you
362
+ add to a covered work, you may (if authorized by the copyright holders of
363
+ that material) supplement the terms of this License with terms:
364
+
365
+ a) Disclaiming warranty or limiting liability differently from the
366
+ terms of sections 15 and 16 of this License; or
367
+
368
+ b) Requiring preservation of specified reasonable legal notices or
369
+ author attributions in that material or in the Appropriate Legal
370
+ Notices displayed by works containing it; or
371
+
372
+ c) Prohibiting misrepresentation of the origin of that material, or
373
+ requiring that modified versions of such material be marked in
374
+ reasonable ways as different from the original version; or
375
+
376
+ d) Limiting the use for publicity purposes of names of licensors or
377
+ authors of the material; or
378
+
379
+ e) Declining to grant rights under trademark law for use of some
380
+ trade names, trademarks, or service marks; or
381
+
382
+ f) Requiring indemnification of licensors and authors of that
383
+ material by anyone who conveys the material (or modified versions of
384
+ it) with contractual assumptions of liability to the recipient, for
385
+ any liability that these contractual assumptions directly impose on
386
+ those licensors and authors.
387
+
388
+ All other non-permissive additional terms are considered "further
389
+ restrictions" within the meaning of section 10. If the Program as you
390
+ received it, or any part of it, contains a notice stating that it is
391
+ governed by this License along with a term that is a further
392
+ restriction, you may remove that term. If a license document contains
393
+ a further restriction but permits relicensing or conveying under this
394
+ License, you may add to a covered work material governed by the terms
395
+ of that license document, provided that the further restriction does
396
+ not survive such relicensing or conveying.
397
+
398
+ If you add terms to a covered work in accord with this section, you
399
+ must place, in the relevant source files, a statement of the
400
+ additional terms that apply to those files, or a notice indicating
401
+ where to find the applicable terms.
402
+
403
+ Additional terms, permissive or non-permissive, may be stated in the
404
+ form of a separately written license, or stated as exceptions;
405
+ the above requirements apply either way.
406
+
407
+ 8. Termination.
408
+
409
+ You may not propagate or modify a covered work except as expressly
410
+ provided under this License. Any attempt otherwise to propagate or
411
+ modify it is void, and will automatically terminate your rights under
412
+ this License (including any patent licenses granted under the third
413
+ paragraph of section 11).
414
+
415
+ However, if you cease all violation of this License, then your
416
+ license from a particular copyright holder is reinstated (a)
417
+ provisionally, unless and until the copyright holder explicitly and
418
+ finally terminates your license, and (b) permanently, if the copyright
419
+ holder fails to notify you of the violation by some reasonable means
420
+ prior to 60 days after the cessation.
421
+
422
+ Moreover, your license from a particular copyright holder is
423
+ reinstated permanently if the copyright holder notifies you of the
424
+ violation by some reasonable means, this is the first time you have
425
+ received notice of violation of this License (for any work) from that
426
+ copyright holder, and you cure the violation prior to 30 days after
427
+ your receipt of the notice.
428
+
429
+ Termination of your rights under this section does not terminate the
430
+ licenses of parties who have received copies or rights from you under
431
+ this License. If your rights have been terminated and not permanently
432
+ reinstated, you do not qualify to receive new licenses for the same
433
+ material under section 10.
434
+
435
+ 9. Acceptance Not Required for Having Copies.
436
+
437
+ You are not required to accept this License in order to receive or
438
+ run a copy of the Program. Ancillary propagation of a covered work
439
+ occurring solely as a consequence of using peer-to-peer transmission
440
+ to receive a copy likewise does not require acceptance. However,
441
+ nothing other than this License grants you permission to propagate or
442
+ modify any covered work. These actions infringe copyright if you do
443
+ not accept this License. Therefore, by modifying or propagating a
444
+ covered work, you indicate your acceptance of this License to do so.
445
+
446
+ 10. Automatic Licensing of Downstream Recipients.
447
+
448
+ Each time you convey a covered work, the recipient automatically
449
+ receives a license from the original licensors, to run, modify and
450
+ propagate that work, subject to this License. You are not responsible
451
+ for enforcing compliance by third parties with this License.
452
+
453
+ An "entity transaction" is a transaction transferring control of an
454
+ organization, or substantially all assets of one, or subdividing an
455
+ organization, or merging organizations. If propagation of a covered
456
+ work results from an entity transaction, each party to that
457
+ transaction who receives a copy of the work also receives whatever
458
+ licenses to the work the party's predecessor in interest had or could
459
+ give under the previous paragraph, plus a right to possession of the
460
+ Corresponding Source of the work from the predecessor in interest, if
461
+ the predecessor has it or can get it with reasonable efforts.
462
+
463
+ You may not impose any further restrictions on the exercise of the
464
+ rights granted or affirmed under this License. For example, you may
465
+ not impose a license fee, royalty, or other charge for exercise of
466
+ rights granted under this License, and you may not initiate litigation
467
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
468
+ any patent claim is infringed by making, using, selling, offering for
469
+ sale, or importing the Program or any portion of it.
470
+
471
+ 11. Patents.
472
+
473
+ A "contributor" is a copyright holder who authorizes use under this
474
+ License of the Program or a work on which the Program is based. The
475
+ work thus licensed is called the contributor's "contributor version".
476
+
477
+ A contributor's "essential patent claims" are all patent claims
478
+ owned or controlled by the contributor, whether already acquired or
479
+ hereafter acquired, that would be infringed by some manner, permitted
480
+ by this License, of making, using, or selling its contributor version,
481
+ but do not include claims that would be infringed only as a
482
+ consequence of further modification of the contributor version. For
483
+ purposes of this definition, "control" includes the right to grant
484
+ patent sublicenses in a manner consistent with the requirements of
485
+ this License.
486
+
487
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
488
+ patent license under the contributor's essential patent claims, to
489
+ make, use, sell, offer for sale, import and otherwise run, modify and
490
+ propagate the contents of its contributor version.
491
+
492
+ In the following three paragraphs, a "patent license" is any express
493
+ agreement or commitment, however denominated, not to enforce a patent
494
+ (such as an express permission to practice a patent or covenant not to
495
+ sue for patent infringement). To "grant" such a patent license to a
496
+ party means to make such an agreement or commitment not to enforce a
497
+ patent against the party.
498
+
499
+ If you convey a covered work, knowingly relying on a patent license,
500
+ and the Corresponding Source of the work is not available for anyone
501
+ to copy, free of charge and under the terms of this License, through a
502
+ publicly available network server or other readily accessible means,
503
+ then you must either (1) cause the Corresponding Source to be so
504
+ available, or (2) arrange to deprive yourself of the benefit of the
505
+ patent license for this particular work, or (3) arrange, in a manner
506
+ consistent with the requirements of this License, to extend the patent
507
+ license to downstream recipients. "Knowingly relying" means you have
508
+ actual knowledge that, but for the patent license, your conveying the
509
+ covered work in a country, or your recipient's use of the covered work
510
+ in a country, would infringe one or more identifiable patents in that
511
+ country that you have reason to believe are valid.
512
+
513
+ If, pursuant to or in connection with a single transaction or
514
+ arrangement, you convey, or propagate by procuring conveyance of, a
515
+ covered work, and grant a patent license to some of the parties
516
+ receiving the covered work authorizing them to use, propagate, modify
517
+ or convey a specific copy of the covered work, then the patent license
518
+ you grant is automatically extended to all recipients of the covered
519
+ work and works based on it.
520
+
521
+ A patent license is "discriminatory" if it does not include within
522
+ the scope of its coverage, prohibits the exercise of, or is
523
+ conditioned on the non-exercise of one or more of the rights that are
524
+ specifically granted under this License. You may not convey a covered
525
+ work if you are a party to an arrangement with a third party that is
526
+ in the business of distributing software, under which you make payment
527
+ to the third party based on the extent of your activity of conveying
528
+ the work, and under which the third party grants, to any of the
529
+ parties who would receive the covered work from you, a discriminatory
530
+ patent license (a) in connection with copies of the covered work
531
+ conveyed by you (or copies made from those copies), or (b) primarily
532
+ for and in connection with specific products or compilations that
533
+ contain the covered work, unless you entered into that arrangement,
534
+ or that patent license was granted, prior to 28 March 2007.
535
+
536
+ Nothing in this License shall be construed as excluding or limiting
537
+ any implied license or other defenses to infringement that may
538
+ otherwise be available to you under applicable patent law.
539
+
540
+ 12. No Surrender of Others' Freedom.
541
+
542
+ If conditions are imposed on you (whether by court order, agreement or
543
+ otherwise) that contradict the conditions of this License, they do not
544
+ excuse you from the conditions of this License. If you cannot convey a
545
+ covered work so as to satisfy simultaneously your obligations under this
546
+ License and any other pertinent obligations, then as a consequence you may
547
+ not convey it at all. For example, if you agree to terms that obligate you
548
+ to collect a royalty for further conveying from those to whom you convey
549
+ the Program, the only way you could satisfy both those terms and this
550
+ License would be to refrain entirely from conveying the Program.
551
+
552
+ 13. Use with the GNU Affero General Public License.
553
+
554
+ Notwithstanding any other provision of this License, you have
555
+ permission to link or combine any covered work with a work licensed
556
+ under version 3 of the GNU Affero General Public License into a single
557
+ combined work, and to convey the resulting work. The terms of this
558
+ License will continue to apply to the part which is the covered work,
559
+ but the special requirements of the GNU Affero General Public License,
560
+ section 13, concerning interaction through a network will apply to the
561
+ combination as such.
562
+
563
+ 14. Revised Versions of this License.
564
+
565
+ The Free Software Foundation may publish revised and/or new versions of
566
+ the GNU General Public License from time to time. Such new versions will
567
+ be similar in spirit to the present version, but may differ in detail to
568
+ address new problems or concerns.
569
+
570
+ Each version is given a distinguishing version number. If the
571
+ Program specifies that a certain numbered version of the GNU General
572
+ Public License "or any later version" applies to it, you have the
573
+ option of following the terms and conditions either of that numbered
574
+ version or of any later version published by the Free Software
575
+ Foundation. If the Program does not specify a version number of the
576
+ GNU General Public License, you may choose any version ever published
577
+ by the Free Software Foundation.
578
+
579
+ If the Program specifies that a proxy can decide which future
580
+ versions of the GNU General Public License can be used, that proxy's
581
+ public statement of acceptance of a version permanently authorizes you
582
+ to choose that version for the Program.
583
+
584
+ Later license versions may give you additional or different
585
+ permissions. However, no additional obligations are imposed on any
586
+ author or copyright holder as a result of your choosing to follow a
587
+ later version.
588
+
589
+ 15. Disclaimer of Warranty.
590
+
591
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
+
600
+ 16. Limitation of Liability.
601
+
602
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610
+ SUCH DAMAGES.
611
+
612
+ 17. Interpretation of Sections 15 and 16.
613
+
614
+ If the disclaimer of warranty and limitation of liability provided
615
+ above cannot be given local legal effect according to their terms,
616
+ reviewing courts shall apply local law that most closely approximates
617
+ an absolute waiver of all civil liability in connection with the
618
+ Program, unless a warranty or assumption of liability accompanies a
619
+ copy of the Program in return for a fee.
620
+
621
+ END OF TERMS AND CONDITIONS
622
+
623
+ How to Apply These Terms to Your New Programs
624
+
625
+ If you develop a new program, and you want it to be of the greatest
626
+ possible use to the public, the best way to achieve this is to make it
627
+ free software which everyone can redistribute and change under these terms.
628
+
629
+ To do so, attach the following notices to the program. It is safest
630
+ to attach them to the start of each source file to most effectively
631
+ state the exclusion of warranty; and each file should have at least
632
+ the "copyright" line and a pointer to where the full notice is found.
633
+
634
+ <one line to give the program's name and a brief idea of what it does.>
635
+ Copyright (C) <year> <name of author>
636
+
637
+ This program is free software: you can redistribute it and/or modify
638
+ it under the terms of the GNU General Public License as published by
639
+ the Free Software Foundation, either version 3 of the License, or
640
+ (at your option) any later version.
641
+
642
+ This program is distributed in the hope that it will be useful,
643
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
644
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645
+ GNU General Public License for more details.
646
+
647
+ You should have received a copy of the GNU General Public License
648
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
649
+
650
+ Also add information on how to contact you by electronic and paper mail.
651
+
652
+ If the program does terminal interaction, make it output a short
653
+ notice like this when it starts in an interactive mode:
654
+
655
+ <program> Copyright (C) <year> <name of author>
656
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657
+ This is free software, and you are welcome to redistribute it
658
+ under certain conditions; type `show c' for details.
659
+
660
+ The hypothetical commands `show w' and `show c' should show the appropriate
661
+ parts of the General Public License. Of course, your program's commands
662
+ might be different; for a GUI interface, you would use an "about box".
663
+
664
+ You should also get your employer (if you work as a programmer) or school,
665
+ if any, to sign a "copyright disclaimer" for the program, if necessary.
666
+ For more information on this, and how to apply and follow the GNU GPL, see
667
+ <https://www.gnu.org/licenses/>.
668
+
669
+ The GNU General Public License does not permit incorporating your program
670
+ into proprietary programs. If your program is a subroutine library, you
671
+ may consider it more useful to permit linking proprietary applications with
672
+ the library. If this is what you want to do, use the GNU Lesser General
673
+ Public License instead of this License. But first, please read
674
+ <https://www.gnu.org/licenses/why-not-lgpl.html>.
custom_nodes/ComfyUI-Advanced-ControlNet/README.md ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ComfyUI-Advanced-ControlNet
2
+ Nodes for scheduling ControlNet strength across timesteps and batched latents, as well as applying custom weights and attention masks. The ControlNet nodes here fully support sliding context sampling, like the one used in the [ComfyUI-AnimateDiff-Evolved](https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved) nodes. Currently supports ControlNets, T2IAdapters, and ControlLoRAs. Kohya Controllllite support coming soon.
3
+
4
+ Custom weights allow replication of the "My prompt is more important" feature of Auto1111's sd-webui ControlNet extension.
5
+
6
+ ControlNet preprocessors are available through [comfyui_controlnet_aux](https://github.com/Fannovel16/comfyui_controlnet_aux) nodes
7
+
8
+ ## Features
9
+ - Timestep and latent strength scheduling
10
+ - Attention masks
11
+ - Soft weights to replicate "My prompt is more important" feature from sd-webui ControlNet extension, and also change the scaling.
12
+ - ControlNet, T2IAdapter, and ControlLoRA support for sliding context windows.
13
+
14
+ ## Table of Contents:
15
+ - [Scheduling Explanation](#scheduling-explanation)
16
+ - [Nodes](#nodes)
17
+ - [Usage](#usage) (will fill this out soon)
18
+
19
+
20
+ # Scheduling Explanation
21
+
22
+ The two core concepts for scheduling are ***Timestep Keyframes*** and ***Latent Keyframes***.
23
+
24
+ ***Timestep Keyframes*** hold the values that guide the settings for a controlnet, and begin to take effect based on their start_percent, which corresponds to the percentage of the sampling process. They can contain masks for the strengths of each latent, control_net_weights, and latent_keyframes (specific strengths for each latent), all optional.
25
+
26
+ ***Latent Keyframes*** determine the strength of the controlnet for specific latents - all they contain is the batch_index of the latent, and the strength the controlnet should apply for that latent. As a concept, latent keyframes achieve the same affect as a uniform mask with the chosen strength value.
27
+
28
+ ![advcn_image](https://github.com/Kosinkadink/ComfyUI-Advanced-ControlNet/assets/7365912/e6275264-6c3f-4246-a319-111ee48f4cd9)
29
+
30
+ # Nodes
31
+
32
+ The ControlNet nodes provided here are the ***Apply Advanced ControlNet*** and ***Load Advanced ControlNet Model*** (or diff) nodes. The vanilla ControlNet nodes are also compatible, and can be used almost interchangeably - the only difference is that **at least one of these nodes must be used** for Advanced versions of ControlNets to be used (important for sliding context sampling, like with AnimateDiff-Evolved).
33
+
34
+ Key:
35
+ - 🟩 - required inputs
36
+ - 🟨 - optional inputs
37
+ - 🟦 - start as widgets, can be converted to inputs
38
+ - πŸŸ₯ - optional input/output, but not recommended to use unless needed
39
+ - πŸŸͺ - output
40
+
41
+ ## Apply Advanced ControlNet
42
+ ![image](https://github.com/Kosinkadink/ComfyUI-Advanced-ControlNet/assets/7365912/dc541d41-70df-4a71-b832-efa65af98f06)
43
+
44
+ Same functionality as the vanilla Apply Advanced ControlNet (Advanced) node, except with Advanced ControlNet features added to it. Automatically converts any ControlNet from ControlNet loaders into Advanced versions.
45
+
46
+ ### Inputs
47
+ - 🟩***positive***: conditioning (positive).
48
+ - 🟩***negative***: conditioning (negative).
49
+ - 🟩***control_net***: loaded controlnet; will be converted to Advanced version automatically by this node, if it's a supported type.
50
+ - 🟩***image***: images to guide controlnets - if the loaded controlnet requires it, they must preprocessed images. If one image provided, will be used for all latents. If more images provided, will use each image separately for each latent. If not enough images to meet latent count, will repeat the images from the beginning to match vanilla ControlNet functionality.
51
+ - 🟨***mask_optional***: attention masks to apply to controlnets; basically, decides what part of the image the controlnet to apply to (and the relative strength, if the mask is not binary). Same as image input, if you provide more than one mask, each can apply to a different latent.
52
+ - 🟨***timestep_kf***: timestep keyframes to guide controlnet effect throughout sampling steps.
53
+ - 🟨***latent_kf_override***: override for latent keyframes, useful if no other features from timestep keyframes is needed. *NOTE: this latent keyframe will be applied to ALL timesteps, regardless if there are other latent keyframes attached to connected timestep keyframes.*
54
+ - 🟨***weights_override***: override for weights, useful if no other features from timestep keyframes is needed. *NOTE: this weight will be applied to ALL timesteps, regardless if there are other weights attached to connected timestep keyframes.*
55
+ - 🟦***strength***: strength of controlnet; 1.0 is full strength, 0.0 is no effect at all.
56
+ - 🟦***start_percent***: sampling step percentage at which controlnet should start to be applied - no matter what start_percent is set on timestep keyframes, they won't take effect until this start_percent is reached.
57
+ - 🟦***stop_percent***: sampling step percentage at which controlnet should stop being applied - no matter what start_percent is set on timestep keyframes, they won't take effect once this end_percent is reached.
58
+
59
+ ### Outputs
60
+ - πŸŸͺ***positive***: conditioning (positive) with applied controlnets
61
+ - πŸŸͺ***negative***: conditioning (negative) with applied controlnets
62
+
63
+ ## Load Advanced ControlNet Model
64
+ ![image](https://github.com/Kosinkadink/ComfyUI-Advanced-ControlNet/assets/7365912/4a7f58a9-783d-4da4-bf82-bc9c167e4722)
65
+
66
+ Loads a ControlNet model and converts it into an Advanced version that supports all the features in this repo. When used with **Apply Advanced ControlNet** node, there is no reason to use the timestep_keyframe input on this node - use timestep_kf on the Apply node instead.
67
+
68
+ ### Inputs
69
+ - πŸŸ₯***timestep_keyframe***: optional and likely unnecessary input to have ControlNet use selected timestep_keyframes - should not be used unless you need to. Useful if this node is not attached to **Apply Advanced ControlNet** node, but still want to use Timestep Keyframe, or to use TK_SHORTCUT outputs from ControlWeights in the same scenario. Will be overriden by the timestep_kf input on **Apply Advanced ControlNet** node, if one is provided there.
70
+ - 🟨***model***: model to plug into the diff version of the node. Some controlnets are designed for receive the model; if you don't know what this does, you probably don't want tot use the diff version of the node.
71
+
72
+ ### Outputs
73
+ - πŸŸͺ***CONTROL_NET***: loaded Advanced ControlNet
74
+
75
+ ## Timestep Keyframe
76
+ ![image](https://github.com/Kosinkadink/ComfyUI-Advanced-ControlNet/assets/7365912/c6f2a86e-fc96-4f8b-b976-7c2062a6eba2)
77
+
78
+ Scheduling node across timesteps (sampling steps) based on the set start_percent. Chaining Timestep Keyframes allows ControlNet scheduling across sampling steps (percentage-wise), through a timestep keyframe schedule.
79
+
80
+ ### Inputs
81
+ - 🟨***prev_timestep_kf***: used to chain Timestep Keyframes together to create a schedule. The order does not matter - the Timestep Keyframes sort themselves automatically by their start_percent. *Any Timestep Keyframe contained in the prev_timestep_keyframe that contains the same start_percent as the Timestep Keyframe will be overwritten.*
82
+ - 🟨***cn_weights***: weights to apply to controlnet while this Timestep Keyframe is in effect. Must be compatible with the loaded controlnet, or will throw an error explaining what weight types are compatible. If inherit_missing is True, if no control_net_weight is passed in, will attempt to reuse the last-used weights in the timestep keyframe schedule. *If Apply Advanced ControlNet node has a weight_override, the weight_override will be used during sampling instead of control_net_weight.*
83
+ - 🟨***latent_keyframe***: latent keyframes to apply to controlnet while this Timestep Keyframe is in effect. If inherit_missing is True, if no latent_keyframe is passed in, will attempt to reuse the last-used weights in the timestep keyframe schedule. *If Apply Advanced ControlNet node has a latent_kf_override, the latent_lf_override will be used during sampling instead of latent_keyframe.*
84
+ - 🟨***mask_optional***: attention masks to apply to controlnets; basically, decides what part of the image the controlnet to apply to (and the relative strength, if the mask is not binary). Same as mask_optional on the Apply Advanced ControlNet node, can apply either one maks to all latents, or individual masks for each latent. If inherit_missing is True, if no mask_optional is passed in, will attempt to reuse the last-used mask_optional in the timestep keyframe schedule. It is NOT overriden by mask_optional on the Apply Advanced ControlNet node; will be used together.
85
+ - 🟦***start_percent***: sampling step percentage at which this Timestep Keyframe qualifies to be used. Acts as the 'key' for the Timestep Keyframe in the timestep keyframe schedule.
86
+ - 🟦***strength***: strength of the controlnet; multiplies the controlnet by this value, basically, applied alongside the strength on the Apply ControlNet node. If set to 0.0 will not have any effect during the duration of this Timestep Keyframe's effect, and will increase sampling speed by not doing any work.
87
+ - 🟦***null_latent_kf_strength***: strength to assign to latents that are unaccounted for in the passed in latent_keyframes. Has no effect if no latent_keyframes are passed in, or no batch_indeces are unaccounted in the latent_keyframes for during sampling.
88
+ - 🟦***inherit_missing***: determines if should reuse values from previous Timestep Keyframes for optional values (control_net_weights, latent_keyframe, and mask_option) that are not included on this TimestepKeyframe. To inherit only specific inputs, use default inputs.
89
+ - 🟦***guarantee_usage***: when true, even if a Timestep Keyframe's start_percent ahead of this one in the schedule is closer to current sampling percentage, this Timestep Keyframe will still be used for one step before moving on to the next selected Timestep Keyframe in the following step. Whether the Timestep Keyframe is used or not, its inputs will still be accounted for inherit_missing purposes.
90
+
91
+ ### Outputs
92
+ - πŸŸͺ***TIMESTEP_KF***: the created Timestep Keyframe, that can either be linked to another or into a Timestep Keyframe input.
93
+
94
+ ## Latent Keyframe
95
+ ![image](https://github.com/Kosinkadink/ComfyUI-Advanced-ControlNet/assets/7365912/7eb2cc4c-255c-4f32-b09b-699f713fada3)
96
+
97
+ A singular Latent Keyframe, selects the strength for a specific batch_index. If batch_index is not present during sampling, will simply have no effect. Can be chained with any other Latent Keyframe-type node to create a latent keyframe schedule.
98
+
99
+ ### Inputs
100
+ - 🟨***prev_latent_kf***: used to chain Latent Keyframes together to create a schedule. *If a Latent Keyframe contained in prev_latent_keyframes have the same batch_index as this Latent Keyframe, they will take priority over this node's value.*
101
+ - 🟦***batch_index***: index of latent in batch to apply controlnet strength to. Acts as the 'key' for the Latent Keyframe in the latent keyframe schedule.
102
+ - 🟦***strength***: strength of controlnet to apply to the corresponding latent.
103
+
104
+ ### Outputs
105
+ - πŸŸͺ***LATENT_KF***: the created Latent Keyframe, that can either be linked to another or into a Latent Keyframe input.
106
+
107
+ ## Latent Keyframe Group
108
+ ![image](https://github.com/Kosinkadink/ComfyUI-Advanced-ControlNet/assets/7365912/5ce3b795-f5fc-4dc3-ae30-a4c7f87e278c)
109
+
110
+ Allows to create Latent Keyframes via individual indeces or python-style ranges.
111
+
112
+ ### Inputs
113
+ - 🟨***prev_latent_kf***: used to chain Latent Keyframes together to create a schedule. *If any Latent Keyframes contained in prev_latent_keyframes have the same batch_index as a this Latent Keyframe, they will take priority over this node's version.*
114
+ - 🟨***latent_optional***: the latents expected to be passed in for sampling; only required if you wish to use negative indeces (will be automatically converted to real values).
115
+ - 🟦***index_strengths***: string list of indeces or python-style ranges of indeces to assign strengths to. If latent_optional is passed in, can contain negative indeces or ranges that contain negative numbers, python-style. The different indeces must be comma separated. Individual latents can be specified by ```batch_index=strength```, like ```0=0.9```. Ranges can be specified by ```start_index_inclusive:end_index_exclusive=strength```, like ```0:8=strength```. Negative indeces are possible when latents_optional has an input, with a string such as ```0,-4=0.25```.
116
+ - 🟦***print_keyframes***: if True, will print the Latent Keyframes generated by this node for debugging purposes.
117
+
118
+ ### Outputs
119
+ - πŸŸͺ***LATENT_KF***: the created Latent Keyframe, that can either be linked to another or into a Latent Keyframe input.
120
+
121
+ ## Latent Keyframe Interpolation
122
+ ![image](https://github.com/Kosinkadink/ComfyUI-Advanced-ControlNet/assets/7365912/7986c737-83b9-46bc-aab0-ae4c368df446)
123
+
124
+ Allows to create Latent Keyframes with interpolated values in a range.
125
+
126
+ ### Inputs
127
+ - 🟨***prev_latent_kf***: used to chain Latent Keyframes together to create a schedule. *If any Latent Keyframes contained in prev_latent_keyframes have the same batch_index as a this Latent Keyframe, they will take priority over this node's version.*
128
+ - 🟦***batch_index_from***: starting batch_index of range, included.
129
+ - 🟦***batch_index_to***: end batch_index of range, excluded (python-style range).
130
+ - 🟦***strength_from***: starting strength of interpolation.
131
+ - 🟦***strength_to***: end strength of interpolation.
132
+ - 🟦***interpolation***: the method of interpolation.
133
+ - 🟦***print_keyframes***: if True, will print the Latent Keyframes generated by this node for debugging purposes.
134
+
135
+ ### Outputs
136
+ - πŸŸͺ***LATENT_KF***: the created Latent Keyframe, that can either be linked to another or into a Latent Keyframe input.
137
+
138
+ ## Latent Keyframe Batched Group
139
+ ![image](https://github.com/Kosinkadink/ComfyUI-Advanced-ControlNet/assets/7365912/6cec701f-6183-4aeb-af5c-cac76f5591b7)
140
+
141
+ Allows to create Latent Keyframes via a list of floats, such as with Batch Value Schedule from [ComfyUI_FizzNodes](https://github.com/FizzleDorf/ComfyUI_FizzNodes) nodes.
142
+
143
+ ### Inputs
144
+ - 🟨***prev_latent_kf***: used to chain Latent Keyframes together to create a schedule. *If any Latent Keyframes contained in prev_latent_keyframes have the same batch_index as a this Latent Keyframe, they will take priority over this node's version.*
145
+ - 🟦***float_strengths***: a list of floats, that will correspond to the strength of each Latent Keyframe; the batch_index is the index of each float value in the list.
146
+ - 🟦***print_keyframes***: if True, will print the Latent Keyframes generated by this node for debugging purposes.
147
+
148
+ ### Outputs
149
+ - πŸŸͺ***LATENT_KF***: the created Latent Keyframe, that can either be linked to another or into a Latent Keyframe input.
150
+
151
+ # There are more nodes to document and show usage - will add this soon! TODO
custom_nodes/ComfyUI-Advanced-ControlNet/__init__.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from .control.nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
2
+
3
+ __all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS']
custom_nodes/ComfyUI-Advanced-ControlNet/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (301 Bytes). View file
 
custom_nodes/ComfyUI-Advanced-ControlNet/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (344 Bytes). View file
 
custom_nodes/ComfyUI-Advanced-ControlNet/control/__pycache__/control.cpython-310.pyc ADDED
Binary file (11.3 kB). View file
 
custom_nodes/ComfyUI-Advanced-ControlNet/control/__pycache__/control.cpython-311.pyc ADDED
Binary file (47.4 kB). View file
 
custom_nodes/ComfyUI-Advanced-ControlNet/control/__pycache__/deprecated_nodes.cpython-310.pyc ADDED
Binary file (2.28 kB). View file
 
custom_nodes/ComfyUI-Advanced-ControlNet/control/__pycache__/deprecated_nodes.cpython-311.pyc ADDED
Binary file (5.67 kB). View file
 
custom_nodes/ComfyUI-Advanced-ControlNet/control/__pycache__/latent_keyframe_nodes.cpython-310.pyc ADDED
Binary file (7.3 kB). View file
 
custom_nodes/ComfyUI-Advanced-ControlNet/control/__pycache__/latent_keyframe_nodes.cpython-311.pyc ADDED
Binary file (14.3 kB). View file
 
custom_nodes/ComfyUI-Advanced-ControlNet/control/__pycache__/logger.cpython-310.pyc ADDED
Binary file (1.14 kB). View file
 
custom_nodes/ComfyUI-Advanced-ControlNet/control/__pycache__/logger.cpython-311.pyc ADDED
Binary file (1.9 kB). View file
 
custom_nodes/ComfyUI-Advanced-ControlNet/control/__pycache__/nodes.cpython-310.pyc ADDED
Binary file (5.85 kB). View file
 
custom_nodes/ComfyUI-Advanced-ControlNet/control/__pycache__/nodes.cpython-311.pyc ADDED
Binary file (10.4 kB). View file
 
custom_nodes/ComfyUI-Advanced-ControlNet/control/__pycache__/weight_nodes.cpython-310.pyc ADDED
Binary file (4.67 kB). View file
 
custom_nodes/ComfyUI-Advanced-ControlNet/control/__pycache__/weight_nodes.cpython-311.pyc ADDED
Binary file (9.45 kB). View file
 
custom_nodes/ComfyUI-Advanced-ControlNet/control/control.py ADDED
@@ -0,0 +1,770 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Union
2
+ from torch import Tensor
3
+ import torch
4
+
5
+ import comfy.utils
6
+ import comfy.controlnet as comfy_cn
7
+ from comfy.controlnet import ControlBase, ControlNet, ControlLora, T2IAdapter, broadcast_image_to
8
+
9
+
10
+ def get_properly_arranged_t2i_weights(initial_weights: list[float]):
11
+ new_weights = []
12
+ new_weights.extend([initial_weights[0]]*3)
13
+ new_weights.extend([initial_weights[1]]*3)
14
+ new_weights.extend([initial_weights[2]]*3)
15
+ new_weights.extend([initial_weights[3]]*3)
16
+ return new_weights
17
+
18
+
19
+ class ControlWeightType:
20
+ DEFAULT = "default"
21
+ UNIVERSAL = "universal"
22
+ T2IADAPTER = "t2iadapter"
23
+ CONTROLNET = "controlnet"
24
+ CONTROLLORA = "controllora"
25
+ CONTROLLLLITE = "controllllite"
26
+
27
+
28
+ class ControlWeights:
29
+ def __init__(self, weight_type: str, base_multiplier: float=1.0, flip_weights: bool=False, weights: list[float]=None, weight_mask: Tensor=None):
30
+ self.weight_type = weight_type
31
+ self.base_multiplier = base_multiplier
32
+ self.flip_weights = flip_weights
33
+ self.weights = weights
34
+ if self.weights is not None and self.flip_weights:
35
+ self.weights.reverse()
36
+ self.weight_mask = weight_mask
37
+
38
+ def get(self, idx: int) -> Union[float, Tensor]:
39
+ # if weights is not none, return index
40
+ if self.weights is not None:
41
+ return self.weights[idx]
42
+ return 1.0
43
+
44
+ @classmethod
45
+ def default(cls):
46
+ return cls(ControlWeightType.DEFAULT)
47
+
48
+ @classmethod
49
+ def universal(cls, base_multiplier: float, flip_weights: bool=False):
50
+ return cls(ControlWeightType.UNIVERSAL, base_multiplier=base_multiplier, flip_weights=flip_weights)
51
+
52
+ @classmethod
53
+ def universal_mask(cls, weight_mask: Tensor):
54
+ return cls(ControlWeightType.UNIVERSAL, weight_mask=weight_mask)
55
+
56
+ @classmethod
57
+ def t2iadapter(cls, weights: list[float]=None, flip_weights: bool=False):
58
+ if weights is None:
59
+ weights = [1.0]*12
60
+ return cls(ControlWeightType.T2IADAPTER, weights=weights,flip_weights=flip_weights)
61
+
62
+ @classmethod
63
+ def controlnet(cls, weights: list[float]=None, flip_weights: bool=False):
64
+ if weights is None:
65
+ weights = [1.0]*13
66
+ return cls(ControlWeightType.CONTROLNET, weights=weights, flip_weights=flip_weights)
67
+
68
+ @classmethod
69
+ def controllora(cls, weights: list[float]=None, flip_weights: bool=False):
70
+ if weights is None:
71
+ weights = [1.0]*10
72
+ return cls(ControlWeightType.CONTROLLORA, weights=weights, flip_weights=flip_weights)
73
+
74
+ @classmethod
75
+ def controllllite(cls, weights: list[float]=None, flip_weights: bool=False):
76
+ if weights is None:
77
+ # TODO: make this have a real value
78
+ weights = [1.0]*200
79
+ return cls(ControlWeightType.CONTROLLLLITE, weights=weights, flip_weights=flip_weights)
80
+
81
+
82
+ class StrengthInterpolation:
83
+ LINEAR = "linear"
84
+ EASE_IN = "ease-in"
85
+ EASE_OUT = "ease-out"
86
+ EASE_IN_OUT = "ease-in-out"
87
+ NONE = "none"
88
+
89
+
90
+ class LatentKeyframe:
91
+ def __init__(self, batch_index: int, strength: float) -> None:
92
+ self.batch_index = batch_index
93
+ self.strength = strength
94
+
95
+
96
+ # always maintain sorted state (by batch_index of LatentKeyframe)
97
+ class LatentKeyframeGroup:
98
+ def __init__(self) -> None:
99
+ self.keyframes: list[LatentKeyframe] = []
100
+
101
+ def add(self, keyframe: LatentKeyframe) -> None:
102
+ added = False
103
+ # replace existing keyframe if same batch_index
104
+ for i in range(len(self.keyframes)):
105
+ if self.keyframes[i].batch_index == keyframe.batch_index:
106
+ self.keyframes[i] = keyframe
107
+ added = True
108
+ break
109
+ if not added:
110
+ self.keyframes.append(keyframe)
111
+ self.keyframes.sort(key=lambda k: k.batch_index)
112
+
113
+ def get_index(self, index: int) -> Union[LatentKeyframe, None]:
114
+ try:
115
+ return self.keyframes[index]
116
+ except IndexError:
117
+ return None
118
+
119
+ def __getitem__(self, index) -> LatentKeyframe:
120
+ return self.keyframes[index]
121
+
122
+ def is_empty(self) -> bool:
123
+ return len(self.keyframes) == 0
124
+
125
+ def clone(self) -> 'LatentKeyframeGroup':
126
+ cloned = LatentKeyframeGroup()
127
+ for tk in self.keyframes:
128
+ cloned.add(tk)
129
+ return cloned
130
+
131
+
132
+ class TimestepKeyframe:
133
+ def __init__(self,
134
+ start_percent: float = 0.0,
135
+ strength: float = 1.0,
136
+ interpolation: str = StrengthInterpolation.NONE,
137
+ control_weights: ControlWeights = None,
138
+ latent_keyframes: LatentKeyframeGroup = None,
139
+ null_latent_kf_strength: float = 0.0,
140
+ inherit_missing: bool = True,
141
+ guarantee_usage: bool = True,
142
+ mask_hint_orig: Tensor = None) -> None:
143
+ self.start_percent = start_percent
144
+ self.start_t = 999999999.9
145
+ self.strength = strength
146
+ self.interpolation = interpolation
147
+ self.control_weights = control_weights
148
+ self.latent_keyframes = latent_keyframes
149
+ self.null_latent_kf_strength = null_latent_kf_strength
150
+ self.inherit_missing = inherit_missing
151
+ self.guarantee_usage = guarantee_usage
152
+ self.mask_hint_orig = mask_hint_orig
153
+
154
+ def has_control_weights(self):
155
+ return self.control_weights is not None
156
+
157
+ def has_latent_keyframes(self):
158
+ return self.latent_keyframes is not None
159
+
160
+ def has_mask_hint(self):
161
+ return self.mask_hint_orig is not None
162
+
163
+
164
+ @classmethod
165
+ def default(cls) -> 'TimestepKeyframe':
166
+ return cls(0.0)
167
+
168
+
169
+ # always maintain sorted state (by start_percent of TimestepKeyFrame)
170
+ class TimestepKeyframeGroup:
171
+ def __init__(self) -> None:
172
+ self.keyframes: list[TimestepKeyframe] = []
173
+ self.keyframes.append(TimestepKeyframe.default())
174
+
175
+ def add(self, keyframe: TimestepKeyframe) -> None:
176
+ added = False
177
+ # replace existing keyframe if same start_percent
178
+ for i in range(len(self.keyframes)):
179
+ if self.keyframes[i].start_percent == keyframe.start_percent:
180
+ self.keyframes[i] = keyframe
181
+ added = True
182
+ break
183
+ if not added:
184
+ self.keyframes.append(keyframe)
185
+ self.keyframes.sort(key=lambda k: k.start_percent)
186
+
187
+ def get_index(self, index: int) -> Union[TimestepKeyframe, None]:
188
+ try:
189
+ return self.keyframes[index]
190
+ except IndexError:
191
+ return None
192
+
193
+ def has_index(self, index: int) -> int:
194
+ return index >=0 and index < len(self.keyframes)
195
+
196
+ def __getitem__(self, index) -> TimestepKeyframe:
197
+ return self.keyframes[index]
198
+
199
+ def __len__(self) -> int:
200
+ return len(self.keyframes)
201
+
202
+ def is_empty(self) -> bool:
203
+ return len(self.keyframes) == 0
204
+
205
+ def clone(self) -> 'TimestepKeyframeGroup':
206
+ cloned = TimestepKeyframeGroup()
207
+ for tk in self.keyframes:
208
+ cloned.add(tk)
209
+ return cloned
210
+
211
+ @classmethod
212
+ def default(cls, keyframe: TimestepKeyframe) -> 'TimestepKeyframeGroup':
213
+ group = cls()
214
+ group.keyframes[0] = keyframe
215
+ return group
216
+
217
+
218
+ # used to inject ControlNetAdvanced and T2IAdapterAdvanced control_merge function
219
+
220
+
221
+ class AdvancedControlBase:
222
+ def __init__(self, base: ControlBase, timestep_keyframes: TimestepKeyframeGroup, weights_default: ControlWeights):
223
+ self.base = base
224
+ self.compatible_weights = [ControlWeightType.UNIVERSAL]
225
+ self.add_compatible_weight(weights_default.weight_type)
226
+ # mask for which parts of controlnet output to keep
227
+ self.mask_cond_hint_original = None
228
+ self.mask_cond_hint = None
229
+ self.tk_mask_cond_hint_original = None
230
+ self.tk_mask_cond_hint = None
231
+ self.weight_mask_cond_hint = None
232
+ # actual index values
233
+ self.sub_idxs = None
234
+ self.full_latent_length = 0
235
+ self.context_length = 0
236
+ # timesteps
237
+ self.t: Tensor = None
238
+ self.batched_number: int = None
239
+ # weights + override
240
+ self.weights: ControlWeights = None
241
+ self.weights_default: ControlWeights = weights_default
242
+ self.weights_override: ControlWeights = None
243
+ # latent keyframe + override
244
+ self.latent_keyframes: LatentKeyframeGroup = None
245
+ self.latent_keyframe_override: LatentKeyframeGroup = None
246
+ # initialize timestep_keyframes
247
+ self.set_timestep_keyframes(timestep_keyframes)
248
+ # override some functions
249
+ self.get_control = self.get_control_inject
250
+ self.control_merge = self.control_merge_inject#.__get__(self, type(self))
251
+ self.pre_run = self.pre_run_inject
252
+ self.cleanup = self.cleanup_inject
253
+
254
+ def add_compatible_weight(self, control_weight_type: str):
255
+ self.compatible_weights.append(control_weight_type)
256
+
257
+ def verify_all_weights(self, throw_error=True):
258
+ # first, check if override exists - if so, only need to check the override
259
+ if self.weights_override is not None:
260
+ if self.weights_override.weight_type not in self.compatible_weights:
261
+ msg = f"Weight override is type {self.weights_override.weight_type}, but loaded {type(self).__name__}" + \
262
+ f"only supports {self.compatible_weights} weights."
263
+ raise WeightTypeException(msg)
264
+ # otherwise, check all timestep keyframe weights
265
+ else:
266
+ for tk in self.timestep_keyframes.keyframes:
267
+ if tk.has_control_weights() and tk.control_weights.weight_type not in self.compatible_weights:
268
+ msg = f"Weight on Timestep Keyframe with start_percent={tk.start_percent} is type" + \
269
+ f"{tk.control_weights.weight_type}, but loaded {type(self).__name__} only supports {self.compatible_weights} weights."
270
+ raise WeightTypeException(msg)
271
+
272
+ def set_timestep_keyframes(self, timestep_keyframes: TimestepKeyframeGroup):
273
+ self.timestep_keyframes = timestep_keyframes if timestep_keyframes else TimestepKeyframeGroup()
274
+ # prepare first timestep_keyframe related stuff
275
+ self.current_timestep_keyframe = None
276
+ self.current_timestep_index = -1
277
+ self.next_timestep_keyframe = None
278
+ self.weights = None
279
+ self.latent_keyframes = None
280
+
281
+ def prepare_current_timestep(self, t: Tensor, batched_number: int):
282
+ self.t = t
283
+ self.batched_number = batched_number
284
+ # get current step percent
285
+ curr_t: float = t[0]
286
+ prev_index = self.current_timestep_index
287
+ # if has next index, loop through and see if need to switch
288
+ if self.timestep_keyframes.has_index(self.current_timestep_index+1):
289
+ for i in range(self.current_timestep_index+1, len(self.timestep_keyframes)):
290
+ eval_tk = self.timestep_keyframes[i]
291
+ # check if start percent is less or equal to curr_t
292
+ if eval_tk.start_t >= curr_t:
293
+ self.current_timestep_index = i
294
+ self.current_timestep_keyframe = eval_tk
295
+ # keep track of control weights, latent keyframes, and masks,
296
+ # accounting for inherit_missing
297
+ if self.current_timestep_keyframe.has_control_weights():
298
+ self.weights = self.current_timestep_keyframe.control_weights
299
+ elif not self.current_timestep_keyframe.inherit_missing:
300
+ self.weights = self.weights_default
301
+ if self.current_timestep_keyframe.has_latent_keyframes():
302
+ self.latent_keyframes = self.current_timestep_keyframe.latent_keyframes
303
+ elif not self.current_timestep_keyframe.inherit_missing:
304
+ self.latent_keyframes = None
305
+ if self.current_timestep_keyframe.has_mask_hint():
306
+ self.tk_mask_cond_hint_original = self.current_timestep_keyframe.mask_hint_orig
307
+ elif not self.current_timestep_keyframe.inherit_missing:
308
+ del self.tk_mask_cond_hint_original
309
+ self.tk_mask_cond_hint_original = None
310
+ # if guarantee_usage, stop searching for other TKs
311
+ if self.current_timestep_keyframe.guarantee_usage:
312
+ break
313
+ # if eval_tk is outside of percent range, stop looking further
314
+ else:
315
+ break
316
+
317
+ # if index changed, apply overrides
318
+ if prev_index != self.current_timestep_index:
319
+ if self.weights_override is not None:
320
+ self.weights = self.weights_override
321
+ if self.latent_keyframe_override is not None:
322
+ self.latent_keyframes = self.latent_keyframe_override
323
+
324
+ # make sure weights and latent_keyframes are in a workable state
325
+ # Note: each AdvancedControlBase should create their own get_universal_weights class
326
+ self.prepare_weights()
327
+
328
+ def prepare_weights(self):
329
+ if self.weights is None or self.weights.weight_type == ControlWeightType.DEFAULT:
330
+ self.weights = self.weights_default
331
+ elif self.weights.weight_type == ControlWeightType.UNIVERSAL:
332
+ # if universal and weight_mask present, no need to convert
333
+ if self.weights.weight_mask is not None:
334
+ return
335
+ self.weights = self.get_universal_weights()
336
+
337
+ def get_universal_weights(self) -> ControlWeights:
338
+ return self.weights
339
+
340
+ def set_cond_hint_mask(self, mask_hint):
341
+ self.mask_cond_hint_original = mask_hint
342
+ return self
343
+
344
+ def pre_run_inject(self, model, percent_to_timestep_function):
345
+ self.base.pre_run(model, percent_to_timestep_function)
346
+ self.pre_run_advanced(model, percent_to_timestep_function)
347
+
348
+ def pre_run_advanced(self, model, percent_to_timestep_function):
349
+ # for each timestep keyframe, calculate the start_t
350
+ for tk in self.timestep_keyframes.keyframes:
351
+ tk.start_t = percent_to_timestep_function(tk.start_percent)
352
+ # clear variables
353
+ self.cleanup_advanced()
354
+
355
+ def get_control_inject(self, x_noisy, t, cond, batched_number):
356
+ # prepare timestep and everything related
357
+ self.prepare_current_timestep(t=t, batched_number=batched_number)
358
+ # if should not perform any actions for the controlnet, exit without doing any work
359
+ if self.strength == 0.0 or self.current_timestep_keyframe.strength == 0.0:
360
+ control_prev = None
361
+ if self.previous_controlnet is not None:
362
+ control_prev = self.previous_controlnet.get_control(x_noisy, t, cond, batched_number)
363
+ if control_prev is not None:
364
+ return control_prev
365
+ else:
366
+ return None
367
+ # otherwise, perform normal function
368
+ return self.get_control_advanced(x_noisy, t, cond, batched_number)
369
+
370
+ def get_control_advanced(self, x_noisy, t, cond, batched_number):
371
+ pass
372
+
373
+ def calc_weight(self, idx: int, x: Tensor, layers: int) -> Union[float, Tensor]:
374
+ if self.weights.weight_mask is not None:
375
+ # prepare weight mask
376
+ self.prepare_weight_mask_cond_hint(x, self.batched_number)
377
+ # adjust mask for current layer and return
378
+ return torch.pow(self.weight_mask_cond_hint, self.get_calc_pow(idx=idx, layers=layers))
379
+ return self.weights.get(idx=idx)
380
+
381
+ def get_calc_pow(self, idx: int, layers: int) -> int:
382
+ return (layers-1)-idx
383
+
384
+ def apply_advanced_strengths_and_masks(self, x: Tensor, batched_number: int):
385
+ # apply strengths, and get batch indeces to null out
386
+ # AKA latents that should not be influenced by ControlNet
387
+ if self.latent_keyframes is not None:
388
+ latent_count = x.size(0)//batched_number
389
+ indeces_to_null = set(range(latent_count))
390
+ mapped_indeces = None
391
+ # if expecting subdivision, will need to translate between subset and actual idx values
392
+ if self.sub_idxs:
393
+ mapped_indeces = {}
394
+ for i, actual in enumerate(self.sub_idxs):
395
+ mapped_indeces[actual] = i
396
+ for keyframe in self.latent_keyframes:
397
+ real_index = keyframe.batch_index
398
+ # if negative, count from end
399
+ if real_index < 0:
400
+ real_index += latent_count if self.sub_idxs is None else self.full_latent_length
401
+
402
+ # if not mapping indeces, what you see is what you get
403
+ if mapped_indeces is None:
404
+ if real_index in indeces_to_null:
405
+ indeces_to_null.remove(real_index)
406
+ # otherwise, see if batch_index is even included in this set of latents
407
+ else:
408
+ real_index = mapped_indeces.get(real_index, None)
409
+ if real_index is None:
410
+ continue
411
+ indeces_to_null.remove(real_index)
412
+
413
+ # if real_index is outside the bounds of latents, don't apply
414
+ if real_index >= latent_count or real_index < 0:
415
+ continue
416
+
417
+ # apply strength for each batched cond/uncond
418
+ for b in range(batched_number):
419
+ x[(latent_count*b)+real_index] = x[(latent_count*b)+real_index] * keyframe.strength
420
+
421
+ # null them out by multiplying by null_latent_kf_strength
422
+ for batch_index in indeces_to_null:
423
+ # apply null for each batched cond/uncond
424
+ for b in range(batched_number):
425
+ x[(latent_count*b)+batch_index] = x[(latent_count*b)+batch_index] * self.current_timestep_keyframe.null_latent_kf_strength
426
+ # apply masks, resizing mask to required dims
427
+ if self.mask_cond_hint is not None:
428
+ masks = prepare_mask_batch(self.mask_cond_hint, x.shape)
429
+ x[:] = x[:] * masks
430
+ if self.tk_mask_cond_hint is not None:
431
+ masks = prepare_mask_batch(self.tk_mask_cond_hint, x.shape)
432
+ x[:] = x[:] * masks
433
+ # apply timestep keyframe strengths
434
+ if self.current_timestep_keyframe.strength != 1.0:
435
+ x[:] *= self.current_timestep_keyframe.strength
436
+
437
+ def control_merge_inject(self: 'AdvancedControlBase', control_input, control_output, control_prev, output_dtype):
438
+ out = {'input':[], 'middle':[], 'output': []}
439
+
440
+ if control_input is not None:
441
+ for i in range(len(control_input)):
442
+ key = 'input'
443
+ x = control_input[i]
444
+ if x is not None:
445
+ self.apply_advanced_strengths_and_masks(x, self.batched_number)
446
+
447
+ x *= self.strength * self.calc_weight(i, x, len(control_input))
448
+ if x.dtype != output_dtype:
449
+ x = x.to(output_dtype)
450
+ out[key].insert(0, x)
451
+
452
+ if control_output is not None:
453
+ for i in range(len(control_output)):
454
+ if i == (len(control_output) - 1):
455
+ key = 'middle'
456
+ index = 0
457
+ else:
458
+ key = 'output'
459
+ index = i
460
+ x = control_output[i]
461
+ if x is not None:
462
+ self.apply_advanced_strengths_and_masks(x, self.batched_number)
463
+
464
+ if self.global_average_pooling:
465
+ x = torch.mean(x, dim=(2, 3), keepdim=True).repeat(1, 1, x.shape[2], x.shape[3])
466
+
467
+ x *= self.strength * self.calc_weight(i, x, len(control_output))
468
+ if x.dtype != output_dtype:
469
+ x = x.to(output_dtype)
470
+
471
+ out[key].append(x)
472
+ if control_prev is not None:
473
+ for x in ['input', 'middle', 'output']:
474
+ o = out[x]
475
+ for i in range(len(control_prev[x])):
476
+ prev_val = control_prev[x][i]
477
+ if i >= len(o):
478
+ o.append(prev_val)
479
+ elif prev_val is not None:
480
+ if o[i] is None:
481
+ o[i] = prev_val
482
+ else:
483
+ o[i] += prev_val
484
+ return out
485
+
486
+ def prepare_mask_cond_hint(self, x_noisy: Tensor, t, cond, batched_number, dtype=None):
487
+ self._prepare_mask("mask_cond_hint", self.mask_cond_hint_original, x_noisy, t, cond, batched_number, dtype)
488
+ self.prepare_tk_mask_cond_hint(x_noisy, t, cond, batched_number, dtype)
489
+
490
+ def prepare_tk_mask_cond_hint(self, x_noisy: Tensor, t, cond, batched_number, dtype=None):
491
+ return self._prepare_mask("tk_mask_cond_hint", self.current_timestep_keyframe.mask_hint_orig, x_noisy, t, cond, batched_number, dtype)
492
+
493
+ def prepare_weight_mask_cond_hint(self, x_noisy: Tensor, batched_number, dtype=None):
494
+ return self._prepare_mask("weight_mask_cond_hint", self.weights.weight_mask, x_noisy, t=None, cond=None, batched_number=batched_number, dtype=dtype, direct_attn=True)
495
+
496
+ def _prepare_mask(self, attr_name, orig_mask: Tensor, x_noisy: Tensor, t, cond, batched_number, dtype=None, direct_attn=False):
497
+ # make mask appropriate dimensions, if present
498
+ if orig_mask is not None:
499
+ out_mask = getattr(self, attr_name)
500
+ if self.sub_idxs is not None or out_mask is None or x_noisy.shape[2] * 8 != out_mask.shape[1] or x_noisy.shape[3] * 8 != out_mask.shape[2]:
501
+ self._reset_attr(attr_name)
502
+ del out_mask
503
+ # TODO: perform upscale on only the sub_idxs masks at a time instead of all to conserve RAM
504
+ # resize mask and match batch count
505
+ multiplier = 1 if direct_attn else 8
506
+ out_mask = prepare_mask_batch(orig_mask, x_noisy.shape, multiplier=multiplier)
507
+ actual_latent_length = x_noisy.shape[0] // batched_number
508
+ out_mask = comfy.utils.repeat_to_batch_size(out_mask, actual_latent_length if self.sub_idxs is None else self.full_latent_length)
509
+ if self.sub_idxs is not None:
510
+ out_mask = out_mask[self.sub_idxs]
511
+ # make cond_hint_mask length match x_noise
512
+ if x_noisy.shape[0] != out_mask.shape[0]:
513
+ out_mask = broadcast_image_to(out_mask, x_noisy.shape[0], batched_number)
514
+ # default dtype to be same as x_noisy
515
+ if dtype is None:
516
+ dtype = x_noisy.dtype
517
+ setattr(self, attr_name, out_mask.to(dtype=dtype).to(self.device))
518
+ del out_mask
519
+
520
+ def _reset_attr(self, attr_name, new_value=None):
521
+ if hasattr(self, attr_name):
522
+ delattr(self, attr_name)
523
+ setattr(self, attr_name, new_value)
524
+
525
+ def cleanup_inject(self):
526
+ self.base.cleanup()
527
+ self.cleanup_advanced()
528
+
529
+ def cleanup_advanced(self):
530
+ self.sub_idxs = None
531
+ self.full_latent_length = 0
532
+ self.context_length = 0
533
+ self.t = None
534
+ self.batched_number = None
535
+ self.weights = None
536
+ self.latent_keyframes = None
537
+ # timestep stuff
538
+ self.current_timestep_keyframe = None
539
+ self.next_timestep_keyframe = None
540
+ self.current_timestep_index = -1
541
+ # clear mask hints
542
+ if self.mask_cond_hint is not None:
543
+ del self.mask_cond_hint
544
+ self.mask_cond_hint = None
545
+ if self.tk_mask_cond_hint_original is not None:
546
+ del self.tk_mask_cond_hint_original
547
+ self.tk_mask_cond_hint_original = None
548
+ if self.tk_mask_cond_hint is not None:
549
+ del self.tk_mask_cond_hint
550
+ self.tk_mask_cond_hint = None
551
+ if self.weight_mask_cond_hint is not None:
552
+ del self.weight_mask_cond_hint
553
+ self.weight_mask_cond_hint = None
554
+
555
+ def copy_to_advanced(self, copied: 'AdvancedControlBase'):
556
+ copied.mask_cond_hint_original = self.mask_cond_hint_original
557
+ copied.weights_override = self.weights_override
558
+ copied.latent_keyframe_override = self.latent_keyframe_override
559
+
560
+
561
+ class ControlNetAdvanced(ControlNet, AdvancedControlBase):
562
+ def __init__(self, control_model, timestep_keyframes: TimestepKeyframeGroup, global_average_pooling=False, device=None):
563
+ super().__init__(control_model=control_model, global_average_pooling=global_average_pooling, device=device)
564
+ AdvancedControlBase.__init__(self, super(), timestep_keyframes=timestep_keyframes, weights_default=ControlWeights.controlnet())
565
+
566
+ def get_universal_weights(self) -> ControlWeights:
567
+ raw_weights = [(self.weights.base_multiplier ** float(12 - i)) for i in range(13)]
568
+ return ControlWeights.controlnet(raw_weights, self.weights.flip_weights)
569
+
570
+ def get_control_advanced(self, x_noisy, t, cond, batched_number):
571
+ # perform special version of get_control that supports sliding context and masks
572
+ return self.sliding_get_control(x_noisy, t, cond, batched_number)
573
+
574
+ def sliding_get_control(self, x_noisy: Tensor, t, cond, batched_number):
575
+ control_prev = None
576
+ if self.previous_controlnet is not None:
577
+ control_prev = self.previous_controlnet.get_control(x_noisy, t, cond, batched_number)
578
+
579
+ if self.timestep_range is not None:
580
+ if t[0] > self.timestep_range[0] or t[0] < self.timestep_range[1]:
581
+ if control_prev is not None:
582
+ return control_prev
583
+ else:
584
+ return None
585
+
586
+ output_dtype = x_noisy.dtype
587
+
588
+ # make cond_hint appropriate dimensions
589
+ # TODO: change this to not require cond_hint upscaling every step when self.sub_idxs are present
590
+ if self.sub_idxs is not None or self.cond_hint is None or x_noisy.shape[2] * 8 != self.cond_hint.shape[2] or x_noisy.shape[3] * 8 != self.cond_hint.shape[3]:
591
+ if self.cond_hint is not None:
592
+ del self.cond_hint
593
+ self.cond_hint = None
594
+ # if self.cond_hint_original length greater or equal to real latent count, subdivide it before scaling
595
+ if self.sub_idxs is not None and self.cond_hint_original.size(0) >= self.full_latent_length:
596
+ self.cond_hint = comfy.utils.common_upscale(self.cond_hint_original[self.sub_idxs], x_noisy.shape[3] * 8, x_noisy.shape[2] * 8, 'nearest-exact', "center").to(self.control_model.dtype).to(self.device)
597
+ else:
598
+ self.cond_hint = comfy.utils.common_upscale(self.cond_hint_original, x_noisy.shape[3] * 8, x_noisy.shape[2] * 8, 'nearest-exact', "center").to(self.control_model.dtype).to(self.device)
599
+ if x_noisy.shape[0] != self.cond_hint.shape[0]:
600
+ self.cond_hint = broadcast_image_to(self.cond_hint, x_noisy.shape[0], batched_number)
601
+
602
+ # prepare mask_cond_hint
603
+ self.prepare_mask_cond_hint(x_noisy=x_noisy, t=t, cond=cond, batched_number=batched_number, dtype=self.control_model.dtype)
604
+
605
+ context = cond['c_crossattn']
606
+ # uses 'y' in new ComfyUI update
607
+ y = cond.get('y', None)
608
+ if y is None: # TODO: remove this in the future since no longer used by newest ComfyUI
609
+ y = cond.get('c_adm', None)
610
+ if y is not None:
611
+ y = y.to(self.control_model.dtype)
612
+ timestep = self.model_sampling_current.timestep(t)
613
+ x_noisy = self.model_sampling_current.calculate_input(t, x_noisy)
614
+
615
+ control = self.control_model(x=x_noisy.to(self.control_model.dtype), hint=self.cond_hint, timesteps=timestep.float(), context=context.to(self.control_model.dtype), y=y)
616
+ return self.control_merge(None, control, control_prev, output_dtype)
617
+
618
+ def copy(self):
619
+ c = ControlNetAdvanced(self.control_model, self.timestep_keyframes, global_average_pooling=self.global_average_pooling)
620
+ self.copy_to(c)
621
+ self.copy_to_advanced(c)
622
+ return c
623
+
624
+ @staticmethod
625
+ def from_vanilla(v: ControlNet, timestep_keyframe: TimestepKeyframeGroup=None) -> 'ControlNetAdvanced':
626
+ return ControlNetAdvanced(control_model=v.control_model, timestep_keyframes=timestep_keyframe,
627
+ global_average_pooling=v.global_average_pooling, device=v.device)
628
+
629
+
630
+ class T2IAdapterAdvanced(T2IAdapter, AdvancedControlBase):
631
+ def __init__(self, t2i_model, timestep_keyframes: TimestepKeyframeGroup, channels_in, device=None):
632
+ super().__init__(t2i_model=t2i_model, channels_in=channels_in, device=device)
633
+ AdvancedControlBase.__init__(self, super(), timestep_keyframes=timestep_keyframes, weights_default=ControlWeights.t2iadapter())
634
+
635
+ def get_universal_weights(self) -> ControlWeights:
636
+ raw_weights = [(self.weights.base_multiplier ** float(7 - i)) for i in range(8)]
637
+ raw_weights = [raw_weights[-8], raw_weights[-3], raw_weights[-2], raw_weights[-1]]
638
+ raw_weights = get_properly_arranged_t2i_weights(raw_weights)
639
+ return ControlWeights.t2iadapter(raw_weights, self.weights.flip_weights)
640
+
641
+ def get_calc_pow(self, idx: int, layers: int) -> int:
642
+ # match how T2IAdapterAdvanced deals with universal weights
643
+ indeces = [7 - i for i in range(8)]
644
+ indeces = [indeces[-8], indeces[-3], indeces[-2], indeces[-1]]
645
+ indeces = get_properly_arranged_t2i_weights(indeces)
646
+ return indeces[idx]
647
+
648
+ def get_control_advanced(self, x_noisy, t, cond, batched_number):
649
+ # prepare timestep and everything related
650
+ self.prepare_current_timestep(t=t, batched_number=batched_number)
651
+ try:
652
+ # if sub indexes present, replace original hint with subsection
653
+ if self.sub_idxs is not None:
654
+ # cond hints
655
+ full_cond_hint_original = self.cond_hint_original
656
+ del self.cond_hint
657
+ self.cond_hint = None
658
+ self.cond_hint_original = full_cond_hint_original[self.sub_idxs]
659
+ # mask hints
660
+ self.prepare_mask_cond_hint(x_noisy=x_noisy, t=t, cond=cond, batched_number=batched_number)
661
+ return super().get_control(x_noisy, t, cond, batched_number)
662
+ finally:
663
+ if self.sub_idxs is not None:
664
+ # replace original cond hint
665
+ self.cond_hint_original = full_cond_hint_original
666
+ del full_cond_hint_original
667
+
668
+ def copy(self):
669
+ c = T2IAdapterAdvanced(self.t2i_model, self.timestep_keyframes, self.channels_in)
670
+ self.copy_to(c)
671
+ self.copy_to_advanced(c)
672
+ return c
673
+
674
+ def cleanup(self):
675
+ super().cleanup()
676
+ self.cleanup_advanced()
677
+
678
+ @staticmethod
679
+ def from_vanilla(v: T2IAdapter, timestep_keyframe: TimestepKeyframeGroup=None) -> 'T2IAdapterAdvanced':
680
+ return T2IAdapterAdvanced(t2i_model=v.t2i_model, timestep_keyframes=timestep_keyframe, channels_in=v.channels_in, device=v.device)
681
+
682
+
683
+ class ControlLoraAdvanced(ControlLora, AdvancedControlBase):
684
+ def __init__(self, control_weights, timestep_keyframes: TimestepKeyframeGroup, global_average_pooling=False, device=None):
685
+ super().__init__(control_weights=control_weights, global_average_pooling=global_average_pooling, device=device)
686
+ AdvancedControlBase.__init__(self, super(), timestep_keyframes=timestep_keyframes, weights_default=ControlWeights.controllora())
687
+ # use some functions from ControlNetAdvanced
688
+ self.get_control_advanced = ControlNetAdvanced.get_control_advanced.__get__(self, type(self))
689
+ self.sliding_get_control = ControlNetAdvanced.sliding_get_control.__get__(self, type(self))
690
+
691
+ def get_universal_weights(self) -> ControlWeights:
692
+ raw_weights = [(self.weights.base_multiplier ** float(9 - i)) for i in range(10)]
693
+ return ControlWeights.controllora(raw_weights, self.weights.flip_weights)
694
+
695
+ def copy(self):
696
+ c = ControlLoraAdvanced(self.control_weights, self.timestep_keyframes, global_average_pooling=self.global_average_pooling)
697
+ self.copy_to(c)
698
+ self.copy_to_advanced(c)
699
+ return c
700
+
701
+ def cleanup(self):
702
+ super().cleanup()
703
+ self.cleanup_advanced()
704
+
705
+ @staticmethod
706
+ def from_vanilla(v: ControlLora, timestep_keyframe: TimestepKeyframeGroup=None) -> 'ControlLoraAdvanced':
707
+ return ControlLoraAdvanced(control_weights=v.control_weights, timestep_keyframes=timestep_keyframe,
708
+ global_average_pooling=v.global_average_pooling, device=v.device)
709
+
710
+
711
+ class ControlLLLiteAdvanced(ControlNet, AdvancedControlBase):
712
+ def __init__(self, control_weights, timestep_keyframes: TimestepKeyframeGroup, device=None):
713
+ AdvancedControlBase.__init__(self, super(), timestep_keyframes=timestep_keyframes, weights_default=ControlWeights.controllllite())
714
+
715
+
716
+ def load_controlnet(ckpt_path, timestep_keyframe: TimestepKeyframeGroup=None, model=None):
717
+ control = comfy_cn.load_controlnet(ckpt_path, model=model)
718
+ # TODO: support controlnet-lllite
719
+ # if is None, see if is a non-vanilla ControlNet
720
+ # if control is None:
721
+ # controlnet_data = comfy.utils.load_torch_file(ckpt_path, safe_load=True)
722
+ # # check if lllite
723
+ # if "lllite_unet" in controlnet_data:
724
+ # pass
725
+ return convert_to_advanced(control, timestep_keyframe=timestep_keyframe)
726
+
727
+
728
+ def convert_to_advanced(control, timestep_keyframe: TimestepKeyframeGroup=None):
729
+ # if already advanced, leave it be
730
+ if is_advanced_controlnet(control):
731
+ return control
732
+ # if exactly ControlNet returned, transform it into ControlNetAdvanced
733
+ if type(control) == ControlNet:
734
+ return ControlNetAdvanced.from_vanilla(v=control, timestep_keyframe=timestep_keyframe)
735
+ # if exactly ControlLora returned, transform it into ControlLoraAdvanced
736
+ elif type(control) == ControlLora:
737
+ return ControlLoraAdvanced.from_vanilla(v=control, timestep_keyframe=timestep_keyframe)
738
+ # if T2IAdapter returned, transform it into T2IAdapterAdvanced
739
+ elif isinstance(control, T2IAdapter):
740
+ return T2IAdapterAdvanced.from_vanilla(v=control, timestep_keyframe=timestep_keyframe)
741
+ # otherwise, leave it be - might be something I am not supporting yet
742
+ return control
743
+
744
+
745
+ def is_advanced_controlnet(input_object):
746
+ return hasattr(input_object, "sub_idxs")
747
+
748
+
749
+ # adapted from comfy/sample.py
750
+ def prepare_mask_batch(mask: Tensor, shape: Tensor, multiplier: int=1, match_dim1=False):
751
+ mask = mask.clone()
752
+ mask = torch.nn.functional.interpolate(mask.reshape((-1, 1, mask.shape[-2], mask.shape[-1])), size=(shape[2]*multiplier, shape[3]*multiplier), mode="bilinear")
753
+ if match_dim1:
754
+ mask = torch.cat([mask] * shape[1], dim=1)
755
+ return mask
756
+
757
+
758
+ # applies min-max normalization, from:
759
+ # https://stackoverflow.com/questions/68791508/min-max-normalization-of-a-tensor-in-pytorch
760
+ def normalize_min_max(x: Tensor, new_min = 0.0, new_max = 1.0):
761
+ x_min, x_max = x.min(), x.max()
762
+ return (((x - x_min)/(x_max - x_min)) * (new_max - new_min)) + new_min
763
+
764
+ def linear_conversion(x, x_min=0.0, x_max=1.0, new_min=0.0, new_max=1.0):
765
+ return (((x - x_min)/(x_max - x_min)) * (new_max - new_min)) + new_min
766
+
767
+
768
+ class WeightTypeException(TypeError):
769
+ "Raised when weight not compatible with AdvancedControlBase object"
770
+ pass
custom_nodes/ComfyUI-Advanced-ControlNet/control/control_lllite.py ADDED
@@ -0,0 +1 @@
 
 
1
+
custom_nodes/ComfyUI-Advanced-ControlNet/control/deprecated_nodes.py ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ import torch
4
+
5
+ import numpy as np
6
+ from PIL import Image, ImageOps
7
+ from .control import ControlWeights, LatentKeyframeGroup, TimestepKeyframeGroup, TimestepKeyframe
8
+ from .logger import logger
9
+
10
+
11
+ class LoadImagesFromDirectory:
12
+ @classmethod
13
+ def INPUT_TYPES(s):
14
+ return {
15
+ "required": {
16
+ "directory": ("STRING", {"default": ""}),
17
+ },
18
+ "optional": {
19
+ "image_load_cap": ("INT", {"default": 0, "min": 0, "step": 1}),
20
+ "start_index": ("INT", {"default": 0, "min": 0, "step": 1}),
21
+ }
22
+ }
23
+
24
+ RETURN_TYPES = ("IMAGE", "MASK", "INT")
25
+ FUNCTION = "load_images"
26
+
27
+ CATEGORY = "Adv-ControlNet πŸ›‚πŸ…πŸ…’πŸ…/deprecated"
28
+
29
+ def load_images(self, directory: str, image_load_cap: int = 0, start_index: int = 0):
30
+ if not os.path.isdir(directory):
31
+ raise FileNotFoundError(f"Directory '{directory} cannot be found.'")
32
+ dir_files = os.listdir(directory)
33
+ if len(dir_files) == 0:
34
+ raise FileNotFoundError(f"No files in directory '{directory}'.")
35
+
36
+ dir_files = sorted(dir_files)
37
+ dir_files = [os.path.join(directory, x) for x in dir_files]
38
+ # start at start_index
39
+ dir_files = dir_files[start_index:]
40
+
41
+ images = []
42
+ masks = []
43
+
44
+ limit_images = False
45
+ if image_load_cap > 0:
46
+ limit_images = True
47
+ image_count = 0
48
+
49
+ for image_path in dir_files:
50
+ if os.path.isdir(image_path):
51
+ continue
52
+ if limit_images and image_count >= image_load_cap:
53
+ break
54
+ i = Image.open(image_path)
55
+ i = ImageOps.exif_transpose(i)
56
+ image = i.convert("RGB")
57
+ image = np.array(image).astype(np.float32) / 255.0
58
+ image = torch.from_numpy(image)[None,]
59
+ if 'A' in i.getbands():
60
+ mask = np.array(i.getchannel('A')).astype(np.float32) / 255.0
61
+ mask = 1. - torch.from_numpy(mask)
62
+ else:
63
+ mask = torch.zeros((64,64), dtype=torch.float32, device="cpu")
64
+ images.append(image)
65
+ masks.append(mask)
66
+ image_count += 1
67
+
68
+ if len(images) == 0:
69
+ raise FileNotFoundError(f"No images could be loaded from directory '{directory}'.")
70
+
71
+ return (torch.cat(images, dim=0), torch.stack(masks, dim=0), image_count)
72
+
73
+
74
+ class TimestepKeyframeNodeDeprecated:
75
+ @classmethod
76
+ def INPUT_TYPES(s):
77
+ return {
78
+ "required": {
79
+ "start_percent": ("FLOAT", {"default": 0.0, "min": 0.0, "max": 1.0, "step": 0.001}, ),
80
+ },
81
+ "optional": {
82
+ "control_net_weights": ("CONTROL_NET_WEIGHTS", ),
83
+ "t2i_adapter_weights": ("T2I_ADAPTER_WEIGHTS", ),
84
+ "latent_keyframe": ("LATENT_KEYFRAME", ),
85
+ "prev_timestep_keyframe": ("TIMESTEP_KEYFRAME", ),
86
+ }
87
+ }
88
+
89
+ RETURN_TYPES = ("TIMESTEP_KEYFRAME", )
90
+ FUNCTION = "load_keyframe"
91
+
92
+ CATEGORY = "Adv-ControlNet πŸ›‚πŸ…πŸ…’πŸ…/keyframes"
93
+
94
+ def load_keyframe(self,
95
+ start_percent: float,
96
+ control_net_weights: ControlWeights=None,
97
+ latent_keyframe: LatentKeyframeGroup=None,
98
+ prev_timestep_keyframe: TimestepKeyframeGroup=None):
99
+ if not prev_timestep_keyframe:
100
+ prev_timestep_keyframe = TimestepKeyframeGroup()
101
+ keyframe = TimestepKeyframe(start_percent, control_net_weights, latent_keyframe)
102
+ prev_timestep_keyframe.add(keyframe)
103
+ return (prev_timestep_keyframe,)
custom_nodes/ComfyUI-Advanced-ControlNet/control/latent_keyframe_nodes.py ADDED
@@ -0,0 +1,283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Union
2
+ import numpy as np
3
+ from collections.abc import Iterable
4
+
5
+ from .control import LatentKeyframe, LatentKeyframeGroup
6
+ from .control import StrengthInterpolation as SI
7
+ from .logger import logger
8
+
9
+
10
+ class LatentKeyframeNode:
11
+ @classmethod
12
+ def INPUT_TYPES(s):
13
+ return {
14
+ "required": {
15
+ "batch_index": ("INT", {"default": 0, "min": -1000, "max": 1000, "step": 1}),
16
+ "strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ),
17
+ },
18
+ "optional": {
19
+ "prev_latent_kf": ("LATENT_KEYFRAME", ),
20
+ }
21
+ }
22
+
23
+ RETURN_NAMES = ("LATENT_KF", )
24
+ RETURN_TYPES = ("LATENT_KEYFRAME", )
25
+ FUNCTION = "load_keyframe"
26
+
27
+ CATEGORY = "Adv-ControlNet πŸ›‚πŸ…πŸ…’πŸ…/keyframes"
28
+
29
+ def load_keyframe(self,
30
+ batch_index: int,
31
+ strength: float,
32
+ prev_latent_kf: LatentKeyframeGroup=None,
33
+ prev_latent_keyframe: LatentKeyframeGroup=None, # old name
34
+ ):
35
+ prev_latent_keyframe = prev_latent_keyframe if prev_latent_keyframe else prev_latent_kf
36
+ if not prev_latent_keyframe:
37
+ prev_latent_keyframe = LatentKeyframeGroup()
38
+ else:
39
+ prev_latent_keyframe = prev_latent_keyframe.clone()
40
+ keyframe = LatentKeyframe(batch_index, strength)
41
+ prev_latent_keyframe.add(keyframe)
42
+ return (prev_latent_keyframe,)
43
+
44
+
45
+ class LatentKeyframeGroupNode:
46
+ @classmethod
47
+ def INPUT_TYPES(s):
48
+ return {
49
+ "required": {
50
+ "index_strengths": ("STRING", {"multiline": True, "default": ""}),
51
+ },
52
+ "optional": {
53
+ "prev_latent_kf": ("LATENT_KEYFRAME", ),
54
+ "latent_optional": ("LATENT", ),
55
+ "print_keyframes": ("BOOLEAN", {"default": False})
56
+ }
57
+ }
58
+
59
+ RETURN_NAMES = ("LATENT_KF", )
60
+ RETURN_TYPES = ("LATENT_KEYFRAME", )
61
+ FUNCTION = "load_keyframes"
62
+
63
+ CATEGORY = "Adv-ControlNet πŸ›‚πŸ…πŸ…’πŸ…/keyframes"
64
+
65
+ def validate_index(self, index: int, latent_count: int = 0, is_range: bool = False, allow_negative = False) -> int:
66
+ # if part of range, do nothing
67
+ if is_range:
68
+ return index
69
+ # otherwise, validate index
70
+ # validate not out of range - only when latent_count is passed in
71
+ if latent_count > 0 and index > latent_count-1:
72
+ raise IndexError(f"Index '{index}' out of range for the total {latent_count} latents.")
73
+ # if negative, validate not out of range
74
+ if index < 0:
75
+ if not allow_negative:
76
+ raise IndexError(f"Negative indeces not allowed, but was {index}.")
77
+ conv_index = latent_count+index
78
+ if conv_index < 0:
79
+ raise IndexError(f"Index '{index}', converted to '{conv_index}' out of range for the total {latent_count} latents.")
80
+ index = conv_index
81
+ return index
82
+
83
+ def convert_to_index_int(self, raw_index: str, latent_count: int = 0, is_range: bool = False, allow_negative = False) -> int:
84
+ try:
85
+ return self.validate_index(int(raw_index), latent_count=latent_count, is_range=is_range, allow_negative=allow_negative)
86
+ except ValueError as e:
87
+ raise ValueError(f"index '{raw_index}' must be an integer.", e)
88
+
89
+ def convert_to_latent_keyframes(self, latent_indeces: str, latent_count: int) -> set[LatentKeyframe]:
90
+ if not latent_indeces:
91
+ return set()
92
+ int_latent_indeces = [i for i in range(0, latent_count)]
93
+ allow_negative = latent_count > 0
94
+ chosen_indeces = set()
95
+ # parse string - allow positive ints, negative ints, and ranges separated by ':'
96
+ groups = latent_indeces.split(",")
97
+ groups = [g.strip() for g in groups]
98
+ for g in groups:
99
+ # parse strengths - default to 1.0 if no strength given
100
+ strength = 1.0
101
+ if '=' in g:
102
+ g, strength_str = g.split("=", 1)
103
+ g = g.strip()
104
+ try:
105
+ strength = float(strength_str.strip())
106
+ except ValueError as e:
107
+ raise ValueError(f"strength '{strength_str}' must be a float.", e)
108
+ if strength < 0:
109
+ raise ValueError(f"Strength '{strength}' cannot be negative.")
110
+ # parse range of indeces (e.g. 2:16)
111
+ if ':' in g:
112
+ index_range = g.split(":", 1)
113
+ index_range = [r.strip() for r in index_range]
114
+ start_index = self.convert_to_index_int(index_range[0], latent_count=latent_count, is_range=True, allow_negative=allow_negative)
115
+ end_index = self.convert_to_index_int(index_range[1], latent_count=latent_count, is_range=True, allow_negative=allow_negative)
116
+ # if latents were passed in, base indeces on known latent count
117
+ if len(int_latent_indeces) > 0:
118
+ for i in int_latent_indeces[start_index:end_index]:
119
+ chosen_indeces.add(LatentKeyframe(i, strength))
120
+ # otherwise, assume indeces are valid
121
+ else:
122
+ for i in range(start_index, end_index):
123
+ chosen_indeces.add(LatentKeyframe(i, strength))
124
+ # parse individual indeces
125
+ else:
126
+ chosen_indeces.add(LatentKeyframe(self.convert_to_index_int(g, latent_count=latent_count, allow_negative=allow_negative), strength))
127
+ return chosen_indeces
128
+
129
+ def load_keyframes(self,
130
+ index_strengths: str,
131
+ prev_latent_kf: LatentKeyframeGroup=None,
132
+ prev_latent_keyframe: LatentKeyframeGroup=None, # old name
133
+ latent_image_opt=None,
134
+ print_keyframes=False):
135
+ prev_latent_keyframe = prev_latent_keyframe if prev_latent_keyframe else prev_latent_kf
136
+ if not prev_latent_keyframe:
137
+ prev_latent_keyframe = LatentKeyframeGroup()
138
+ else:
139
+ prev_latent_keyframe = prev_latent_keyframe.clone()
140
+ curr_latent_keyframe = LatentKeyframeGroup()
141
+
142
+ latent_count = -1
143
+ if latent_image_opt:
144
+ latent_count = latent_image_opt['samples'].size()[0]
145
+ latent_keyframes = self.convert_to_latent_keyframes(index_strengths, latent_count=latent_count)
146
+
147
+ for latent_keyframe in latent_keyframes:
148
+ curr_latent_keyframe.add(latent_keyframe)
149
+
150
+ if print_keyframes:
151
+ for keyframe in curr_latent_keyframe.keyframes:
152
+ logger.info(f"keyframe {keyframe.batch_index}:{keyframe.strength}")
153
+
154
+ # replace values with prev_latent_keyframes
155
+ for latent_keyframe in prev_latent_keyframe.keyframes:
156
+ curr_latent_keyframe.add(latent_keyframe)
157
+
158
+ return (curr_latent_keyframe,)
159
+
160
+
161
+ class LatentKeyframeInterpolationNode:
162
+ @classmethod
163
+ def INPUT_TYPES(s):
164
+ return {
165
+ "required": {
166
+ "batch_index_from": ("INT", {"default": 0, "min": -10000, "max": 10000, "step": 1}),
167
+ "batch_index_to_excl": ("INT", {"default": 0, "min": -10000, "max": 10000, "step": 1}),
168
+ "strength_from": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ),
169
+ "strength_to": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ),
170
+ "interpolation": ([SI.LINEAR, SI.EASE_IN, SI.EASE_OUT, SI.EASE_IN_OUT], ),
171
+ },
172
+ "optional": {
173
+ "prev_latent_kf": ("LATENT_KEYFRAME", ),
174
+ "print_keyframes": ("BOOLEAN", {"default": False})
175
+ }
176
+ }
177
+
178
+ RETURN_NAMES = ("LATENT_KF", )
179
+ RETURN_TYPES = ("LATENT_KEYFRAME", )
180
+ FUNCTION = "load_keyframe"
181
+ CATEGORY = "Adv-ControlNet πŸ›‚πŸ…πŸ…’πŸ…/keyframes"
182
+
183
+ def load_keyframe(self,
184
+ batch_index_from: int,
185
+ strength_from: float,
186
+ batch_index_to_excl: int,
187
+ strength_to: float,
188
+ interpolation: str,
189
+ prev_latent_kf: LatentKeyframeGroup=None,
190
+ prev_latent_keyframe: LatentKeyframeGroup=None, # old name
191
+ print_keyframes=False):
192
+
193
+ if (batch_index_from > batch_index_to_excl):
194
+ raise ValueError("batch_index_from must be less than or equal to batch_index_to.")
195
+
196
+ if (batch_index_from < 0 and batch_index_to_excl >= 0):
197
+ raise ValueError("batch_index_from and batch_index_to must be either both positive or both negative.")
198
+
199
+ prev_latent_keyframe = prev_latent_keyframe if prev_latent_keyframe else prev_latent_kf
200
+ if not prev_latent_keyframe:
201
+ prev_latent_keyframe = LatentKeyframeGroup()
202
+ else:
203
+ prev_latent_keyframe = prev_latent_keyframe.clone()
204
+ curr_latent_keyframe = LatentKeyframeGroup()
205
+
206
+ steps = batch_index_to_excl - batch_index_from
207
+ diff = strength_to - strength_from
208
+ if interpolation == SI.LINEAR:
209
+ weights = np.linspace(strength_from, strength_to, steps)
210
+ elif interpolation == SI.EASE_IN:
211
+ index = np.linspace(0, 1, steps)
212
+ weights = diff * np.power(index, 2) + strength_from
213
+ elif interpolation == SI.EASE_OUT:
214
+ index = np.linspace(0, 1, steps)
215
+ weights = diff * (1 - np.power(1 - index, 2)) + strength_from
216
+ elif interpolation == SI.EASE_IN_OUT:
217
+ index = np.linspace(0, 1, steps)
218
+ weights = diff * ((1 - np.cos(index * np.pi)) / 2) + strength_from
219
+
220
+ for i in range(steps):
221
+ keyframe = LatentKeyframe(batch_index_from + i, float(weights[i]))
222
+ curr_latent_keyframe.add(keyframe)
223
+
224
+ if print_keyframes:
225
+ for keyframe in curr_latent_keyframe.keyframes:
226
+ logger.info(f"keyframe {keyframe.batch_index}:{keyframe.strength}")
227
+
228
+ # replace values with prev_latent_keyframes
229
+ for latent_keyframe in prev_latent_keyframe.keyframes:
230
+ curr_latent_keyframe.add(latent_keyframe)
231
+
232
+ return (curr_latent_keyframe,)
233
+
234
+
235
+ class LatentKeyframeBatchedGroupNode:
236
+ @classmethod
237
+ def INPUT_TYPES(s):
238
+ return {
239
+ "required": {
240
+ "float_strengths": ("FLOAT", {"default": -1, "min": -1, "step": 0.001, "forceInput": True}),
241
+ },
242
+ "optional": {
243
+ "prev_latent_kf": ("LATENT_KEYFRAME", ),
244
+ "print_keyframes": ("BOOLEAN", {"default": False})
245
+ }
246
+ }
247
+
248
+ RETURN_NAMES = ("LATENT_KF", )
249
+ RETURN_TYPES = ("LATENT_KEYFRAME", )
250
+ FUNCTION = "load_keyframe"
251
+ CATEGORY = "Adv-ControlNet πŸ›‚πŸ…πŸ…’πŸ…/keyframes"
252
+
253
+ def load_keyframe(self, float_strengths: Union[float, list[float]],
254
+ prev_latent_kf: LatentKeyframeGroup=None,
255
+ prev_latent_keyframe: LatentKeyframeGroup=None, # old name
256
+ print_keyframes=False):
257
+ prev_latent_keyframe = prev_latent_keyframe if prev_latent_keyframe else prev_latent_kf
258
+ if not prev_latent_keyframe:
259
+ prev_latent_keyframe = LatentKeyframeGroup()
260
+ else:
261
+ prev_latent_keyframe = prev_latent_keyframe.clone()
262
+ curr_latent_keyframe = LatentKeyframeGroup()
263
+
264
+ # if received a normal float input, do nothing
265
+ if type(float_strengths) in (float, int):
266
+ logger.info("No batched float_strengths passed into Latent Keyframe Batch Group node; will not create any new keyframes.")
267
+ # if iterable, attempt to create LatentKeyframes with chosen strengths
268
+ elif isinstance(float_strengths, Iterable):
269
+ for idx, strength in enumerate(float_strengths):
270
+ keyframe = LatentKeyframe(idx, strength)
271
+ curr_latent_keyframe.add(keyframe)
272
+ else:
273
+ raise ValueError(f"Expected strengths to be an iterable input, but was {type(float_strengths).__repr__}.")
274
+
275
+ if print_keyframes:
276
+ for keyframe in curr_latent_keyframe.keyframes:
277
+ logger.info(f"keyframe {keyframe.batch_index}:{keyframe.strength}")
278
+
279
+ # replace values with prev_latent_keyframes
280
+ for latent_keyframe in prev_latent_keyframe.keyframes:
281
+ curr_latent_keyframe.add(latent_keyframe)
282
+
283
+ return (curr_latent_keyframe,)
custom_nodes/ComfyUI-Advanced-ControlNet/control/logger.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ import copy
3
+ import logging
4
+
5
+
6
+ class ColoredFormatter(logging.Formatter):
7
+ COLORS = {
8
+ "DEBUG": "\033[0;36m", # CYAN
9
+ "INFO": "\033[0;32m", # GREEN
10
+ "WARNING": "\033[0;33m", # YELLOW
11
+ "ERROR": "\033[0;31m", # RED
12
+ "CRITICAL": "\033[0;37;41m", # WHITE ON RED
13
+ "RESET": "\033[0m", # RESET COLOR
14
+ }
15
+
16
+ def format(self, record):
17
+ colored_record = copy.copy(record)
18
+ levelname = colored_record.levelname
19
+ seq = self.COLORS.get(levelname, self.COLORS["RESET"])
20
+ colored_record.levelname = f"{seq}{levelname}{self.COLORS['RESET']}"
21
+ return super().format(colored_record)
22
+
23
+
24
+ # Create a new logger
25
+ logger = logging.getLogger("Advanced-ControlNet")
26
+ logger.propagate = False
27
+
28
+ # Add handler if we don't have one.
29
+ if not logger.handlers:
30
+ handler = logging.StreamHandler(sys.stdout)
31
+ handler.setFormatter(ColoredFormatter("[%(name)s] - %(levelname)s - %(message)s"))
32
+ logger.addHandler(handler)
33
+
34
+ # Configure logger
35
+ loglevel = logging.INFO
36
+ logger.setLevel(loglevel)
custom_nodes/ComfyUI-Advanced-ControlNet/control/nodes.py ADDED
@@ -0,0 +1,243 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ from torch import Tensor
3
+
4
+ import folder_paths
5
+
6
+ from .control import load_controlnet, convert_to_advanced, ControlWeights, ControlWeightType,\
7
+ LatentKeyframeGroup, TimestepKeyframe, TimestepKeyframeGroup, is_advanced_controlnet
8
+ from .control import StrengthInterpolation as SI
9
+ from .weight_nodes import DefaultWeights, ScaledSoftMaskedUniversalWeights, ScaledSoftUniversalWeights, SoftControlNetWeights, CustomControlNetWeights, \
10
+ SoftT2IAdapterWeights, CustomT2IAdapterWeights
11
+ from .latent_keyframe_nodes import LatentKeyframeGroupNode, LatentKeyframeInterpolationNode, LatentKeyframeBatchedGroupNode, LatentKeyframeNode
12
+ from .deprecated_nodes import LoadImagesFromDirectory
13
+ from .logger import logger
14
+
15
+
16
+ class TimestepKeyframeNode:
17
+ @classmethod
18
+ def INPUT_TYPES(s):
19
+ return {
20
+ "required": {
21
+ "start_percent": ("FLOAT", {"default": 0.0, "min": 0.0, "max": 1.0, "step": 0.001}, ),
22
+ },
23
+ "optional": {
24
+ "prev_timestep_kf": ("TIMESTEP_KEYFRAME", ),
25
+ "strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ),
26
+ "cn_weights": ("CONTROL_NET_WEIGHTS", ),
27
+ "latent_keyframe": ("LATENT_KEYFRAME", ),
28
+ "null_latent_kf_strength": ("FLOAT", {"default": 0.0, "min": 0.0, "max": 10.0, "step": 0.001}, ),
29
+ "inherit_missing": ("BOOLEAN", {"default": True}, ),
30
+ "guarantee_usage": ("BOOLEAN", {"default": True}, ),
31
+ "mask_optional": ("MASK", ),
32
+ #"interpolation": ([SI.LINEAR, SI.EASE_IN, SI.EASE_OUT, SI.EASE_IN_OUT, SI.NONE], {"default": SI.NONE}, ),
33
+ }
34
+ }
35
+
36
+ RETURN_NAMES = ("TIMESTEP_KF", )
37
+ RETURN_TYPES = ("TIMESTEP_KEYFRAME", )
38
+ FUNCTION = "load_keyframe"
39
+
40
+ CATEGORY = "Adv-ControlNet πŸ›‚πŸ…πŸ…’πŸ…/keyframes"
41
+
42
+ def load_keyframe(self,
43
+ start_percent: float,
44
+ strength: float=1.0,
45
+ cn_weights: ControlWeights=None, control_net_weights: ControlWeights=None, # old name
46
+ latent_keyframe: LatentKeyframeGroup=None,
47
+ prev_timestep_kf: TimestepKeyframeGroup=None, prev_timestep_keyframe: TimestepKeyframeGroup=None, # old name
48
+ null_latent_kf_strength: float=0.0,
49
+ inherit_missing=True,
50
+ guarantee_usage=True,
51
+ mask_optional=None,
52
+ interpolation: str=SI.NONE,):
53
+ control_net_weights = control_net_weights if control_net_weights else cn_weights
54
+ prev_timestep_keyframe = prev_timestep_keyframe if prev_timestep_keyframe else prev_timestep_kf
55
+ if not prev_timestep_keyframe:
56
+ prev_timestep_keyframe = TimestepKeyframeGroup()
57
+ else:
58
+ prev_timestep_keyframe = prev_timestep_keyframe.clone()
59
+ keyframe = TimestepKeyframe(start_percent=start_percent, strength=strength, interpolation=interpolation, null_latent_kf_strength=null_latent_kf_strength,
60
+ control_weights=control_net_weights, latent_keyframes=latent_keyframe, inherit_missing=inherit_missing, guarantee_usage=guarantee_usage,
61
+ mask_hint_orig=mask_optional)
62
+ prev_timestep_keyframe.add(keyframe)
63
+ return (prev_timestep_keyframe,)
64
+
65
+
66
+ class ControlNetLoaderAdvanced:
67
+ @classmethod
68
+ def INPUT_TYPES(s):
69
+ return {
70
+ "required": {
71
+ "control_net_name": (folder_paths.get_filename_list("controlnet"), ),
72
+ },
73
+ "optional": {
74
+ "timestep_keyframe": ("TIMESTEP_KEYFRAME", ),
75
+ }
76
+ }
77
+
78
+ RETURN_TYPES = ("CONTROL_NET", )
79
+ FUNCTION = "load_controlnet"
80
+
81
+ CATEGORY = "Adv-ControlNet πŸ›‚πŸ…πŸ…’πŸ…"
82
+
83
+ def load_controlnet(self, control_net_name,
84
+ timestep_keyframe: TimestepKeyframeGroup=None
85
+ ):
86
+ controlnet_path = folder_paths.get_full_path("controlnet", control_net_name)
87
+ controlnet = load_controlnet(controlnet_path, timestep_keyframe)
88
+ return (controlnet,)
89
+
90
+
91
+ class DiffControlNetLoaderAdvanced:
92
+ @classmethod
93
+ def INPUT_TYPES(s):
94
+ return {
95
+ "required": {
96
+ "model": ("MODEL",),
97
+ "control_net_name": (folder_paths.get_filename_list("controlnet"), )
98
+ },
99
+ "optional": {
100
+ "timestep_keyframe": ("TIMESTEP_KEYFRAME", ),
101
+ }
102
+ }
103
+
104
+ RETURN_TYPES = ("CONTROL_NET", )
105
+ FUNCTION = "load_controlnet"
106
+
107
+ CATEGORY = "Adv-ControlNet πŸ›‚πŸ…πŸ…’πŸ…"
108
+
109
+ def load_controlnet(self, control_net_name, model,
110
+ timestep_keyframe: TimestepKeyframeGroup=None
111
+ ):
112
+ controlnet_path = folder_paths.get_full_path("controlnet", control_net_name)
113
+ controlnet = load_controlnet(controlnet_path, timestep_keyframe, model)
114
+ if is_advanced_controlnet(controlnet):
115
+ controlnet.verify_all_weights()
116
+ return (controlnet,)
117
+
118
+
119
+ class AdvancedControlNetApply:
120
+ @classmethod
121
+ def INPUT_TYPES(s):
122
+ return {
123
+ "required": {
124
+ "positive": ("CONDITIONING", ),
125
+ "negative": ("CONDITIONING", ),
126
+ "control_net": ("CONTROL_NET", ),
127
+ "image": ("IMAGE", ),
128
+ "strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.01}),
129
+ "start_percent": ("FLOAT", {"default": 0.0, "min": 0.0, "max": 1.0, "step": 0.001}),
130
+ "end_percent": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.001})
131
+ },
132
+ "optional": {
133
+ "mask_optional": ("MASK", ),
134
+ "timestep_kf": ("TIMESTEP_KEYFRAME", ),
135
+ "latent_kf_override": ("LATENT_KEYFRAME", ),
136
+ "weights_override": ("CONTROL_NET_WEIGHTS", ),
137
+ }
138
+ }
139
+
140
+ RETURN_TYPES = ("CONDITIONING","CONDITIONING")
141
+ RETURN_NAMES = ("positive", "negative")
142
+ FUNCTION = "apply_controlnet"
143
+
144
+ CATEGORY = "Adv-ControlNet πŸ›‚πŸ…πŸ…’πŸ…"
145
+
146
+ def apply_controlnet(self, positive, negative, control_net, image, strength, start_percent, end_percent,
147
+ mask_optional: Tensor=None,
148
+ timestep_kf: TimestepKeyframeGroup=None, latent_kf_override: LatentKeyframeGroup=None,
149
+ weights_override: ControlWeights=None):
150
+ if strength == 0:
151
+ return (positive, negative)
152
+
153
+ control_hint = image.movedim(-1,1)
154
+ cnets = {}
155
+
156
+ out = []
157
+ for conditioning in [positive, negative]:
158
+ c = []
159
+ for t in conditioning:
160
+ d = t[1].copy()
161
+
162
+ prev_cnet = d.get('control', None)
163
+ if prev_cnet in cnets:
164
+ c_net = cnets[prev_cnet]
165
+ else:
166
+ # copy, convert to advanced if needed, and set cond
167
+ c_net = convert_to_advanced(control_net.copy()).set_cond_hint(control_hint, strength, (start_percent, end_percent))
168
+ if is_advanced_controlnet(c_net):
169
+ # apply optional parameters and overrides, if provided
170
+ if timestep_kf is not None:
171
+ c_net.set_timestep_keyframes(timestep_kf)
172
+ if latent_kf_override is not None:
173
+ c_net.latent_keyframe_override = latent_kf_override
174
+ if weights_override is not None:
175
+ c_net.weights_override = weights_override
176
+ # verify weights are compatible
177
+ c_net.verify_all_weights()
178
+ # set cond hint mask
179
+ if mask_optional is not None:
180
+ mask_optional = mask_optional.clone()
181
+ # if not in the form of a batch, make it so
182
+ if len(mask_optional.shape) < 3:
183
+ mask_optional = mask_optional.unsqueeze(0)
184
+ c_net.set_cond_hint_mask(mask_optional)
185
+ c_net.set_previous_controlnet(prev_cnet)
186
+ cnets[prev_cnet] = c_net
187
+
188
+ d['control'] = c_net
189
+ d['control_apply_to_uncond'] = False
190
+ n = [t[0], d]
191
+ c.append(n)
192
+ out.append(c)
193
+ return (out[0], out[1])
194
+
195
+
196
+ # NODE MAPPING
197
+ NODE_CLASS_MAPPINGS = {
198
+ # Keyframes
199
+ "TimestepKeyframe": TimestepKeyframeNode,
200
+ "LatentKeyframe": LatentKeyframeNode,
201
+ "LatentKeyframeGroup": LatentKeyframeGroupNode,
202
+ "LatentKeyframeBatchedGroup": LatentKeyframeBatchedGroupNode,
203
+ "LatentKeyframeTiming": LatentKeyframeInterpolationNode,
204
+ # Conditioning
205
+ "ACN_AdvancedControlNetApply": AdvancedControlNetApply,
206
+ # Loaders
207
+ "ControlNetLoaderAdvanced": ControlNetLoaderAdvanced,
208
+ "DiffControlNetLoaderAdvanced": DiffControlNetLoaderAdvanced,
209
+ # Weights
210
+ "ScaledSoftControlNetWeights": ScaledSoftUniversalWeights,
211
+ "ScaledSoftMaskedUniversalWeights": ScaledSoftMaskedUniversalWeights,
212
+ "SoftControlNetWeights": SoftControlNetWeights,
213
+ "CustomControlNetWeights": CustomControlNetWeights,
214
+ "SoftT2IAdapterWeights": SoftT2IAdapterWeights,
215
+ "CustomT2IAdapterWeights": CustomT2IAdapterWeights,
216
+ "ACN_DefaultUniversalWeights": DefaultWeights,
217
+ # Image
218
+ "LoadImagesFromDirectory": LoadImagesFromDirectory
219
+ }
220
+
221
+ NODE_DISPLAY_NAME_MAPPINGS = {
222
+ # Keyframes
223
+ "TimestepKeyframe": "Timestep Keyframe πŸ›‚πŸ…πŸ…’πŸ…",
224
+ "LatentKeyframe": "Latent Keyframe πŸ›‚πŸ…πŸ…’πŸ…",
225
+ "LatentKeyframeGroup": "Latent Keyframe Group πŸ›‚πŸ…πŸ…’πŸ…",
226
+ "LatentKeyframeBatchedGroup": "Latent Keyframe Batched Group πŸ›‚πŸ…πŸ…’πŸ…",
227
+ "LatentKeyframeTiming": "Latent Keyframe Interpolation πŸ›‚πŸ…πŸ…’πŸ…",
228
+ # Conditioning
229
+ "ACN_AdvancedControlNetApply": "Apply Advanced ControlNet πŸ›‚πŸ…πŸ…’πŸ…",
230
+ # Loaders
231
+ "ControlNetLoaderAdvanced": "Load Advanced ControlNet Model πŸ›‚πŸ…πŸ…’πŸ…",
232
+ "DiffControlNetLoaderAdvanced": "Load Advanced ControlNet Model (diff) πŸ›‚πŸ…πŸ…’πŸ…",
233
+ # Weights
234
+ "ScaledSoftControlNetWeights": "Scaled Soft Weights πŸ›‚πŸ…πŸ…’πŸ…",
235
+ "ScaledSoftMaskedUniversalWeights": "Scaled Soft Masked Weights πŸ›‚πŸ…πŸ…’πŸ…",
236
+ "SoftControlNetWeights": "ControlNet Soft Weights πŸ›‚πŸ…πŸ…’πŸ…",
237
+ "CustomControlNetWeights": "ControlNet Custom Weights πŸ›‚πŸ…πŸ…’πŸ…",
238
+ "SoftT2IAdapterWeights": "T2IAdapter Soft Weights πŸ›‚πŸ…πŸ…’πŸ…",
239
+ "CustomT2IAdapterWeights": "T2IAdapter Custom Weights πŸ›‚πŸ…πŸ…’πŸ…",
240
+ "ACN_DefaultUniversalWeights": "Force Default Weights πŸ›‚πŸ…πŸ…’πŸ…",
241
+ # Image
242
+ "LoadImagesFromDirectory": "Load Images [DEPRECATED] πŸ›‚πŸ…πŸ…’πŸ…"
243
+ }
custom_nodes/ComfyUI-Advanced-ControlNet/control/reference_nodes.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class AnimateDiffLoaderWithContext:
2
+ @classmethod
3
+ def INPUT_TYPES(s):
4
+ return {
5
+ "required": {
6
+ "model": ("MODEL",),
7
+ "image": ("IMAGE",),
8
+ },
9
+ }
10
+
11
+ RETURN_TYPES = ("MODEL",)
12
+ CATEGORY = ""
custom_nodes/ComfyUI-Advanced-ControlNet/control/weight_nodes.py ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from torch import Tensor
2
+ import torch
3
+ from .control import TimestepKeyframe, TimestepKeyframeGroup, ControlWeights, get_properly_arranged_t2i_weights, linear_conversion
4
+ from .logger import logger
5
+
6
+
7
+ WEIGHTS_RETURN_NAMES = ("CN_WEIGHTS", "TK_SHORTCUT")
8
+
9
+
10
+ class DefaultWeights:
11
+ @classmethod
12
+ def INPUT_TYPES(s):
13
+ return {
14
+ }
15
+
16
+ RETURN_TYPES = ("CONTROL_NET_WEIGHTS", "TIMESTEP_KEYFRAME",)
17
+ RETURN_NAMES = WEIGHTS_RETURN_NAMES
18
+ FUNCTION = "load_weights"
19
+
20
+ CATEGORY = "Adv-ControlNet πŸ›‚πŸ…πŸ…’πŸ…/weights"
21
+
22
+ def load_weights(self):
23
+ weights = ControlWeights.default()
24
+ return (weights, TimestepKeyframeGroup.default(TimestepKeyframe(control_weights=weights)))
25
+
26
+
27
+ class ScaledSoftMaskedUniversalWeights:
28
+ @classmethod
29
+ def INPUT_TYPES(s):
30
+ return {
31
+ "required": {
32
+ "mask": ("MASK", ),
33
+ "min_base_multiplier": ("FLOAT", {"default": 0.0, "min": 0.0, "max": 1.0, "step": 0.001}, ),
34
+ "max_base_multiplier": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.001}, ),
35
+ #"lock_min": ("BOOLEAN", {"default": False}, ),
36
+ #"lock_max": ("BOOLEAN", {"default": False}, ),
37
+ },
38
+ }
39
+
40
+ RETURN_TYPES = ("CONTROL_NET_WEIGHTS", "TIMESTEP_KEYFRAME",)
41
+ RETURN_NAMES = WEIGHTS_RETURN_NAMES
42
+ FUNCTION = "load_weights"
43
+
44
+ CATEGORY = "Adv-ControlNet πŸ›‚πŸ…πŸ…’πŸ…/weights"
45
+
46
+ def load_weights(self, mask: Tensor, min_base_multiplier: float, max_base_multiplier: float, lock_min=False, lock_max=False):
47
+ # normalize mask
48
+ mask = mask.clone()
49
+ x_min = 0.0 if lock_min else mask.min()
50
+ x_max = 1.0 if lock_max else mask.max()
51
+ if x_min == x_max:
52
+ mask = torch.ones_like(mask) * max_base_multiplier
53
+ else:
54
+ mask = linear_conversion(mask, x_min, x_max, min_base_multiplier, max_base_multiplier)
55
+ weights = ControlWeights.universal_mask(weight_mask=mask)
56
+ return (weights, TimestepKeyframeGroup.default(TimestepKeyframe(control_weights=weights)))
57
+
58
+
59
+ class ScaledSoftUniversalWeights:
60
+ @classmethod
61
+ def INPUT_TYPES(s):
62
+ return {
63
+ "required": {
64
+ "base_multiplier": ("FLOAT", {"default": 0.825, "min": 0.0, "max": 1.0, "step": 0.001}, ),
65
+ "flip_weights": ("BOOLEAN", {"default": False}),
66
+ },
67
+ }
68
+
69
+ RETURN_TYPES = ("CONTROL_NET_WEIGHTS", "TIMESTEP_KEYFRAME",)
70
+ RETURN_NAMES = WEIGHTS_RETURN_NAMES
71
+ FUNCTION = "load_weights"
72
+
73
+ CATEGORY = "Adv-ControlNet πŸ›‚πŸ…πŸ…’πŸ…/weights"
74
+
75
+ def load_weights(self, base_multiplier, flip_weights):
76
+ weights = ControlWeights.universal(base_multiplier=base_multiplier, flip_weights=flip_weights)
77
+ return (weights, TimestepKeyframeGroup.default(TimestepKeyframe(control_weights=weights)))
78
+
79
+
80
+ class SoftControlNetWeights:
81
+ @classmethod
82
+ def INPUT_TYPES(s):
83
+ return {
84
+ "required": {
85
+ "weight_00": ("FLOAT", {"default": 0.09941396206337118, "min": 0.0, "max": 10.0, "step": 0.001}, ),
86
+ "weight_01": ("FLOAT", {"default": 0.12050177219802567, "min": 0.0, "max": 10.0, "step": 0.001}, ),
87
+ "weight_02": ("FLOAT", {"default": 0.14606275417942507, "min": 0.0, "max": 10.0, "step": 0.001}, ),
88
+ "weight_03": ("FLOAT", {"default": 0.17704576264172736, "min": 0.0, "max": 10.0, "step": 0.001}, ),
89
+ "weight_04": ("FLOAT", {"default": 0.214600924414215, "min": 0.0, "max": 10.0, "step": 0.001}, ),
90
+ "weight_05": ("FLOAT", {"default": 0.26012233262329093, "min": 0.0, "max": 10.0, "step": 0.001}, ),
91
+ "weight_06": ("FLOAT", {"default": 0.3152997971191405, "min": 0.0, "max": 10.0, "step": 0.001}, ),
92
+ "weight_07": ("FLOAT", {"default": 0.3821815722656249, "min": 0.0, "max": 10.0, "step": 0.001}, ),
93
+ "weight_08": ("FLOAT", {"default": 0.4632503906249999, "min": 0.0, "max": 10.0, "step": 0.001}, ),
94
+ "weight_09": ("FLOAT", {"default": 0.561515625, "min": 0.0, "max": 10.0, "step": 0.001}, ),
95
+ "weight_10": ("FLOAT", {"default": 0.6806249999999999, "min": 0.0, "max": 10.0, "step": 0.001}, ),
96
+ "weight_11": ("FLOAT", {"default": 0.825, "min": 0.0, "max": 10.0, "step": 0.001}, ),
97
+ "weight_12": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ),
98
+ "flip_weights": ("BOOLEAN", {"default": False}),
99
+ },
100
+ }
101
+
102
+ RETURN_TYPES = ("CONTROL_NET_WEIGHTS", "TIMESTEP_KEYFRAME",)
103
+ RETURN_NAMES = WEIGHTS_RETURN_NAMES
104
+ FUNCTION = "load_weights"
105
+
106
+ CATEGORY = "Adv-ControlNet πŸ›‚πŸ…πŸ…’πŸ…/weights/ControlNet"
107
+
108
+ def load_weights(self, weight_00, weight_01, weight_02, weight_03, weight_04, weight_05, weight_06,
109
+ weight_07, weight_08, weight_09, weight_10, weight_11, weight_12, flip_weights):
110
+ weights = [weight_00, weight_01, weight_02, weight_03, weight_04, weight_05, weight_06,
111
+ weight_07, weight_08, weight_09, weight_10, weight_11, weight_12]
112
+ weights = ControlWeights.controlnet(weights, flip_weights=flip_weights)
113
+ return (weights, TimestepKeyframeGroup.default(TimestepKeyframe(control_weights=weights)))
114
+
115
+
116
+ class CustomControlNetWeights:
117
+ @classmethod
118
+ def INPUT_TYPES(s):
119
+ return {
120
+ "required": {
121
+ "weight_00": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ),
122
+ "weight_01": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ),
123
+ "weight_02": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ),
124
+ "weight_03": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ),
125
+ "weight_04": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ),
126
+ "weight_05": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ),
127
+ "weight_06": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ),
128
+ "weight_07": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ),
129
+ "weight_08": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ),
130
+ "weight_09": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ),
131
+ "weight_10": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ),
132
+ "weight_11": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ),
133
+ "weight_12": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ),
134
+ "flip_weights": ("BOOLEAN", {"default": False}),
135
+ }
136
+ }
137
+
138
+ RETURN_TYPES = ("CONTROL_NET_WEIGHTS", "TIMESTEP_KEYFRAME",)
139
+ RETURN_NAMES = WEIGHTS_RETURN_NAMES
140
+ FUNCTION = "load_weights"
141
+
142
+ CATEGORY = "Adv-ControlNet πŸ›‚πŸ…πŸ…’πŸ…/weights/ControlNet"
143
+
144
+ def load_weights(self, weight_00, weight_01, weight_02, weight_03, weight_04, weight_05, weight_06,
145
+ weight_07, weight_08, weight_09, weight_10, weight_11, weight_12, flip_weights):
146
+ weights = [weight_00, weight_01, weight_02, weight_03, weight_04, weight_05, weight_06,
147
+ weight_07, weight_08, weight_09, weight_10, weight_11, weight_12]
148
+ weights = ControlWeights.controlnet(weights, flip_weights=flip_weights)
149
+ return (weights, TimestepKeyframeGroup.default(TimestepKeyframe(control_weights=weights)))
150
+
151
+
152
+ class SoftT2IAdapterWeights:
153
+ @classmethod
154
+ def INPUT_TYPES(s):
155
+ return {
156
+ "required": {
157
+ "weight_00": ("FLOAT", {"default": 0.25, "min": 0.0, "max": 10.0, "step": 0.001}, ),
158
+ "weight_01": ("FLOAT", {"default": 0.62, "min": 0.0, "max": 10.0, "step": 0.001}, ),
159
+ "weight_02": ("FLOAT", {"default": 0.825, "min": 0.0, "max": 10.0, "step": 0.001}, ),
160
+ "weight_03": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ),
161
+ "flip_weights": ("BOOLEAN", {"default": False}),
162
+ },
163
+ }
164
+
165
+ RETURN_TYPES = ("CONTROL_NET_WEIGHTS", "TIMESTEP_KEYFRAME",)
166
+ RETURN_NAMES = WEIGHTS_RETURN_NAMES
167
+ FUNCTION = "load_weights"
168
+
169
+ CATEGORY = "Adv-ControlNet πŸ›‚πŸ…πŸ…’πŸ…/weights/T2IAdapter"
170
+
171
+ def load_weights(self, weight_00, weight_01, weight_02, weight_03, flip_weights):
172
+ weights = [weight_00, weight_01, weight_02, weight_03]
173
+ weights = get_properly_arranged_t2i_weights(weights)
174
+ weights = ControlWeights.t2iadapter(weights, flip_weights=flip_weights)
175
+ return (weights, TimestepKeyframeGroup.default(TimestepKeyframe(control_weights=weights)))
176
+
177
+
178
+ class CustomT2IAdapterWeights:
179
+ @classmethod
180
+ def INPUT_TYPES(s):
181
+ return {
182
+ "required": {
183
+ "weight_00": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ),
184
+ "weight_01": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ),
185
+ "weight_02": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ),
186
+ "weight_03": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ),
187
+ "flip_weights": ("BOOLEAN", {"default": False}),
188
+ },
189
+ }
190
+
191
+ RETURN_TYPES = ("CONTROL_NET_WEIGHTS", "TIMESTEP_KEYFRAME",)
192
+ RETURN_NAMES = WEIGHTS_RETURN_NAMES
193
+ FUNCTION = "load_weights"
194
+
195
+ CATEGORY = "Adv-ControlNet πŸ›‚πŸ…πŸ…’πŸ…/weights/T2IAdapter"
196
+
197
+ def load_weights(self, weight_00, weight_01, weight_02, weight_03, flip_weights):
198
+ weights = [weight_00, weight_01, weight_02, weight_03]
199
+ weights = get_properly_arranged_t2i_weights(weights)
200
+ weights = ControlWeights.t2iadapter(weights, flip_weights=flip_weights)
201
+ return (weights, TimestepKeyframeGroup.default(TimestepKeyframe(control_weights=weights)))
custom_nodes/ComfyUI-Advanced-ControlNet/requirements.txt ADDED
File without changes
custom_nodes/ComfyUI-Custom-Scripts/.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ __pycache__
custom_nodes/ComfyUI-Custom-Scripts/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2023 pythongosssss
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
custom_nodes/ComfyUI-Custom-Scripts/README.md ADDED
@@ -0,0 +1,394 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ComfyUI-Custom-Scripts
2
+
3
+ # Installation
4
+
5
+ 1. Clone the repository:
6
+ `git clone https://github.com/pythongosssss/ComfyUI-Custom-Scripts.git`
7
+ to your ComfyUI `custom_nodes` directory
8
+
9
+ The script will then automatically install all custom scripts and nodes.
10
+ It will attempt to use symlinks and junctions to prevent having to copy files and keep them up to date.
11
+
12
+ - For uninstallation:
13
+ - Delete the cloned repo in `custom_nodes`
14
+ - Ensure `web/extensions/pysssss/CustomScripts` has also been removed
15
+
16
+ # Update
17
+ 1. Navigate to the cloned repo e.g. `custom_nodes/ComfyUI-Custom-Scripts`
18
+ 2. `git pull`
19
+
20
+ # Features
21
+
22
+ ## Autocomplete
23
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/b5971135-414f-4f4e-a6cf-2650dc01085f)
24
+ Provides embedding and custom word autocomplete. You can view embedding details by clicking on the info icon on the list.
25
+ Define your list of custom words via the settings.
26
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/160ef61c-7d7e-49d0-b60f-5a1501b74c9d)
27
+ You can quickly default to danbooru tags using the Load button, or load/manage other custom word lists.
28
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/cc180b35-5f45-442f-9285-3ddf3fa320d0)
29
+
30
+ ## Auto Arrange Graph
31
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/04b06081-ca6f-4c0f-8584-d0a157c36747)
32
+ Adds a menu option to auto arrange the graph in order of execution, this makes very wide graphs!
33
+
34
+ ## Always Snap to Grid
35
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/66f36d1f-e579-4959-9880-9a9624922e3a)
36
+ Adds a setting to make moving nodes always snap to grid.
37
+
38
+ ## [Testing] "Better" Loader Lists
39
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/664caa71-f25f-4a96-a04a-1466d6b2b8b4)
40
+ Adds custom Lora and Checkpoint loader nodes, these have the ability to show preview images, just place a png or jpg next to the file and it'll display in the list on hover (e.g. sdxl.safetensors and sdxl.png).
41
+ Optionally enable subfolders via the settings:
42
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/e15b5e83-4f9d-4d57-8324-742bedf75439)
43
+ Adds an "examples" widget to load sample prompts, triggerwords, etc:
44
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/ad1751e4-4c85-42e7-9490-e94fb1cbc8e7)
45
+ These should be stored in a folder matching the name of the model, e.g. if it is `loras/add_detail.safetensors` put your files in as `loras/add_detail/*.txt`
46
+ To quickly save a generated image as the preview to use for the model, you can right click on an image on a node, and select Save as Preview and choose the model to save the preview for:
47
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/9fa8e9db-27b3-45cb-85c2-0860a238fd3a)
48
+
49
+ ## Checkpoint/LoRA/Embedding Info
50
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/6b67bf40-ee17-4fa6-a0c1-7947066bafc2)
51
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/32405df6-b367-404f-a5df-2d4347089a9e)
52
+ Adds "View Info" menu option to view details about the selected LoRA or Checkpoint. To view embedding details, click the info button when using embedding autocomplete.
53
+
54
+ ## Constrain Image
55
+ Adds a node for resizing an image to a max & min size optionally cropping if required.
56
+
57
+ ## Custom Colors
58
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/fa7883f3-f81c-49f6-9ab6-9526e4debab6)
59
+ Adds a custom color picker to nodes & groups
60
+
61
+ ## Favicon Status
62
+ ![image](https://user-images.githubusercontent.com/125205205/230171227-31f061a6-6324-4976-bed9-723a87500cf3.png)
63
+ ![image](https://user-images.githubusercontent.com/125205205/230171445-c7202a45-b511-4d69-87fa-945ad44c063f.png)
64
+ Adds a favicon and title to the window, favicon changes color while generating and the window title includes the number of prompts in the queue
65
+
66
+ ## Image Feed
67
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/caea0d48-85b9-4ca9-9771-5c795db35fbc)
68
+ Adds a panel showing images that have been generated in the current session, you can control the direction that images are added and the position of the panel via the ComfyUI settings screen and the size of the panel and the images via the sliders at the top of the panel.
69
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/ca093d38-41a3-4647-9223-5bd0b9ee4f1e)
70
+
71
+ ## KSampler (Advanced) denoise helper
72
+ Provides a simple method to set custom denoise on the advanced sampler
73
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/42946bd8-0078-4c7a-bfe9-7adb1382b5e2)
74
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/7cfccb22-f155-4848-934b-a2b2a6efe16f)
75
+
76
+ ## Lock Nodes & Groups
77
+ ![image](https://user-images.githubusercontent.com/125205205/230172868-5c5a943c-ade1-4799-bf80-cc931da5d4b2.png)
78
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/cfca09d9-38e5-4ecd-8b73-1455009fcd67)
79
+ Adds a lock option to nodes & groups that prevents you from moving them until unlocked
80
+
81
+ ## Math Expression
82
+ Allows for evaluating complex expressions using values from the graph. You can input `INT`, `FLOAT`, `IMAGE` and `LATENT` values.
83
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/1593edde-67b8-45d8-88cb-e75f52dba039)
84
+ Other nodes values can be referenced via the `Node name for S&R` via the `Properties` menu item on a node, or the node title.
85
+ Supported operators: `+ - * /` (basic ops) `//` (floor division) `**` (power) `^` (xor) `%` (mod)
86
+ Supported functions `floor(num, dp?)` `floor(num)` `ceil(num)` `randomint(min,max)`
87
+ If using a `LATENT` or `IMAGE` you can get the dimensions using `a.width` or `a.height` where `a` is the input name.
88
+
89
+ ## Node Finder
90
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/177d2b67-acbc-4ec3-ab31-7c295a98c194)
91
+ Adds a menu item for following/jumping to the executing node, and a menu to quickly go to a node of a specific type.
92
+
93
+ ## Preset Text
94
+ ![image](https://user-images.githubusercontent.com/125205205/230173939-08459efc-785b-46da-93d1-b02f0300c6f4.png)
95
+ Adds a node that lets you save and use text presets (e.g. for your 'normal' negatives)
96
+
97
+ ## Quick Nodes
98
+ ![image](https://user-images.githubusercontent.com/125205205/230174266-5232831a-a03b-4bf7-bc8b-c45466a0bc64.png)
99
+ Adds various menu items to some nodes for quickly setting up common parts of graphs
100
+
101
+ ## Play Sound
102
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/9bcf9fb3-5898-4432-a974-fb1e17d3b7e8)
103
+ Plays a sound when the node is executed, either after each prompt or only when the queue is empty for queuing multiple prompts.
104
+ You can customize the sound by replacing the mp3 file `web/extensions/pysssss/CustomScripts/assets\notify.mp3`
105
+
106
+ ## [WIP] Repeater
107
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/ec0dac25-14e4-4d44-b975-52193656709d)
108
+ Node allows you to either create a list of N repeats of the input node, or create N outputs from the input node.
109
+ You can optionally decide if you want to reuse the input node, or create a new instance each time (e.g. a Checkpoint Loader would want to be re-used, but a random number would want to be unique)
110
+ TODO: Type safety on the wildcard outputs to require match with input
111
+
112
+ ## Show Text
113
+ ![image](https://user-images.githubusercontent.com/125205205/230174888-c004fd48-da78-4de9-81c2-93a866fcfcd1.png)
114
+ Takes input from a node that produces a string and displays it, useful for things like interrogator, prompt generators, etc.
115
+
116
+ ## Show Image on Menu
117
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/b6ab58f2-583b-448c-bcfc-f93f5cdab0fc)
118
+ Shows the current generating image on the menu at the bottom, you can disable this via the settings menu.
119
+
120
+ ## String Function
121
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/01107137-8a93-4765-bae0-fcc110a09091)
122
+ Supports appending and replacing text
123
+ `tidy_tags` will add commas between parts when in `append` mode.
124
+ `replace` mode supports regex replace by using `/your regex here/` and you can reference capturing groups using `\number` e.g. `\1`
125
+
126
+ ## Touch Support
127
+ Provides basic support for touch screen devices, its not perfect but better than nothing
128
+
129
+ ## Widget Defaults
130
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/3d675032-2b19-4da8-a7d7-fa2d7c555daa)
131
+ Allows you to specify default values for widgets when adding new nodes, the values are configured via the settings menu
132
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/7b57a3d8-98d3-46e9-9b33-6645c0da41e7)
133
+
134
+ ## Workflows
135
+ Adds options to the menu for saving + loading workflows:
136
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/7b5a3012-4c59-47c6-8eea-85cf534403ea)
137
+
138
+ ## Workflow Images
139
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/06453fd2-c020-46ee-a7db-2b8bf5bcba7e)
140
+ Adds menu options for importing/exporting the graph as SVG and PNG showing a view of the nodes
141
+
142
+ ## (Testing) Reroute Primitive
143
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/8b870eef-d572-43f9-b394-cfa7abbd2f98) Provides a node that allows rerouting primitives.
144
+ The node can also be collapsed to a single point that you can drag around.
145
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/a9bd0112-cf8f-44f3-af6d-f9a8fed152a7)
146
+ Warning: Don't use normal reroutes or primitives with these nodes, it isn't tested and this node replaces their functionality.
147
+
148
+ <br>
149
+ <br>
150
+
151
+
152
+ ## WD14 Tagger
153
+ Moved to: https://github.com/pythongosssss/ComfyUI-WD14-Tagger
154
+
155
+ ## Link Render Mode
156
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/ad3be76b-43b1-455e-a64a-bf2a6571facf)
157
+ Allows you to control the rendering of the links between nodes between straight, linear & spline, e.g. Straight.
158
+
159
+ <br>
160
+ <br>
161
+
162
+
163
+ # Changelog
164
+
165
+ ## 2023-09-22
166
+ ### Minor
167
+ - ✨ Use Civitai image as preview
168
+ - πŸ› CTRL+Enter on autocomplete will no longer accept the suggestions as it is the shortcut for queuing a prompt.
169
+ - πŸ› Fix using numbers in widget defaults
170
+ - ✨ Support setting node properties (e.g. title, colors) via widget defaults
171
+
172
+ ## 2023-09-13
173
+ ### New
174
+ - ✨ Ability to "send" an image to a Load Image node in either the current or a different workflow
175
+ ### Minor
176
+ - ✨ Add support for A1111 autocomplete CSV format
177
+ - ✨ Allow setting custom node for middle click to add node
178
+
179
+ ## 2023-09-10
180
+ ### Minor
181
+ - πŸ› Fix rendering new lines in workflow image exports
182
+
183
+ ## 2023-09-08
184
+ ### New
185
+ - ✨ Add Load + Save Text file nodes, you can configure the allowed directories in the `user/text_file_dirs.json` file
186
+ ### Minor
187
+ - 🎨 Show autocomplete alias word on popup
188
+ - ✨ Add setting to disable middle click from adding a reroute node
189
+ - 🎨 Add prompt for setting custom column count on image feed (click the column count label)
190
+
191
+ ## 2023-09-07
192
+ ### New
193
+ - ✨ Support Unicode (e.g. Chinese) and word aliases in autocomplete.
194
+
195
+ ## 2023-09-05
196
+ ### Minor
197
+ - 🎨 Disable autocomplete on math node
198
+ - πŸ› Fix Show Text node always resizing on update
199
+
200
+ ### Minor
201
+ - 🎨 Better adding of preview image to menu (thanks to @zeroeightysix)
202
+ - 🎨 UX improvements for image feed (thanks to @birdddev)
203
+ - πŸ› Fix Math Expression expression not showing on updated ComfyUI
204
+ -
205
+ ## 2023-08-30
206
+ ### Minor
207
+ - 🎨 Allow jpeg lora/checkpoint preview images
208
+ - ✨ Save ShowText value to embedded image metadata
209
+
210
+ ## 2023-08-29
211
+ ### Minor
212
+ - ✨ Option to auto insert `, ` after autocomplete
213
+ - 🎨 Exclude arrow keys from triggering autocomplete
214
+ - πŸ› Split paths by `\` and `/` on Windows for submenus
215
+
216
+ ## 2023-08-28
217
+ ### New
218
+ - ✨ Add custom autocomplete word list setting
219
+ - ✨ Support autocomplete word priority sorting
220
+ - ✨ Support autocomplete matching anywhere in word rather than requiring starts with
221
+
222
+ ## 2023-08-27
223
+ ### New
224
+ - ✨ Add Checkpoint info
225
+ - ✨ Add embedding autocomplete
226
+ - ✨ Add embedding info
227
+ ### Major
228
+ - ♻️ Refactor LoRA info
229
+
230
+ ## 2023-08-26
231
+ ### Minor
232
+ - πŸ› Fix using text widget values in Math Expression not casting to number
233
+ - 🎨 Fix padding on lightbox next arrow
234
+
235
+ ## 2023-08-25
236
+ ### Minor
237
+ - ♻️ Support older versions of python
238
+
239
+ ## 2023-08-24
240
+ ### Minor
241
+ - πŸ› Fix extracting links from LoRA info notes
242
+
243
+ ## 2023-08-23
244
+ ### Major
245
+ - 🚨 Update to use `WEB_DIRECTORY` feature instead of manual linking/copying web files
246
+
247
+ ## 2023-08-22
248
+ ### New
249
+ - ✨ Math Expression now supports IMAGE and LATENT inputs, to access the dimensions use `a.width`, `b.height`
250
+ - 🎨 Removed STRING output on Math Expression, now draws the result onto the node
251
+
252
+ ## 2023-08-21
253
+ ### New
254
+ - ✨ Allow custom note (named {file}.txt) to show in LoRA info
255
+ - ✨ Query Civita API using the model hash to provide link
256
+
257
+ ## 2023-08-20
258
+ ### New
259
+ - ✨ Add LoRA Info menu option for displaying LoRA metadata
260
+ ### Minor
261
+ - πŸ› Fix crash on preset text replacement (thanks to @sjuxax)
262
+
263
+ ## 2023-08-19
264
+ ### New
265
+ - ✨ Add support for importing JPG files with embedded metadata (e.g. from Civitai)
266
+ ### Minor
267
+ - πŸ› Fix crash on graph arrange where LiteGraph sometimes stores links to deleted nodes
268
+ - πŸ› Fix a couple of rendering issues in workflow export
269
+
270
+ ## 2023-08-18
271
+ ### New
272
+ - ✨ Add "example" widget to custom LoRA + Checkpoint loader allowing you to quickly view saved prompts, triggers, etc
273
+ - ✨ Add quick "Save as Preview" option on images to save generated images for models
274
+
275
+ ## 2023-08-16
276
+ ### New
277
+ - ✨ Add repeater node for generating lists or quickly duplicating nodes
278
+ ### Minor
279
+ - πŸ› Support quick Add LoRA on custom Checkpoint Loader
280
+ - ✨ Support `randomint(min,max)` function in math node
281
+ - 🎨 Use relative imports to support proxied urls not on root path (thanks to @mcmonkey4eva)
282
+
283
+ ## 2023-08-13
284
+ ### Minor
285
+ - ✨ Support `round` `floor` `ceil` functions in math node
286
+ - πŸ› Fix floor division in math node
287
+
288
+ ## 2023-08-12
289
+ ### New
290
+ - 🎨 Image feed now uses a lightbox for showing images
291
+ ### Minor
292
+ - 🎨 Better loader lists now supports images named `{name}.preview.png`
293
+
294
+ ## 2023-08-11
295
+ ### Minor
296
+ - ✨ Enable filter box on submenus
297
+
298
+ ## 2023-08-05
299
+ ### Major
300
+ - 🚨 The ComfyUI Lora Loader no longer has subfolders, due to compatibility issues you need to use my Lora Loader if you want subfolers, these can be enabled/disabled on the node via a setting (🐍 Enable submenu in custom nodes)
301
+ ### New
302
+ - ✨ Add custom Checkpoint Loader supporting images & subfolders
303
+ - ✨ Add Play Sound node for notifying when a prompt is finished
304
+ ### Minor
305
+ - ✨ Quick Nodes supports new LoRA loader ("Add 🐍 LoRA")
306
+ - ♻️ Disable link render mode if ComfyUI has native support
307
+
308
+ ## 2023-08-04
309
+ ### Minor
310
+ - ✨ Always snap to grid now applies on node resize
311
+ - πŸ› Fix reroute primitive widget value not being restored on reload
312
+ - ✨ Workflows now reuse last filename from load & save - save must be done by the submenu
313
+
314
+ ## 2023-08-02
315
+ ### New
316
+ - ✨ Add "Always snap to grid" setting that does the same as holding shift, aligning nodes to the grid
317
+ ### Minor
318
+ - 🚨 No longer populates image feed when its closed
319
+ - πŸ› Allow lock/unlock of multiple selected nodes
320
+
321
+ ## 2023-08-01
322
+ ### Minor
323
+ - 🎨 Image feed now uses comfy theme variables for colors
324
+ - πŸ› Link render mode redraws graph on change of setting instead of requiring mouse move
325
+
326
+ ## 2023-07-30
327
+ - 🎨 Update to image feed to make more user friendly, change image size to column count, various other tweaks (thanks @DrJKL)
328
+
329
+ ## 2023-07-30
330
+ ### Major
331
+ - πŸ› Fix issue with context menu (right click) not working for some users after Lora script updates
332
+ ### New
333
+ - ✨ Add "Custom" option to color menu for nodes & groups
334
+ ### Minor
335
+ - πŸ› Fix String Function values converted to unconnected inputs outputting the text "undefined"
336
+
337
+ ## 2023-07-29
338
+ ### New
339
+ - ✨ Added Reroute Primitive combining the functionality of reroutes + primitives, also allowing collapsing to a single point.
340
+ - ✨ Add support for exporting workflow images as PNGs and optional embedding of metadata in PNG and SVG
341
+ ### Minor
342
+ - ✨ Remove new lines in Math Expression node
343
+ - ✨ String function is now an output node
344
+ - πŸ› Fix conflict between Lora Loader + Lora submenu causing the context menu to be have strangely (#23, #24)
345
+ - 🎨 Rename "SVG -> Import/Export" to "Workflow Image" -> Import/Export
346
+
347
+ ## 2023-07-27
348
+ ### New
349
+ - ✨ Added custom Lora Loader that includes image previews
350
+ ### Minor
351
+ - ✨ Add preview output to string function node
352
+ - πŸ“„ Updated missing/out of date parts of readme
353
+ - πŸ› Fix crash on show image on menu when set to not show (thanks @DrJKL)
354
+ - πŸ› Fix incorrect category (util vs utils) for math node (thanks @DrJKL)
355
+
356
+ ## 2023-07-27
357
+ ### Minor
358
+ - ✨ Save Image Feed close state
359
+ - πŸ› Fix unlocked group size calculation
360
+
361
+ ## 2023-07-21 + 22
362
+ ### Minor
363
+ - πŸ› Fix preset text incompatibility with Impact Pack (thanks @ltdrdata)
364
+
365
+ ## 2023-07-13
366
+ ### New
367
+ - ✨ Add Math Expression node for evaluating expressions using values from the graph
368
+ ### Minor
369
+ - ✨ Add settings for image feed location + image order
370
+
371
+ ## 2023-06-27
372
+ ### Minor
373
+ - πŸ› Fix unlocking group using incorrect size
374
+ - ✨ Save visibility of image feed
375
+
376
+ ## 2023-06-18
377
+ ### Major Changes
378
+ - ✨ Added auto installation of scripts and `__init__` (thanks @TashaSkyUp)
379
+ - ♻️ Reworked folder structure
380
+ - 🚨 Renamed a number of nodes to include `pysssss` to prevent name conflicts
381
+ - 🚨 Remove Latent Upscale By as it is now a built in node in ComfyUI
382
+ - 🚨 Removed Anime Segmentation to own repo
383
+ ### New
384
+ - ✨ Add Link Render Mode setting to choose how links are rendered
385
+ - ✨ Add Constrain Image node for resizing nodes to a min/max resolution with optional cropping
386
+ - ✨ Add Show Image On Menu to include the latest image output on the menu
387
+ - ✨ Add KSamplerAdvanced simple denoise prompt for configuring the node using steps + denoise
388
+ - 🎨 Add sizing options to Image Feed
389
+
390
+ ### Other
391
+ - ♻️ Include [canvas2svg](https://gliffy.github.io/canvas2svg/) for SVG export in assets to prevent downloading at runtime
392
+ - 🎨 Add background color (using theme color) to exported SVG
393
+ - πŸ› Fix Manage Widget Defaults to work with new ComfyUI settings dialog
394
+ - πŸ› Increase Image Feed z-index to prevent node text overlapping
custom_nodes/ComfyUI-Custom-Scripts/__init__.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import importlib.util
2
+ import glob
3
+ import os
4
+ import sys
5
+ from .pysssss import init, get_ext_dir
6
+
7
+ NODE_CLASS_MAPPINGS = {}
8
+ NODE_DISPLAY_NAME_MAPPINGS = {}
9
+
10
+ if init():
11
+ py = get_ext_dir("py")
12
+ files = glob.glob(os.path.join(py, "*.py"), recursive=False)
13
+ for file in files:
14
+ name = os.path.splitext(file)[0]
15
+ spec = importlib.util.spec_from_file_location(name, file)
16
+ module = importlib.util.module_from_spec(spec)
17
+ sys.modules[name] = module
18
+ spec.loader.exec_module(module)
19
+ if hasattr(module, "NODE_CLASS_MAPPINGS") and getattr(module, "NODE_CLASS_MAPPINGS") is not None:
20
+ NODE_CLASS_MAPPINGS.update(module.NODE_CLASS_MAPPINGS)
21
+ if hasattr(module, "NODE_DISPLAY_NAME_MAPPINGS") and getattr(module, "NODE_DISPLAY_NAME_MAPPINGS") is not None:
22
+ NODE_DISPLAY_NAME_MAPPINGS.update(module.NODE_DISPLAY_NAME_MAPPINGS)
23
+
24
+ WEB_DIRECTORY = "./web"
25
+ __all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS", "WEB_DIRECTORY"]
custom_nodes/ComfyUI-Custom-Scripts/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (854 Bytes). View file
 
custom_nodes/ComfyUI-Custom-Scripts/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (1.63 kB). View file
 
custom_nodes/ComfyUI-Custom-Scripts/__pycache__/pysssss.cpython-310.pyc ADDED
Binary file (7.34 kB). View file
 
custom_nodes/ComfyUI-Custom-Scripts/__pycache__/pysssss.cpython-311.pyc ADDED
Binary file (14.5 kB). View file
 
custom_nodes/ComfyUI-Custom-Scripts/py/__pycache__/autocomplete.cpython-310.pyc ADDED
Binary file (994 Bytes). View file
 
custom_nodes/ComfyUI-Custom-Scripts/py/__pycache__/autocomplete.cpython-311.pyc ADDED
Binary file (2.04 kB). View file
 
custom_nodes/ComfyUI-Custom-Scripts/py/__pycache__/better_combos.cpython-310.pyc ADDED
Binary file (4.32 kB). View file
 
custom_nodes/ComfyUI-Custom-Scripts/py/__pycache__/better_combos.cpython-311.pyc ADDED
Binary file (8.52 kB). View file
 
custom_nodes/ComfyUI-Custom-Scripts/py/__pycache__/constrain_image.cpython-310.pyc ADDED
Binary file (2.06 kB). View file
 
custom_nodes/ComfyUI-Custom-Scripts/py/__pycache__/constrain_image.cpython-311.pyc ADDED
Binary file (3.74 kB). View file
 
custom_nodes/ComfyUI-Custom-Scripts/py/__pycache__/math_expression.cpython-310.pyc ADDED
Binary file (5.13 kB). View file
 
custom_nodes/ComfyUI-Custom-Scripts/py/__pycache__/math_expression.cpython-311.pyc ADDED
Binary file (9.24 kB). View file
 
custom_nodes/ComfyUI-Custom-Scripts/py/__pycache__/model_info.cpython-310.pyc ADDED
Binary file (2.63 kB). View file
 
custom_nodes/ComfyUI-Custom-Scripts/py/__pycache__/model_info.cpython-311.pyc ADDED
Binary file (6.4 kB). View file
 
custom_nodes/ComfyUI-Custom-Scripts/py/__pycache__/play_sound.cpython-310.pyc ADDED
Binary file (1.49 kB). View file
 
custom_nodes/ComfyUI-Custom-Scripts/py/__pycache__/play_sound.cpython-311.pyc ADDED
Binary file (1.92 kB). View file
 
custom_nodes/ComfyUI-Custom-Scripts/py/__pycache__/repeater.cpython-310.pyc ADDED
Binary file (1.42 kB). View file
 
custom_nodes/ComfyUI-Custom-Scripts/py/__pycache__/repeater.cpython-311.pyc ADDED
Binary file (1.96 kB). View file