yijin928 commited on
Commit
6af0efe
·
verified ·
1 Parent(s): 25bb7a0

Upload 309 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. custom_nodes/ComfyUI-ReActor/.github/ISSUE_TEMPLATE/bug_report.yml +56 -0
  2. custom_nodes/ComfyUI-ReActor/.github/ISSUE_TEMPLATE/config.yml +5 -0
  3. custom_nodes/ComfyUI-ReActor/.github/ISSUE_TEMPLATE/feature_request.yml +16 -0
  4. custom_nodes/ComfyUI-ReActor/.github/workflows/publish_action.yml +20 -0
  5. custom_nodes/ComfyUI-ReActor/.gitignore +5 -0
  6. custom_nodes/ComfyUI-ReActor/LICENSE +674 -0
  7. custom_nodes/ComfyUI-ReActor/README.md +482 -0
  8. custom_nodes/ComfyUI-ReActor/README_RU.md +491 -0
  9. custom_nodes/ComfyUI-ReActor/__init__.py +39 -0
  10. custom_nodes/ComfyUI-ReActor/__pycache__/__init__.cpython-311.pyc +0 -0
  11. custom_nodes/ComfyUI-ReActor/__pycache__/nodes.cpython-311.pyc +0 -0
  12. custom_nodes/ComfyUI-ReActor/__pycache__/reactor_patcher.cpython-311.pyc +0 -0
  13. custom_nodes/ComfyUI-ReActor/__pycache__/reactor_utils.cpython-311.pyc +0 -0
  14. custom_nodes/ComfyUI-ReActor/install.bat +37 -0
  15. custom_nodes/ComfyUI-ReActor/install.py +104 -0
  16. custom_nodes/ComfyUI-ReActor/modules/__init__.py +0 -0
  17. custom_nodes/ComfyUI-ReActor/modules/__pycache__/__init__.cpython-311.pyc +0 -0
  18. custom_nodes/ComfyUI-ReActor/modules/__pycache__/processing.cpython-311.pyc +0 -0
  19. custom_nodes/ComfyUI-ReActor/modules/__pycache__/scripts.cpython-311.pyc +0 -0
  20. custom_nodes/ComfyUI-ReActor/modules/__pycache__/scripts_postprocessing.cpython-311.pyc +0 -0
  21. custom_nodes/ComfyUI-ReActor/modules/__pycache__/shared.cpython-311.pyc +0 -0
  22. custom_nodes/ComfyUI-ReActor/modules/images.py +0 -0
  23. custom_nodes/ComfyUI-ReActor/modules/processing.py +13 -0
  24. custom_nodes/ComfyUI-ReActor/modules/scripts.py +13 -0
  25. custom_nodes/ComfyUI-ReActor/modules/scripts_postprocessing.py +0 -0
  26. custom_nodes/ComfyUI-ReActor/modules/shared.py +19 -0
  27. custom_nodes/ComfyUI-ReActor/nodes.py +1275 -0
  28. custom_nodes/ComfyUI-ReActor/pyproject.toml +15 -0
  29. custom_nodes/ComfyUI-ReActor/r_basicsr/__init__.py +12 -0
  30. custom_nodes/ComfyUI-ReActor/r_basicsr/__pycache__/__init__.cpython-311.pyc +0 -0
  31. custom_nodes/ComfyUI-ReActor/r_basicsr/__pycache__/test.cpython-311.pyc +0 -0
  32. custom_nodes/ComfyUI-ReActor/r_basicsr/__pycache__/train.cpython-311.pyc +0 -0
  33. custom_nodes/ComfyUI-ReActor/r_basicsr/__pycache__/version.cpython-311.pyc +0 -0
  34. custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__init__.py +25 -0
  35. custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__pycache__/__init__.cpython-311.pyc +0 -0
  36. custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__pycache__/arch_util.cpython-311.pyc +0 -0
  37. custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__pycache__/basicvsr_arch.cpython-311.pyc +0 -0
  38. custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__pycache__/basicvsrpp_arch.cpython-311.pyc +0 -0
  39. custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__pycache__/dfdnet_arch.cpython-311.pyc +0 -0
  40. custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__pycache__/dfdnet_util.cpython-311.pyc +0 -0
  41. custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__pycache__/discriminator_arch.cpython-311.pyc +0 -0
  42. custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__pycache__/duf_arch.cpython-311.pyc +0 -0
  43. custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__pycache__/ecbsr_arch.cpython-311.pyc +0 -0
  44. custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__pycache__/edsr_arch.cpython-311.pyc +0 -0
  45. custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__pycache__/edvr_arch.cpython-311.pyc +0 -0
  46. custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__pycache__/hifacegan_arch.cpython-311.pyc +0 -0
  47. custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__pycache__/hifacegan_util.cpython-311.pyc +0 -0
  48. custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__pycache__/rcan_arch.cpython-311.pyc +0 -0
  49. custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__pycache__/ridnet_arch.cpython-311.pyc +0 -0
  50. custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__pycache__/rrdbnet_arch.cpython-311.pyc +0 -0
custom_nodes/ComfyUI-ReActor/.github/ISSUE_TEMPLATE/bug_report.yml ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Bug Report
2
+ description: You think somethings is broken
3
+ labels: ["bug", "new"]
4
+
5
+ body:
6
+ - type: checkboxes
7
+ attributes:
8
+ label: First, confirm
9
+ description: Make sure you use the latest version of the ReActor extension and you have already searched to see if an issue already exists for the bug you encountered before you create a new Issue.
10
+ options:
11
+ - label: I have read the [instruction](https://github.com/Gourieff/ComfyUI-ReActor/blob/main/README.md) carefully
12
+ required: true
13
+ - label: I have searched the existing issues
14
+ required: true
15
+ - label: I have updated the extension to the latest version
16
+ required: true
17
+ - type: markdown
18
+ attributes:
19
+ value: |
20
+ *Please fill this form with as much information as possible and *provide screenshots if possible**
21
+ - type: textarea
22
+ id: what-did
23
+ attributes:
24
+ label: What happened?
25
+ description: Tell what happened in a very clear and simple way
26
+ validations:
27
+ required: true
28
+ - type: textarea
29
+ id: steps
30
+ attributes:
31
+ label: Steps to reproduce the problem
32
+ description: Please provide with precise step by step instructions on how to reproduce the bug
33
+ value: |
34
+ Your workflow
35
+ validations:
36
+ required: true
37
+ - type: textarea
38
+ id: sysinfo
39
+ attributes:
40
+ label: Sysinfo
41
+ description: Describe your platform. OS, browser, GPU, what other nodes are also enabled.
42
+ validations:
43
+ required: true
44
+ - type: textarea
45
+ id: logs
46
+ attributes:
47
+ label: Relevant console log
48
+ description: Please provide cmd/terminal logs from the moment you started UI to the momemt you got an error. This will be automatically formatted into code, so no need for backticks.
49
+ render: Shell
50
+ validations:
51
+ required: true
52
+ - type: textarea
53
+ id: misc
54
+ attributes:
55
+ label: Additional information
56
+ description: Please provide with any relevant additional info or context.
custom_nodes/ComfyUI-ReActor/.github/ISSUE_TEMPLATE/config.yml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ blank_issues_enabled: false
2
+ contact_links:
3
+ - name: ReActor Node Community Support
4
+ url: https://github.com/Gourieff/ComfyUI-ReActor/discussions
5
+ about: Please ask and answer questions here.
custom_nodes/ComfyUI-ReActor/.github/ISSUE_TEMPLATE/feature_request.yml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Feature request
2
+ description: Suggest an idea for this project
3
+ title: "[Feature]: "
4
+ labels: ["enhancement", "new"]
5
+
6
+ body:
7
+ - type: textarea
8
+ id: description
9
+ attributes:
10
+ label: Feature description
11
+ description: Describe the feature in a clear and simple way
12
+ value:
13
+ - type: markdown
14
+ attributes:
15
+ value: |
16
+ The best way to propose an idea is to start a new discussion via the [Discussions](https://github.com/Gourieff/ComfyUI-ReActor/discussions) section (choose the "Idea" category)
custom_nodes/ComfyUI-ReActor/.github/workflows/publish_action.yml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Publish to Comfy registry
2
+ on:
3
+ workflow_dispatch:
4
+ push:
5
+ branches:
6
+ - main
7
+ paths:
8
+ - "pyproject.toml"
9
+
10
+ jobs:
11
+ publish-node:
12
+ name: Publish Custom Node to registry
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - name: Check out code
16
+ uses: actions/checkout@v4
17
+ - name: Publish Custom Node
18
+ uses: Comfy-Org/publish-node-action@main
19
+ with:
20
+ personal_access_token: ${{ secrets.REGISTRY_ACCESS_TOKEN }} ## Add your own personal access token to your Github secrets and reference it here.
custom_nodes/ComfyUI-ReActor/.gitignore ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ __pycache__/
2
+ *$py.class
3
+ .vscode/
4
+ example
5
+ input
custom_nodes/ComfyUI-ReActor/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-ReActor/README.md ADDED
@@ -0,0 +1,482 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div align="center">
2
+
3
+ <img src="https://github.com/Gourieff/Assets/raw/main/sd-webui-reactor/ReActor_logo_NEW_EN.png?raw=true" alt="logo" width="180px"/>
4
+
5
+ ![Version](https://img.shields.io/badge/node_version-0.5.2_beta2-green?style=for-the-badge&labelColor=darkgreen)
6
+
7
+ <!--<sup>
8
+ <font color=brightred>
9
+
10
+ ## !!! [Important Update](#latestupdate) !!!<br>Don't forget to add the Node again in existing workflows
11
+
12
+ </font>
13
+ </sup>-->
14
+
15
+ <a href="https://boosty.to/artgourieff" target="_blank">
16
+ <img src="https://lovemet.ru/img/boosty.jpg" width="108" alt="Support Me on Boosty"/>
17
+ <br>
18
+ <sup>
19
+ Support This Project
20
+ </sup>
21
+ </a>
22
+
23
+ <hr>
24
+
25
+ [![Commit activity](https://img.shields.io/github/commit-activity/t/Gourieff/ComfyUI-ReActor/main?cacheSeconds=0)](https://github.com/Gourieff/ComfyUI-ReActor/commits/main)
26
+ ![Last commit](https://img.shields.io/github/last-commit/Gourieff/ComfyUI-ReActor/main?cacheSeconds=0)
27
+ [![Opened issues](https://img.shields.io/github/issues/Gourieff/ComfyUI-ReActor?color=red)](https://github.com/Gourieff/ComfyUI-ReActor/issues?cacheSeconds=0)
28
+ [![Closed issues](https://img.shields.io/github/issues-closed/Gourieff/ComfyUI-ReActor?color=green&cacheSeconds=0)](https://github.com/Gourieff/ComfyUI-ReActor/issues?q=is%3Aissue+state%3Aclosed)
29
+ ![License](https://img.shields.io/github/license/Gourieff/ComfyUI-ReActor)
30
+
31
+ English | [Русский](/README_RU.md)
32
+
33
+ # ReActor Nodes for ComfyUI<br><sub><sup>-=SFW-Friendly=-</sup></sub>
34
+
35
+ </div>
36
+
37
+ ### The Fast and Simple Face Swap Extension Nodes for ComfyUI, based on [blocked ReActor](https://github.com/Gourieff/comfyui-reactor-node) - now it has a nudity detector to avoid using this software with 18+ content
38
+
39
+ > By using this Node you accept and assume [responsibility](#disclaimer))
40
+
41
+ <div align="center">
42
+
43
+ ---
44
+ [**What's new**](#latestupdate) | [**Installation**](#installation) | [**Usage**](#usage) | [**Troubleshooting**](#troubleshooting) | [**Updating**](#updating) | [**Disclaimer**](#disclaimer) | [**Credits**](#credits) | [**Note!**](#note)
45
+
46
+ ---
47
+
48
+ </div>
49
+
50
+ <a name="latestupdate">
51
+
52
+ ## What's new in the latest update
53
+
54
+ ### 0.5.2 <sub><sup>BETA1</sup></sub>
55
+
56
+ - ReSwapper models support. Although Inswapper still has the best similarity, but ReSwapper is evolving - thanks @somanchiu https://github.com/somanchiu/ReSwapper for the ReSwapper models and the ReSwapper project! This is a good step for the Community in the Inswapper's alternative creation!
57
+
58
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.5.2-whatsnew-03.jpg?raw=true" alt="0.5.2-whatsnew-03" width="100%"/>
59
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.5.2-whatsnew-04.jpg?raw=true" alt="0.5.2-whatsnew-04" width="100%"/>
60
+
61
+ You can download ReSwapper models here:
62
+ https://huggingface.co/datasets/Gourieff/ReActor/tree/main/models
63
+ Just put them into the "models/reswapper" directory.
64
+
65
+ ### 0.5.2 <sub><sup>ALPHA3</sup></sub>
66
+
67
+ - NSFW-detector to not violate [GitHub rules](https://docs.github.com/en/site-policy/acceptable-use-policies/github-misinformation-and-disinformation#synthetic--manipulated-media-tools)
68
+
69
+ ### 0.5.2 <sub><sup>ALPHA2</sup></sub>
70
+
71
+ - Minor fixes
72
+
73
+ ### 0.5.2 <sub><sup>ALPHA1</sup></sub>
74
+
75
+ - New node "Unload ReActor Models" - is useful for complex WFs when you need to free some VRAM utilized by ReActor
76
+
77
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.5.2-whatsnew-01.jpg?raw=true" alt="0.5.2-whatsnew-01" width="100%"/>
78
+
79
+ - Support of ORT CoreML and ROCM EPs, just install onnxruntime version you need
80
+ - Install script improvements to install latest versions of ORT-GPU
81
+
82
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.5.2-whatsnew-02.jpg?raw=true" alt="0.5.2-whatsnew-02" width="50%"/>
83
+
84
+ <details>
85
+ <summary><a>Previous versions</a></summary>
86
+
87
+ ### 0.5.1
88
+
89
+ - Support of GPEN 1024/2048 restoration models (available in the HF dataset https://huggingface.co/datasets/Gourieff/ReActor/tree/main/models/facerestore_models)
90
+ - ReActorFaceBoost Node - an attempt to improve the quality of swapped faces. The idea is to restore and scale the swapped face (according to the `face_size` parameter of the restoration model) BEFORE pasting it to the target image (via inswapper algorithms), more information is [here (PR#321)](https://github.com/Gourieff/comfyui-reactor-node/pull/321)
91
+
92
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.5.1-whatsnew-01.jpg?raw=true" alt="0.5.1-whatsnew-01" width="100%"/>
93
+
94
+ [Full size demo preview](https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.5.1-whatsnew-02.png)
95
+
96
+ - Sorting facemodels alphabetically
97
+ - A lot of fixes and improvements
98
+
99
+ ### [0.5.0 <sub><sup>BETA4</sup></sub>](https://github.com/Gourieff/comfyui-reactor-node/releases/tag/v0.5.0)
100
+
101
+ - Spandrel lib support for GFPGAN
102
+
103
+ ### 0.5.0 <sub><sup>BETA3</sup></sub>
104
+
105
+ - Fixes: "RAM issue", "No detection" for MaskingHelper
106
+
107
+ ### 0.5.0 <sub><sup>BETA2</sup></sub>
108
+
109
+ - You can now build a blended face model from a batch of face models you already have, just add the "Make Face Model Batch" node to your workflow and connect several models via "Load Face Model"
110
+ - Huge performance boost of the image analyzer's module! 10x speed up! Working with videos is now a pleasure!
111
+
112
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.5.0-whatsnew-05.png?raw=true" alt="0.5.0-whatsnew-05" width="100%"/>
113
+
114
+ ### 0.5.0 <sub><sup>BETA1</sup></sub>
115
+
116
+ - SWAPPED_FACE output for the Masking Helper Node
117
+ - FIX: Empty A-channel for Masking Helper IMAGE output (causing errors with some nodes) was removed
118
+
119
+ ### 0.5.0 <sub><sup>ALPHA1</sup></sub>
120
+
121
+ - ReActorBuildFaceModel Node got "face_model" output to provide a blended face model directly to the main Node:
122
+
123
+ Basic workflow [💾](https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/workflows/ReActor--Build-Blended-Face-Model--v2.json)
124
+
125
+ - Face Masking feature is available now, just add the "ReActorMaskHelper" Node to the workflow and connect it as shown below:
126
+
127
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.5.0-whatsnew-01.jpg?raw=true" alt="0.5.0-whatsnew-01" width="100%"/>
128
+
129
+ If you don't have the "face_yolov8m.pt" Ultralytics model - you can download it from the [Assets](https://huggingface.co/datasets/Gourieff/ReActor/blob/main/models/detection/bbox/face_yolov8m.pt) and put it into the "ComfyUI\models\ultralytics\bbox" directory
130
+ <br>
131
+ As well as ["sam_vit_b_01ec64.pth"](https://huggingface.co/datasets/Gourieff/ReActor/blob/main/models/sams/sam_vit_b_01ec64.pth) model - download (if you don't have it) and put it into the "ComfyUI\models\sams" directory;
132
+
133
+ Use this Node to gain the best results of the face swapping process:
134
+
135
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.5.0-whatsnew-02.jpg?raw=true" alt="0.5.0-whatsnew-02" width="100%"/>
136
+
137
+ - ReActorImageDublicator Node - rather useful for those who create videos, it helps to duplicate one image to several frames to use them with VAE Encoder (e.g. live avatars):
138
+
139
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.5.0-whatsnew-03.jpg?raw=true" alt="0.5.0-whatsnew-03" width="100%"/>
140
+
141
+ - ReActorFaceSwapOpt (a simplified version of the Main Node) + ReActorOptions Nodes to set some additional options such as (new) "input/source faces separate order". Yes! You can now set the order of faces in the index in the way you want ("large to small" goes by default)!
142
+
143
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.5.0-whatsnew-04.jpg?raw=true" alt="0.5.0-whatsnew-04" width="100%"/>
144
+
145
+ - Little speed boost when analyzing target images (unfortunately it is still quite slow in compare to swapping and restoring...)
146
+
147
+ ### [0.4.2](https://github.com/Gourieff/comfyui-reactor-node/releases/tag/v0.4.2)
148
+
149
+ - GPEN-BFR-512 and RestoreFormer_Plus_Plus face restoration models support
150
+
151
+ You can download models here: https://huggingface.co/datasets/Gourieff/ReActor/tree/main/models/facerestore_models
152
+ <br>Put them into the `ComfyUI\models\facerestore_models` folder
153
+
154
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.4.2-whatsnew-04.jpg?raw=true" alt="0.4.2-whatsnew-04" width="100%"/>
155
+
156
+ - Due to popular demand - you can now blend several images with persons into one face model file and use it with "Load Face Model" Node or in SD WebUI as well;
157
+
158
+ Experiment and create new faces or blend faces of one person to gain better accuracy and likeness!
159
+
160
+ Just add the ImpactPack's "Make Image Batch" Node as the input to the ReActor's one and load images you want to blend into one model:
161
+
162
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.4.2-whatsnew-01.jpg?raw=true" alt="0.4.2-whatsnew-01" width="100%"/>
163
+
164
+ Result example (the new face was created from 4 faces of different actresses):
165
+
166
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.4.2-whatsnew-02.jpg?raw=true" alt="0.4.2-whatsnew-02" width="75%"/>
167
+
168
+ Basic workflow [💾](https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/workflows/ReActor--Build-Blended-Face-Model--v1.json)
169
+
170
+ ### [0.4.1](https://github.com/Gourieff/comfyui-reactor-node/releases/tag/v0.4.1)
171
+
172
+ - CUDA 12 Support - don't forget to run (Windows) `install.bat` or (Linux/MacOS) `install.py` for ComfyUI's Python enclosure or try to install ORT-GPU for CU12 manually (https://onnxruntime.ai/docs/install/#install-onnx-runtime-gpu-cuda-12x)
173
+ - Issue https://github.com/Gourieff/comfyui-reactor-node/issues/173 fix
174
+
175
+ - Separate Node for the Face Restoration postprocessing (FR https://github.com/Gourieff/comfyui-reactor-node/issues/191), can be found inside ReActor's menu (RestoreFace Node)
176
+ - (Windows) Installation can be done for Python from the System's PATH
177
+ - Different fixes and improvements
178
+
179
+ - Face Restore Visibility and CodeFormer Weight (Fidelity) options are now available! Don't forget to reload the Node in your existing workflow
180
+
181
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.4.1-whatsnew-01.jpg?raw=true" alt="0.4.1-whatsnew-01" width="100%"/>
182
+
183
+ ### [0.4.0](https://github.com/Gourieff/comfyui-reactor-node/releases/tag/v0.4.0)
184
+
185
+ - Input "input_image" goes first now, it gives a correct bypass and also it is right to have the main input first;
186
+ - You can now save face models as "safetensors" files (`ComfyUI\models\reactor\faces`) and load them into ReActor implementing different scenarios and keeping super lightweight face models of the faces you use:
187
+
188
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.4.0-whatsnew-01.jpg?raw=true" alt="0.4.0-whatsnew-01" width="100%"/>
189
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.4.0-whatsnew-02.jpg?raw=true" alt="0.4.0-whatsnew-02" width="100%"/>
190
+
191
+ - Ability to build and save face models directly from an image:
192
+
193
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.4.0-whatsnew-03.jpg?raw=true" alt="0.4.0-whatsnew-03" width="50%"/>
194
+
195
+ - Both the inputs are optional, just connect one of them according to your workflow; if both is connected - `image` has a priority.
196
+ - Different fixes making this extension better.
197
+
198
+ Thanks to everyone who finds bugs, suggests new features and supports this project!
199
+
200
+ </details>
201
+
202
+ ## Installation
203
+
204
+ <details>
205
+ <summary>SD WebUI: <a href="https://github.com/AUTOMATIC1111/stable-diffusion-webui/">AUTOMATIC1111</a> or <a href="https://github.com/vladmandic/automatic">SD.Next</a></summary>
206
+
207
+ 1. Close (stop) your SD-WebUI/Comfy Server if it's running
208
+ 2. (For Windows Users):
209
+ - Install [Visual Studio 2022](https://visualstudio.microsoft.com/downloads/) (Community version - you need this step to build Insightface)
210
+ - OR only [VS C++ Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/) and select "Desktop Development with C++" under "Workloads -> Desktop & Mobile"
211
+ - OR if you don't want to install VS or VS C++ BT - follow [this steps (sec. I)](#insightfacebuild)
212
+ 3. Go to the `extensions\sd-webui-comfyui\ComfyUI\custom_nodes`
213
+ 4. Open Console or Terminal and run `git clone https://github.com/Gourieff/ComfyUI-ReActor`
214
+ 5. Go to the SD WebUI root folder, open Console or Terminal and run (Windows users)`.\venv\Scripts\activate` or (Linux/MacOS)`venv/bin/activate`
215
+ 6. `python -m pip install -U pip`
216
+ 7. `cd extensions\sd-webui-comfyui\ComfyUI\custom_nodes\ComfyUI-ReActor`
217
+ 8. `python install.py`
218
+ 9. Please, wait until the installation process will be finished
219
+ 10. (From the version 0.3.0) Download additional facerestorers models from the link below and put them into the `extensions\sd-webui-comfyui\ComfyUI\models\facerestore_models` directory:<br>
220
+ https://huggingface.co/datasets/Gourieff/ReActor/tree/main/models/facerestore_models
221
+ 11. Run SD WebUI and check console for the message that ReActor Node is running:
222
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/uploads/console_status_running.jpg?raw=true" alt="console_status_running" width="759"/>
223
+
224
+ 12. Go to the ComfyUI tab and find there ReActor Node inside the menu `ReActor` or by using a search:
225
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/uploads/webui-demo.png?raw=true" alt="webui-demo" width="100%"/>
226
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/uploads/search-demo.png?raw=true" alt="webui-demo" width="1043"/>
227
+
228
+ </details>
229
+
230
+ <details>
231
+ <summary>Standalone (Portable) <a href="https://github.com/comfyanonymous/ComfyUI">ComfyUI</a> for Windows</summary>
232
+
233
+ 1. Do the following:
234
+ - Install [Visual Studio 2022](https://visualstudio.microsoft.com/downloads/) (Community version - you need this step to build Insightface)
235
+ - OR only [VS C++ Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/) and select "Desktop Development with C++" under "Workloads -> Desktop & Mobile"
236
+ - OR if you don't want to install VS or VS C++ BT - follow [this steps (sec. I)](#insightfacebuild)
237
+ 2. Choose between two options:
238
+ - (ComfyUI Manager) Open ComfyUI Manager, click "Install Custom Nodes", type "ReActor" in the "Search" field and then click "Install". After ComfyUI will complete the process - please restart the Server.
239
+ - (Manually) Go to `ComfyUI\custom_nodes`, open Console and run `git clone https://github.com/Gourieff/ComfyUI-ReActor`
240
+ 3. Go to `ComfyUI\custom_nodes\ComfyUI-ReActor` and run `install.bat`
241
+ 4. If you don't have the "face_yolov8m.pt" Ultralytics model - you can download it from the [Assets](https://huggingface.co/datasets/Gourieff/ReActor/blob/main/models/detection/bbox/face_yolov8m.pt) and put it into the "ComfyUI\models\ultralytics\bbox" directory
242
+ <br>
243
+ As well as one or both of "Sams" models from [here](https://huggingface.co/datasets/Gourieff/ReActor/tree/main/models/sams) - download (if you don't have them) and put into the "ComfyUI\models\sams" directory
244
+ 5. Run ComfyUI and find there ReActor Nodes inside the menu `ReActor` or by using a search
245
+
246
+ </details>
247
+
248
+ ## Usage
249
+
250
+ You can find ReActor Nodes inside the menu `ReActor` or by using a search (just type "ReActor" in the search field)
251
+
252
+ List of Nodes:
253
+ - ••• Main Nodes •••
254
+ - ReActorFaceSwap (Main Node)
255
+ - ReActorFaceSwapOpt (Main Node with the additional Options input)
256
+ - ReActorOptions (Options for ReActorFaceSwapOpt)
257
+ - ReActorFaceBoost (Face Booster Node)
258
+ - ReActorMaskHelper (Masking Helper)
259
+ - ••• Operations with Face Models •••
260
+ - ReActorSaveFaceModel (Save Face Model)
261
+ - ReActorLoadFaceModel (Load Face Model)
262
+ - ReActorBuildFaceModel (Build Blended Face Model)
263
+ - ReActorMakeFaceModelBatch (Make Face Model Batch)
264
+ - ••• Additional Nodes •••
265
+ - ReActorRestoreFace (Face Restoration)
266
+ - ReActorImageDublicator (Dublicate one Image to Images List)
267
+ - ImageRGBA2RGB (Convert RGBA to RGB)
268
+
269
+ Connect all required slots and run the query.
270
+
271
+ ### Main Node Inputs
272
+
273
+ - `input_image` - is an image to be processed (target image, analog of "target image" in the SD WebUI extension);
274
+ - Supported Nodes: "Load Image", "Load Video" or any other nodes providing images as an output;
275
+ - `source_image` - is an image with a face or faces to swap in the `input_image` (source image, analog of "source image" in the SD WebUI extension);
276
+ - Supported Nodes: "Load Image" or any other nodes providing images as an output;
277
+ - `face_model` - is the input for the "Load Face Model" Node or another ReActor node to provide a face model file (face embedding) you created earlier via the "Save Face Model" Node;
278
+ - Supported Nodes: "Load Face Model", "Build Blended Face Model";
279
+
280
+ ### Main Node Outputs
281
+
282
+ - `IMAGE` - is an output with the resulted image;
283
+ - Supported Nodes: any nodes which have images as an input;
284
+ - `FACE_MODEL` - is an output providing a source face's model being built during the swapping process;
285
+ - Supported Nodes: "Save Face Model", "ReActor", "Make Face Model Batch";
286
+
287
+ ### Face Restoration
288
+
289
+ Since version 0.3.0 ReActor Node has a buil-in face restoration.<br>Just download the models you want (see [Installation](#installation) instruction) and select one of them to restore the resulting face(s) during the faceswap. It will enhance face details and make your result more accurate.
290
+
291
+ ### Face Indexes
292
+
293
+ By default ReActor detects faces in images from "large" to "small".<br>You can change this option by adding ReActorFaceSwapOpt node with ReActorOptions.
294
+
295
+ And if you need to specify faces, you can set indexes for source and input images.
296
+
297
+ Index of the first detected face is 0.
298
+
299
+ You can set indexes in the order you need.<br>
300
+ E.g.: 0,1,2 (for Source); 1,0,2 (for Input).<br>This means: the second Input face (index = 1) will be swapped by the first Source face (index = 0) and so on.
301
+
302
+ ### Genders
303
+
304
+ You can specify the gender to detect in images.<br>
305
+ ReActor will swap a face only if it meets the given condition.
306
+
307
+ ### Face Models
308
+
309
+ Since version 0.4.0 you can save face models as "safetensors" files (stored in `ComfyUI\models\reactor\faces`) and load them into ReActor implementing different scenarios and keeping super lightweight face models of the faces you use.
310
+
311
+ To make new models appear in the list of the "Load Face Model" Node - just refresh the page of your ComfyUI web application.<br>
312
+ (I recommend you to use ComfyUI Manager - otherwise you workflow can be lost after you refresh the page if you didn't save it before that).
313
+
314
+ ## Troubleshooting
315
+
316
+ <a name="insightfacebuild">
317
+
318
+ ### **I. (For Windows users) If you still cannot build Insightface for some reasons or just don't want to install Visual Studio or VS C++ Build Tools - do the following:**
319
+
320
+ 1. (ComfyUI Portable) From the root folder check the version of Python:<br>run CMD and type `python_embeded\python.exe -V`
321
+ 2. Download prebuilt Insightface package [for Python 3.10](https://github.com/Gourieff/Assets/raw/main/Insightface/insightface-0.7.3-cp310-cp310-win_amd64.whl) or [for Python 3.11](https://github.com/Gourieff/Assets/raw/main/Insightface/insightface-0.7.3-cp311-cp311-win_amd64.whl) (if in the previous step you see 3.11) or [for Python 3.12](https://github.com/Gourieff/Assets/raw/main/Insightface/insightface-0.7.3-cp312-cp312-win_amd64.whl) (if in the previous step you see 3.12) and put into the stable-diffusion-webui (A1111 or SD.Next) root folder (where you have "webui-user.bat" file) or into ComfyUI root folder if you use ComfyUI Portable
322
+ 3. From the root folder run:
323
+ - (SD WebUI) CMD and `.\venv\Scripts\activate`
324
+ - (ComfyUI Portable) run CMD
325
+ 4. Then update your PIP:
326
+ - (SD WebUI) `python -m pip install -U pip`
327
+ - (ComfyUI Portable) `python_embeded\python.exe -m pip install -U pip`
328
+ 5. Then install Insightface:
329
+ - (SD WebUI) `pip install insightface-0.7.3-cp310-cp310-win_amd64.whl` (for 3.10) or `pip install insightface-0.7.3-cp311-cp311-win_amd64.whl` (for 3.11) or `pip install insightface-0.7.3-cp312-cp312-win_amd64.whl` (for 3.12)
330
+ - (ComfyUI Portable) `python_embeded\python.exe -m pip install insightface-0.7.3-cp310-cp310-win_amd64.whl` (for 3.10) or `python_embeded\python.exe -m pip install insightface-0.7.3-cp311-cp311-win_amd64.whl` (for 3.11) or `python_embeded\python.exe -m pip install insightface-0.7.3-cp312-cp312-win_amd64.whl` (for 3.12)
331
+ 6. Enjoy!
332
+
333
+ ### **II. "AttributeError: 'NoneType' object has no attribute 'get'"**
334
+
335
+ This error may occur if there's smth wrong with the model file `inswapper_128.onnx`
336
+
337
+ Try to download it manually from [here](https://github.com/facefusion/facefusion-assets/releases/download/models/inswapper_128.onnx)
338
+ and put it to the `ComfyUI\models\insightface` replacing existing one
339
+
340
+ ### **III. "reactor.execute() got an unexpected keyword argument 'reference_image'"**
341
+
342
+ This means that input points have been changed with the latest update<br>
343
+ Remove the current ReActor Node from your workflow and add it again
344
+
345
+ ### **IV. ControlNet Aux Node IMPORT failed error when using with ReActor Node**
346
+
347
+ 1. Close ComfyUI if it runs
348
+ 2. Go to the ComfyUI root folder, open CMD there and run:
349
+ - `python_embeded\python.exe -m pip uninstall -y opencv-python opencv-contrib-python opencv-python-headless`
350
+ - `python_embeded\python.exe -m pip install opencv-python==4.7.0.72`
351
+ 3. That's it!
352
+
353
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/uploads/reactor-w-controlnet.png?raw=true" alt="reactor+controlnet" />
354
+
355
+ ### **V. "ModuleNotFoundError: No module named 'basicsr'" or "subprocess-exited-with-error" during future-0.18.3 installation**
356
+
357
+ - Download https://github.com/Gourieff/Assets/raw/main/comfyui-reactor-node/future-0.18.3-py3-none-any.whl<br>
358
+ - Put it to ComfyUI root And run:
359
+
360
+ python_embeded\python.exe -m pip install future-0.18.3-py3-none-any.whl
361
+
362
+ - Then:
363
+
364
+ python_embeded\python.exe -m pip install basicsr
365
+
366
+ ### **VI. "fatal: fetch-pack: invalid index-pack output" when you try to `git clone` the repository"**
367
+
368
+ Try to clone with `--depth=1` (last commit only):
369
+
370
+ git clone --depth=1 https://github.com/Gourieff/ComfyUI-ReActor
371
+
372
+ Then retrieve the rest (if you need):
373
+
374
+ git fetch --unshallow
375
+
376
+ ## Updating
377
+
378
+ Just put .bat or .sh script from this [Repo](https://github.com/Gourieff/sd-webui-extensions-updater) to the `ComfyUI\custom_nodes` directory and run it when you need to check for updates
379
+
380
+ ### Disclaimer
381
+
382
+ This software is meant to be a productive contribution to the rapidly growing AI-generated media industry. It will help artists with tasks such as animating a custom character or using the character as a model for clothing etc.
383
+
384
+ The developers of this software are aware of its possible unethical applications and are committed to take preventative measures against them. We will continue to develop this project in the positive direction while adhering to law and ethics.
385
+
386
+ Users of this software are expected to use this software responsibly while abiding the local law. If face of a real person is being used, users are suggested to get consent from the concerned person and clearly mention that it is a deepfake when posting content online. **Developers and Contributors of this software are not responsible for actions of end-users.**
387
+
388
+ By using this extension you are agree not to create any content that:
389
+ - violates any laws;
390
+ - causes any harm to a person or persons;
391
+ - propagates (spreads) any information (both public or personal) or images (both public or personal) which could be meant for harm;
392
+ - spreads misinformation;
393
+ - targets vulnerable groups of people.
394
+
395
+ This software utilizes the pre-trained models `buffalo_l` and `inswapper_128.onnx`, which are provided by [InsightFace](https://github.com/deepinsight/insightface/). These models are included under the following conditions:
396
+
397
+ [From insighface license](https://github.com/deepinsight/insightface/tree/master/python-package): The InsightFace’s pre-trained models are available for non-commercial research purposes only. This includes both auto-downloading models and manually downloaded models.
398
+
399
+ Users of this software must strictly adhere to these conditions of use. The developers and maintainers of this software are not responsible for any misuse of InsightFace’s pre-trained models.
400
+
401
+ Please note that if you intend to use this software for any commercial purposes, you will need to train your own models or find models that can be used commercially.
402
+
403
+ ### Models Hashsum
404
+
405
+ #### Safe-to-use models have the following hash:
406
+
407
+ inswapper_128.onnx
408
+ ```
409
+ MD5:a3a155b90354160350efd66fed6b3d80
410
+ SHA256:e4a3f08c753cb72d04e10aa0f7dbe3deebbf39567d4ead6dce08e98aa49e16af
411
+ ```
412
+
413
+ 1k3d68.onnx
414
+
415
+ ```
416
+ MD5:6fb94fcdb0055e3638bf9158e6a108f4
417
+ SHA256:df5c06b8a0c12e422b2ed8947b8869faa4105387f199c477af038aa01f9a45cc
418
+ ```
419
+
420
+ 2d106det.onnx
421
+
422
+ ```
423
+ MD5:a3613ef9eb3662b4ef88eb90db1fcf26
424
+ SHA256:f001b856447c413801ef5c42091ed0cd516fcd21f2d6b79635b1e733a7109dbf
425
+ ```
426
+
427
+ det_10g.onnx
428
+
429
+ ```
430
+ MD5:4c10eef5c9e168357a16fdd580fa8371
431
+ SHA256:5838f7fe053675b1c7a08b633df49e7af5495cee0493c7dcf6697200b85b5b91
432
+ ```
433
+
434
+ genderage.onnx
435
+
436
+ ```
437
+ MD5:81c77ba87ab38163b0dec6b26f8e2af2
438
+ SHA256:4fde69b1c810857b88c64a335084f1c3fe8f01246c9a191b48c7bb756d6652fb
439
+ ```
440
+
441
+ w600k_r50.onnx
442
+
443
+ ```
444
+ MD5:80248d427976241cbd1343889ed132b3
445
+ SHA256:4c06341c33c2ca1f86781dab0e829f88ad5b64be9fba56e56bc9ebdefc619e43
446
+ ```
447
+
448
+ **Please check hashsums if you download these models from unverified (or untrusted) sources**
449
+
450
+ <a name="credits">
451
+
452
+ ## Thanks and Credits
453
+
454
+ <details>
455
+ <summary><a>Click to expand</a></summary>
456
+
457
+ <br>
458
+
459
+ |file|source|license|
460
+ |----|------|-------|
461
+ |[buffalo_l.zip](https://huggingface.co/datasets/Gourieff/ReActor/blob/main/models/buffalo_l.zip) | [DeepInsight](https://github.com/deepinsight/insightface) | ![license](https://img.shields.io/badge/license-non_commercial-red) |
462
+ | [codeformer-v0.1.0.pth](https://huggingface.co/datasets/Gourieff/ReActor/blob/main/models/facerestore_models/codeformer-v0.1.0.pth) | [sczhou](https://github.com/sczhou/CodeFormer) | ![license](https://img.shields.io/badge/license-non_commercial-red) |
463
+ | [GFPGANv1.3.pth](https://huggingface.co/datasets/Gourieff/ReActor/blob/main/models/facerestore_models/GFPGANv1.3.pth) | [TencentARC](https://github.com/TencentARC/GFPGAN) | ![license](https://img.shields.io/badge/license-Apache_2.0-green.svg) |
464
+ | [GFPGANv1.4.pth](https://huggingface.co/datasets/Gourieff/ReActor/blob/main/models/facerestore_models/GFPGANv1.4.pth) | [TencentARC](https://github.com/TencentARC/GFPGAN) | ![license](https://img.shields.io/badge/license-Apache_2.0-green.svg) |
465
+ | [inswapper_128.onnx](https://github.com/facefusion/facefusion-assets/releases/download/models/inswapper_128.onnx) | [DeepInsight](https://github.com/deepinsight/insightface) | ![license](https://img.shields.io/badge/license-non_commercial-red) |
466
+ | [inswapper_128_fp16.onnx](https://github.com/facefusion/facefusion-assets/releases/download/models/inswapper_128_fp16.onnx) | [Hillobar](https://github.com/Hillobar/Rope) | ![license](https://img.shields.io/badge/license-non_commercial-red) |
467
+
468
+ [BasicSR](https://github.com/XPixelGroup/BasicSR) - [@XPixelGroup](https://github.com/XPixelGroup) <br>
469
+ [facexlib](https://github.com/xinntao/facexlib) - [@xinntao](https://github.com/xinntao) <br>
470
+
471
+ [@s0md3v](https://github.com/s0md3v), [@henryruhs](https://github.com/henryruhs) - the original Roop App <br>
472
+ [@ssitu](https://github.com/ssitu) - the first version of [ComfyUI_roop](https://github.com/ssitu/ComfyUI_roop) extension
473
+
474
+ </details>
475
+
476
+ <a name="note">
477
+
478
+ ### Note!
479
+
480
+ **If you encounter any errors when you use ReActor Node - don't rush to open an issue, first try to remove current ReActor node in your workflow and add it again**
481
+
482
+ **ReActor Node gets updates from time to time, new functions appear and old node can work with errors or not work at all**
custom_nodes/ComfyUI-ReActor/README_RU.md ADDED
@@ -0,0 +1,491 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div align="center">
2
+
3
+ <img src="https://github.com/Gourieff/Assets/raw/main/sd-webui-reactor/ReActor_logo_NEW_RU.png?raw=true" alt="logo" width="180px"/>
4
+
5
+ ![Version](https://img.shields.io/badge/версия_нода-0.5.2_beta2-green?style=for-the-badge&labelColor=darkgreen)
6
+
7
+ <!--<sup>
8
+ <font color=brightred>
9
+
10
+ ## !!! [Важные изменения](#latestupdate) !!!<br>Не забудьте добавить Нод заново в существующие воркфлоу
11
+
12
+ </font>
13
+ </sup>-->
14
+
15
+ <a href="https://boosty.to/artgourieff" target="_blank">
16
+ <img src="https://lovemet.ru/img/boosty.jpg" width="108" alt="Поддержать проект на Boosty"/>
17
+ <br>
18
+ <sup>
19
+ Поддержать проект
20
+ </sup>
21
+ </a>
22
+
23
+ <hr>
24
+
25
+ [![Commit activity](https://img.shields.io/github/commit-activity/t/Gourieff/ComfyUI-ReActor/main?cacheSeconds=0)](https://github.com/Gourieff/ComfyUI-ReActor/commits/main)
26
+ ![Last commit](https://img.shields.io/github/last-commit/Gourieff/ComfyUI-ReActor/main?cacheSeconds=0)
27
+ [![Opened issues](https://img.shields.io/github/issues/Gourieff/ComfyUI-ReActor?color=red)](https://github.com/Gourieff/ComfyUI-ReActor/issues?cacheSeconds=0)
28
+ [![Closed issues](https://img.shields.io/github/issues-closed/Gourieff/ComfyUI-ReActor?color=green&cacheSeconds=0)](https://github.com/Gourieff/ComfyUI-ReActor/issues?q=is%3Aissue+state%3Aclosed)
29
+ ![License](https://img.shields.io/github/license/Gourieff/ComfyUI-ReActor)
30
+
31
+ [English](/README.md) | Русский
32
+
33
+ # ReActor Nodes для ComfyUI<br><sub><sup>-=Безопасно для работы | SFW-Friendly=-</sup></sub>
34
+
35
+ </div>
36
+
37
+ ### Ноды (nodes) для быстрой и простой замены лиц на любых изображениях для работы с ComfyUI, основан на [ранее заблокированном РеАкторе](https://github.com/Gourieff/comfyui-reactor-node) - теперь имеется встроенный NSFW-детектор, исключающий замену лиц на изображениях с контентом 18+
38
+
39
+ > Используя данное ПО, вы понимаете и принимаете [ответственность](#disclaimer)
40
+
41
+ <div align="center">
42
+
43
+ ---
44
+ [**Что нового**](#latestupdate) | [**Установка**](#installation) | [**Использование**](#usage) | [**Устранение проблем**](#troubleshooting) | [**Обновление**](#updating) | [**Ответственность**](#disclaimer) | [**Благодарности**](#credits) | [**Заметка**](#note)
45
+
46
+ ---
47
+
48
+ </div>
49
+
50
+ <a name="latestupdate">
51
+
52
+ ## Что нового в последнем обновлении
53
+
54
+ ### 0.5.2 <sub><sup>BETA1</sup></sub>
55
+
56
+ - Поддержка моделей ReSwapper. Несмотря на то, что Inswapper по-прежнему даёт лучшее сходство, но ReSwapper развивается - спасибо @somanchiu https://github.com/somanchiu/ReSwapper за эти модели и проект ReSwapper! Это хороший шаг для Сообщества в создании альтернативы Инсваппера!
57
+
58
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.5.2-whatsnew-03.jpg?raw=true" alt="0.5.2-whatsnew-03" width="100%"/>
59
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.5.2-whatsnew-04.jpg?raw=true" alt="0.5.2-whatsnew-04" width="100%"/>
60
+
61
+ Скачать модели ReSwapper можно отсюда:
62
+ https://huggingface.co/datasets/Gourieff/ReActor/tree/main/models
63
+ Сохраните их в директорию "models/reswapper".
64
+
65
+ ### 0.5.2 <sub><sup>ALPHA3</sup></sub>
66
+
67
+ - NSFW-детектор, чтобы не нарушать [правила GitHub](https://docs.github.com/en/site-policy/acceptable-use-policies/github-misinformation-and-disinformation#synthetic--manipulated-media-tools)
68
+
69
+ ### 0.5.2 <sub><sup>ALPHA2</sup></sub>
70
+
71
+ - Небольшие исправления
72
+
73
+ ### 0.5.2 <sub><sup>ALPHA1</sup></sub>
74
+
75
+ - Новый нод "Unload ReActor Models" - полезен для сложных воркфлоу, когда вам нужно освободить ОЗУ, занятую РеАктором
76
+
77
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.5.2-whatsnew-01.jpg?raw=true" alt="0.5.2-whatsnew-01" width="100%"/>
78
+
79
+ - Поддержка ORT CoreML and ROCM EPs, достаточно установить ту версию onnxruntime, которая соответствует вашему GPU
80
+ - Некоторые улучшения скрипта установки для поддержки последней версии ORT-GPU
81
+
82
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.5.2-whatsnew-02.jpg?raw=true" alt="0.5.2-whatsnew-02" width="50%"/>
83
+
84
+ <details>
85
+ <summary><a>Предыдущие версии</a></summary>
86
+
87
+ ### 0.5.1
88
+
89
+ - Поддержка м��делей восстановления лиц GPEN 1024/2048 (доступны в датасете на HF https://huggingface.co/datasets/Gourieff/ReActor/tree/main/models/facerestore_models)
90
+ - Нод ReActorFaceBoost - попытка улучшить качество заменённых лиц. Идея состоит в том, чтобы восстановить и увеличить заменённое лицо (в соответствии с параметром `face_size` модели реставрации) ДО того, как лицо будет вставлено в целевое изображения (через алгоритмы инсваппера), больше информации [здесь (PR#321)](https://github.com/Gourieff/comfyui-reactor-node/pull/321)
91
+
92
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.5.1-whatsnew-01.jpg?raw=true" alt="0.5.1-whatsnew-01" width="100%"/>
93
+
94
+ [Полноразмерное демо-превью](https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.5.1-whatsnew-02.png)
95
+
96
+ - Сортировка моделей лиц по алфавиту
97
+ - Множество исправлений и улучшений
98
+
99
+ ### [0.5.0 <sub><sup>BETA4</sup></sub>](https://github.com/Gourieff/comfyui-reactor-node/releases/tag/v0.5.0)
100
+
101
+ - Поддержка библиотеки Spandrel при работе с GFPGAN
102
+
103
+ ### 0.5.0 <sub><sup>BETA3</sup></sub>
104
+
105
+ - Исправления: "RAM issue", "No detection" для MaskingHelper
106
+
107
+ ### 0.5.0 <sub><sup>BETA2</sup></sub>
108
+
109
+ - Появилась возможность строить смешанные модели лиц из пачки уже имеющихся моделей - добавьте для этого нод "Make Face Model Batch" в свой воркфлоу и загрузите несколько моделей через ноды "Load Face Model"
110
+ - Огромный буст производительности модуля анализа изображений! 10-кратный прирост скорости! Работа с видео теперь в удовольствие!
111
+
112
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.5.0-whatsnew-05.png?raw=true" alt="0.5.0-whatsnew-05" width="100%"/>
113
+
114
+ ### 0.5.0 <sub><sup>BETA1</sup></sub>
115
+
116
+ - Добавлен выход SWAPPED_FACE для нода Masking Helper
117
+ - FIX: Удалён пустой A-канал на выходе IMAGE нода Masking Helper (вызывавший ошибки с некоторым нодами)
118
+
119
+ ### 0.5.0 <sub><sup>ALPHA1</sup></sub>
120
+
121
+ - Нод ReActorBuildFaceModel получил выход "face_model" для отправки совмещенной модели лиц непосредственно в основной Нод:
122
+
123
+ Basic workflow [💾](https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/workflows/ReActor--Build-Blended-Face-Model--v2.json)
124
+
125
+ - Функции маски лица теперь доступна и в версии для Комфи, просто добавьте нод "ReActorMaskHelper" в воркфлоу и соедините узлы, как показано ниже:
126
+
127
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.5.0-whatsnew-01.jpg?raw=true" alt="0.5.0-whatsnew-01" width="100%"/>
128
+
129
+ Если модель "face_yolov8m.pt" у вас отсутствует - можете скачать её [отсюда](https://huggingface.co/datasets/Gourieff/ReActor/blob/main/models/detection/bbox/face_yolov8m.pt) и положить в папку "ComfyUI\models\ultralytics\bbox"
130
+ <br>
131
+ То же самое и с ["sam_vit_b_01ec64.pth"](https://huggingface.co/datasets/Gourieff/ReActor/blob/main/models/sams/sam_vit_b_01ec64.pth) - скачайте (если отсутствует) и положите в папку "ComfyUI\models\sams";
132
+
133
+ Данный нод поможет вам получить куда более аккуратный результат при замене лиц:
134
+
135
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.5.0-whatsnew-02.jpg?raw=true" alt="0.5.0-whatsnew-02" width="100%"/>
136
+
137
+ - Нод ReActorImageDublicator - полезен тем, кто создает видео, помогает продублировать одиночное изображение в несколько копий, чтобы использовать их, к примеру, с VAE энкодером:
138
+
139
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.5.0-whatsnew-03.jpg?raw=true" alt="0.5.0-whatsnew-03" width="100%"/>
140
+
141
+ - ReActorFaceSwapOpt (упрощенная версия основного нода) + нод ReActorOptions для установки дополнительных опций, как (новые) "отдельный порядок лиц для input/source". Да! Теперь можно установить любой порядок "чтения" индекса лиц на изображении, в т.ч. ��т большего к меньшему (по умолчанию)!
142
+
143
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.5.0-whatsnew-04.jpg?raw=true" alt="0.5.0-whatsnew-04" width="100%"/>
144
+
145
+ - Небольшое улучшение скорости анализа целевых изображений (input)
146
+
147
+ ### [0.4.2](https://github.com/Gourieff/comfyui-reactor-node/releases/tag/v0.4.2)
148
+
149
+ - Добавлена поддержка GPEN-BFR-512 и RestoreFormer_Plus_Plus моделей восстановления лиц
150
+
151
+ Скачать можно здесь: https://huggingface.co/datasets/Gourieff/ReActor/tree/main/models/facerestore_models
152
+ <br>Добавьте модели в папку `ComfyUI\models\facerestore_models`
153
+
154
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.4.2-whatsnew-04.jpg?raw=true" alt="0.4.2-whatsnew-04" width="100%"/>
155
+
156
+ - По многочисленным просьбам появилась возможность строить смешанные модели лиц и в ComfyUI тоже и использовать их с нодом "Load Face Model" Node или в SD WebUI;
157
+
158
+ Экспериментируйте и создавайте новые лица или совмещайте разные лица нужного вам персонажа, чтобы добиться лучшей точности и схожести с оригиналом!
159
+
160
+ Достаточно добавить нод "Make Image Batch" (ImpactPack) на вход нового нода РеАктора и загрузить в пачку необходимые вам изображения для построения смешанной модели:
161
+
162
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.4.2-whatsnew-01.jpg?raw=true" alt="0.4.2-whatsnew-01" width="100%"/>
163
+
164
+ Пример результата (на основе лиц 4-х актрис создано новое лицо):
165
+
166
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.4.2-whatsnew-02.jpg?raw=true" alt="0.4.2-whatsnew-02" width="75%"/>
167
+
168
+ Базовый воркфлоу [💾](https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/workflows/ReActor--Build-Blended-Face-Model--v1.json)
169
+
170
+ ### [0.4.1](https://github.com/Gourieff/comfyui-reactor-node/releases/tag/v0.4.1)
171
+
172
+ - Поддержка CUDA 12 - не забудьте запустить (Windows) `install.bat` или (Linux/MacOS) `install.py` для используемого Python окружения или попробуйте установить ORT-GPU для CU12 вручную (https://onnxruntime.ai/docs/install/#install-onnx-runtime-gpu-cuda-12x)
173
+ - Исправление Issue https://github.com/Gourieff/comfyui-reactor-node/issues/173
174
+
175
+ - Отдельный Нод для восстаноления лиц (FR https://github.com/Gourieff/comfyui-reactor-node/issues/191), располагается внутри меню ReActor (нод RestoreFace)
176
+ - (Windows) Установка зависимостей теперь может быть выполнена в Python из PATH ОС
177
+ - Разные исправления и улучшения
178
+
179
+ - Face Restore Visibility и CodeFormer Weight (Fidelity) теперь доступны; не забудьте заново добавить Нод в ваших существующих воркфлоу
180
+
181
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.4.1-whatsnew-01.jpg?raw=true" alt="0.4.1-whatsnew-01" width="100%"/>
182
+
183
+ ### [0.4.0](https://github.com/Gourieff/comfyui-reactor-node/releases/tag/v0.4.0)
184
+
185
+ - Вход "input_image" теперь идёт первым, это даёт возможность корректного байпаса, а также это правильно с точки зрения расположения входов (главный вход - первый);
186
+ - Теперь можно сохранять модели лиц в качестве файлов "safetensors" (`ComfyUI\models\reactor\faces`) и загружать их в ReActor, реализуя разные сценарии использования, а также храня супер легкие модели лиц, которые вы чаще всего используете:
187
+
188
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.4.0-whatsnew-01.jpg?raw=true" alt="0.4.0-whatsnew-01" width="100%"/>
189
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.4.0-whatsnew-02.jpg?raw=true" alt="0.4.0-whatsnew-02" width="100%"/>
190
+
191
+ - Возможность сохранять модели лиц напрямую из изображения:
192
+
193
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.4.0-whatsnew-03.jpg?raw=true" alt="0.4.0-whatsnew-03" width="50%"/>
194
+
195
+ - Оба входа опциональны, присоедините один из них в соответствии с вашим воркфлоу; если присо��денены оба - вход `image` имеет приоритет.
196
+ - Различные исправления, делающие это расширение лучше.
197
+
198
+ Спасибо всем, кто находит ошибки, предлагает новые функции и поддерживает данный проект!
199
+
200
+ </details>
201
+
202
+ <a name="installation">
203
+
204
+ ## Установка
205
+
206
+ <details>
207
+ <summary>SD WebUI: <a href="https://github.com/AUTOMATIC1111/stable-diffusion-webui/">AUTOMATIC1111</a> или <a href="https://github.com/vladmandic/automatic">SD.Next</a></summary>
208
+
209
+ 1. Закройте (остановите) SD-WebUI Сервер, если запущен
210
+ 2. (Для пользователей Windows):
211
+ - Установите [Visual Studio 2022](https://visualstudio.microsoft.com/downloads/) (Например, версию Community - этот шаг нужен для правильной компиляции библиотеки Insightface)
212
+ - ИЛИ только [VS C++ Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/), выберите "Desktop Development with C++" в разделе "Workloads -> Desktop & Mobile"
213
+ - ИЛИ если же вы не хотите устанавливать что-либо из вышеуказанного - выполните [данные шаги (раздел. I)](#insightfacebuild)
214
+ 3. Перейдите в `extensions\sd-webui-comfyui\ComfyUI\custom_nodes`
215
+ 4. Откройте Консоль или Терминал и выполните `git clone https://github.com/Gourieff/ComfyUI-ReActor`
216
+ 5. Перейдите в корневую директорию SD WebUI, откройте Консоль или Терминал и выполните (для пользователей Windows)`.\venv\Scripts\activate` или (для пользователей Linux/MacOS)`venv/bin/activate`
217
+ 6. `python -m pip install -U pip`
218
+ 7. `cd extensions\sd-webui-comfyui\ComfyUI\custom_nodes\ComfyUI-ReActor`
219
+ 8. `python install.py`
220
+ 9. Пожалуйста, дождитесь полного завершения установки
221
+ 10. (Начиная с версии 0.3.0) Скачайте дополнительные модели восстановления лиц (по ссылке ниже) и сохраните их в папку `extensions\sd-webui-comfyui\ComfyUI\models\facerestore_models`:<br>
222
+ https://huggingface.co/datasets/Gourieff/ReActor/tree/main/models/facerestore_models
223
+ 11. Запустите SD WebUI и проверьте консоль на сообщение, что ReActor Node работает:
224
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/uploads/console_status_running.jpg?raw=true" alt="console_status_running" width="759"/>
225
+
226
+ 12. Перейдите во вкладку ComfyUI и найдите там ReActor Node внутри меню `ReActor` или через поиск:
227
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/uploads/webui-demo.png?raw=true" alt="webui-demo" width="100%"/>
228
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/uploads/search-demo.png?raw=true" alt="webui-demo" width="1043"/>
229
+
230
+ </details>
231
+
232
+ <details>
233
+ <summary>Портативная версия <a href="https://github.com/comfyanonymous/ComfyUI">ComfyUI</a> для Windows</summary>
234
+
235
+ 1. Сделайте следующее:
236
+ - Установите [Visual Studio 2022](https://visualstudio.microsoft.com/downloads/) (Например, версию Community - этот шаг нужен для правильной компиляции библиотеки Insightface)
237
+ - ИЛИ только [VS C++ Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/), выберите "Desktop Development with C++" в разделе "Workloads -> Desktop & Mobile"
238
+ - ИЛИ если же вы не хотите устанавливать что-либо из вышеуказанного - выполните [данные шаги (раздел. I)](#insightfacebuild)
239
+ 2. Выберите из двух вариантов:
240
+ - (ComfyUI Manager) Откройте ComfyUI Manager, нажвите "Install Custom Nodes", введите "ReActor" в поле "Search" и далее нажмите "Install". После того, как ComfyUI завершит установку, перезагрузите сервер.
241
+ - (Вручную) Перейдите в `ComfyUI\custom_nodes`, откройте Консоль и выполните `git clone https://github.com/Gourieff/ComfyUI-ReActor`
242
+ 3. Перейдите `ComfyUI\custom_nodes\ComfyUI-ReActor` и запустите `install.bat`, дождитесь окончания установки
243
+ 4. Если модель "face_yolov8m.pt" у вас отсутствует - можете скачать её [отсюда](https://huggingface.co/datasets/Gourieff/ReActor/blob/main/models/detection/bbox/face_yolov8m.pt) и положить в папку "ComfyUI\models\ultralytics\bbox"
244
+ <br>
245
+ То ��е самое и с "Sams" моделями, скачайте одну или обе [отсюда](https://huggingface.co/datasets/Gourieff/ReActor/tree/main/models/sams) - и положите в папку "ComfyUI\models\sams"
246
+ 5. Запустите ComfyUI и найдите ReActor Node внутри меню `ReActor` или через поиск
247
+
248
+ </details>
249
+
250
+ <a name="usage">
251
+
252
+ ## Использование
253
+
254
+ Вы можете найти ноды ReActor внутри меню `ReActor` или через поиск (достаточно ввести "ReActor" в поисковой строке)
255
+
256
+ Список нодов:
257
+ - ••• Main Nodes •••
258
+ - ReActorFaceSwap (Основной нод)
259
+ - ReActorFaceSwapOpt (Основной нод с доп. входом Options)
260
+ - ReActorOptions (Опции для ReActorFaceSwapOpt)
261
+ - ReActorFaceBoost (Нод Face Booster)
262
+ - ReActorMaskHelper (Masking Helper)
263
+ - ••• Operations with Face Models •••
264
+ - ReActorSaveFaceModel (Save Face Model)
265
+ - ReActorLoadFaceModel (Load Face Model)
266
+ - ReActorBuildFaceModel (Build Blended Face Model)
267
+ - ReActorMakeFaceModelBatch (Make Face Model Batch)
268
+ - ••• Additional Nodes •••
269
+ - ReActorRestoreFace (Face Restoration)
270
+ - ReActorImageDublicator (Dublicate one Image to Images List)
271
+ - ImageRGBA2RGB (Convert RGBA to RGB)
272
+
273
+ Соедините все необходимые слоты (slots) и запустите очередь (query).
274
+
275
+ ### Входы основного Нода
276
+
277
+ - `input_image` - это изображение, на котором надо поменять лицо или лица (целевое изображение, аналог "target image" в версии для SD WebUI);
278
+ - Поддерживаемые ноды: "Load Image", "Load Video" или любые другие ноды предоставляющие изображение в качестве выхода;
279
+ - `source_image` - это изображение с лицом или лицами для замены (изображение-источник, аналог "source image" в версии для SD WebUI);
280
+ - Поддерживаемые ноды: "Load Image" или любые другие ноды с выходом Image(s);
281
+ - `face_model` - это вход для выхода с нода "Load Face Model" или другого нода ReActor для загрузки модели лица (face model или face embedding), которое вы создали ранее через нод "Save Face Model";
282
+ - Поддерживаемые ноды: "Load Face Model", "Build Blended Face Model";
283
+
284
+ ### Выходы основного Нода
285
+
286
+ - `IMAGE` - выход с готовым изображением (результатом);
287
+ - Поддерживаемые ноды: любые ноды с изображением на входе;
288
+ - `FACE_MODEL` - выход, предоставляющий модель лица, построенную в ходе замены;
289
+ - Поддерживаемые ноды: "Save Face Model", "ReActor", "Make Face Model Batch";
290
+
291
+ ### Восстановление лиц
292
+
293
+ Начиная с версии 0.3.0 ReActor Node имеет встроенное восстановление лиц.<br>Скачайте нужные вам модели (см. инструкцию по [Установке](#installation)) и выберите одну из них, чтобы улучшить качество финального лица.
294
+
295
+ ### Индексы Лиц (Face Indexes)
296
+
297
+ По умолчанию ReActor определяет лица на изображении в порядке от "большого" к "малому".<br>Вы можете поменять эту опцию, используя нод ReActorFaceSwapOpt вместе с ReActorOptions.
298
+
299
+ Если вам нужно заменить определенное лицо, вы можете указать индекс для исходного (source, с лицом) и входного (input, где будет замена лица) изображений.
300
+
301
+ Индекс первого обнаруженного лица - 0.
302
+
303
+ Вы можете задать индексы в том порядке, который вам нужен.<br>
304
+ Например: 0,1,2 (для Source); 1,0,2 (для Input).<br>Это означает, что: второе лицо из Input (индекс = 1) будет заменено первым лицом из Source (индекс = 0) и так далее.
305
+
306
+ ### Определение Пола
307
+
308
+ Вы можете обозначить, какой пол нужно определять на изображении.<br>
309
+ ReActor заменит только то лицо, которое удовлетворяет заданному условию.
310
+
311
+ ### Модели Лиц
312
+ Начиная с версии 0.4.0, вы можете сохранять модели лиц как файлы "safetensors" (хранятся в папке `ComfyUI\models\reactor\faces`) и загружать их в ReActor, реализуя разные сценарии использования, а также храня супер легкие модели лиц, которые вы чаще всего используете.
313
+
314
+ Чтобы новые модели появились в списке моделей нода "Load Face Model" - обновите страницу of с ComfyUI.<br>
315
+ (Рекомендую использовать ComfyUI Manager - иначе ваше воркфлоу может быть потеряно после перезагрузки страницы, если вы не сохранили его).
316
+
317
+ <a name="troubleshooting">
318
+
319
+ ## Устранение проблем
320
+
321
+ <a name="insightfacebuild">
322
+
323
+ ### **I. (Для пользователей Windows) Если вы до сих пор не можете установить пакет Insightface по каким-то причинам или же просто не желаете устанавливать Visual Studio или VS C++ Build Tools - сделайте следующее:**
324
+
325
+ 1. (ComfyUI Portable) Находясь в корневой директории, проверьте версию Python:<br>запустите CMD и выполните `python_embeded\python.exe -V`<br>Вы должны увидеть версию или 3.10, или 3.11, или 3.12
326
+ 2. Скачайте готовый пакет Insightface [для версии 3.10](https://github.com/Gourieff/sd-webui-reactor/raw/main/example/insightface-0.7.3-cp310-cp310-win_amd64.whl) или [для 3.11](https://github.com/Gourieff/Assets/raw/main/Insightface/insightface-0.7.3-cp311-cp311-win_amd64.whl) (если на предыдущем шаге вы увидели 3.11) или [для 3.12](https://github.com/Gourieff/Assets/raw/main/Insightface/insightface-0.7.3-cp312-cp312-win_amd64.whl) (если на предыдущем шаге вы увидели 3.12) и сохраните его в корневую директорию stable-diffusion-webui (A1111 или SD.Next) - туда, где лежит файл "webui-user.bat" -ИЛИ- в корневую директорию ComfyUI, если вы используете ComfyUI Portable
327
+ 3. Из корневой директории запустите:
328
+ - (SD WebUI) CMD и `.\venv\Scripts\activate`
329
+ - (ComfyUI Portable) CMD
330
+ 4. Обновите PIP:
331
+ - (SD WebUI) `python -m pip install -U pip`
332
+ - (ComfyUI Portable) `python_embeded\python.exe -m pip install -U pip`
333
+ 5. Затем установите Insightface:
334
+ - (SD WebUI) `pip install insightface-0.7.3-cp310-cp310-win_amd64.whl` (для 3.10) или `pip install insightface-0.7.3-cp311-cp311-win_amd64.whl` (для 3.11) или `pip install insightface-0.7.3-cp312-cp312-win_amd64.whl` (for 3.12)
335
+ - (ComfyUI Portable) `python_embeded\python.exe -m pip install insightface-0.7.3-cp310-cp310-win_amd64.whl` (для 3.10) или `python_embeded\python.exe -m pip install insightface-0.7.3-cp311-cp311-win_amd64.whl` (для 3.11) или `python_embeded\python.exe -m pip install insightface-0.7.3-cp312-cp312-win_amd64.whl` (for 3.12)
336
+ 6. Готово!
337
+
338
+ ### **II. "AttributeError: 'NoneType' object has no attribute 'get'"**
339
+
340
+ Эта ошибка появляется, если что-то не так с файлом модели `inswapper_128.onnx`
341
+
342
+ Скачайте вручную по ссылке [отсюда](https://github.com/facefusion/facefusion-assets/releases/download/models/inswapper_128.onnx)
343
+ и сохраните в директорию `ComfyUI\models\insightface`, заменив имеющийся файл
344
+
345
+ ### **III. "reactor.execute() got an unexpected keyword argument 'reference_image'"**
346
+
347
+ Это означает, что поменялось обозначение входных точек (input points) всвязи с последним обновлением<br>
348
+ Удалите из вашего рабочего пространства имеющийся ReActor Node и добавьте его снова
349
+
350
+ ### **IV. ControlNet Aux Node IMPORT failed - при использовании совместно с нодом ReActor**
351
+
352
+ 1. Закройте или остановите ComfyUI сервер, если он запущен
353
+ 2. Перейдите в корневую папку ComfyUI, откройте консоль CMD и выполните следующее:
354
+ - `python_embeded\python.exe -m pip uninstall -y opencv-python opencv-contrib-python opencv-python-headless`
355
+ - `python_embeded\python.exe -m pip install opencv-python==4.7.0.72`
356
+ 3. Готово!
357
+
358
+ <img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/uploads/reactor-w-controlnet.png?raw=true" alt="reactor+controlnet" />
359
+
360
+ ### **V. "ModuleNotFoundError: No module named 'basicsr'" или "subprocess-exited-with-error" при установке пакета future-0.18.3**
361
+
362
+ - Скачайте https://github.com/Gourieff/Assets/raw/main/comfyui-reactor-node/future-0.18.3-py3-none-any.whl<br>
363
+ - Скопируйте файл в корневую папку ComfyUI и выполните в консоли:
364
+
365
+ python_embeded\python.exe -m pip install future-0.18.3-py3-none-any.whl
366
+
367
+ - Затем:
368
+
369
+ python_embeded\python.exe -m pip install basicsr
370
+
371
+ ### **VI. "fatal: fetch-pack: invalid index-pack output" при исполнении команды `git clone`"**
372
+
373
+ Попробуйте клонировать репозиторий с параметром `--depth=1` (только последний коммит):
374
+
375
+ git clone --depth=1 https://github.com/Gourieff/ComfyUI-ReActor
376
+
377
+ Затем вытяните оставшееся (если требуется):
378
+
379
+ git fetch --unshallow
380
+
381
+ <a name="updating">
382
+
383
+ ## Обновление
384
+
385
+ Положите .bat или .sh скрипт из [данного репозитория](https://github.com/Gourieff/sd-webui-extensions-updater) в папку `ComfyUI\custom_nodes` и запустите, когда желаете обновить ComfyUI и Ноды
386
+
387
+ <a name="disclaimer">
388
+
389
+ ## Ответственность
390
+
391
+ Это программное обеспечение призвано стать продуктивным вкладом в быстрорастущую медиаиндустрию на основе генеративных сетей и искусственного интеллекта. Данное ПО поможет художникам в решении таких задач, как анимация собственного персонажа или использование персонажа в качестве модели для одежды и т.д.
392
+
393
+ Разработчики этого программного обеспечения осведомлены о возможных неэтичных применениях и обязуются принять против этого превентивные меры. Мы продолжим развивать этот проект в позитивном направлении, придерживаясь закона и этики.
394
+
395
+ Подразумевается, что пользователи этого программного обеспечения будут использовать его ответственно, соблюдая локальное законодательство. Если используется лицо реального человека, пользователь обязан получить согласие заинтересованного лица и четко указать, что это дипфейк при размещении контента в Интернете. **Разработчики и Со-авторы данного программного обеспечения не несут ответственности за действия конечных пользователей.**
396
+
397
+ Используя данное расширение, вы соглашаетесь не создавать материалы, которые:
398
+ - нарушают какие-либо действующие законы тех или иных государств или международных организаций;
399
+ - причиняют какой-либо вред человеку или лицам;
400
+ - пропагандируют любую информацию (как общедоступную, так и личную) или изображения (как общедоступные, так и личные), которые могут быть направлены на причинение вреда;
401
+ - используются для распространения дезинформации;
402
+ - нацелены на уязвимые группы людей.
403
+
404
+ Данное программное обеспечение использует предварительно обученные модели `buffalo_l` и `inswapper_128.onnx`, представленные разработчиками [InsightFace](https://github.com/deepinsight/insightface/). Эти модели распространяются при следующих условиях:
405
+
406
+ [Перевод из текста лицензии insighface](https://github.com/deepinsight/insightface/tree/master/python-package): Предварительно обученные модели InsightFace доступны только для некоммерческих исследовательских целей. Сюда входят как модели с автоматической загрузкой, так и модели, загруженные вручную.
407
+
408
+ Пользователи данного программного обеспечения должны строго соблюдать данные условия использования. Разработчики и Со-авторы данного программного продукта не несут ответственности за неправильное использование предварительн�� обученных моделей InsightFace.
409
+
410
+ Обратите внимание: если вы собираетесь использовать это программное обеспечение в каких-либо коммерческих целях, вам необходимо будет обучить свои собственные модели или найти модели, которые можно использовать в коммерческих целях.
411
+
412
+ ### Хэш файлов моделей
413
+
414
+ #### Безопасные для использования модели имеют следующий хэш:
415
+
416
+ inswapper_128.onnx
417
+ ```
418
+ MD5:a3a155b90354160350efd66fed6b3d80
419
+ SHA256:e4a3f08c753cb72d04e10aa0f7dbe3deebbf39567d4ead6dce08e98aa49e16af
420
+ ```
421
+
422
+ 1k3d68.onnx
423
+
424
+ ```
425
+ MD5:6fb94fcdb0055e3638bf9158e6a108f4
426
+ SHA256:df5c06b8a0c12e422b2ed8947b8869faa4105387f199c477af038aa01f9a45cc
427
+ ```
428
+
429
+ 2d106det.onnx
430
+
431
+ ```
432
+ MD5:a3613ef9eb3662b4ef88eb90db1fcf26
433
+ SHA256:f001b856447c413801ef5c42091ed0cd516fcd21f2d6b79635b1e733a7109dbf
434
+ ```
435
+
436
+ det_10g.onnx
437
+
438
+ ```
439
+ MD5:4c10eef5c9e168357a16fdd580fa8371
440
+ SHA256:5838f7fe053675b1c7a08b633df49e7af5495cee0493c7dcf6697200b85b5b91
441
+ ```
442
+
443
+ genderage.onnx
444
+
445
+ ```
446
+ MD5:81c77ba87ab38163b0dec6b26f8e2af2
447
+ SHA256:4fde69b1c810857b88c64a335084f1c3fe8f01246c9a191b48c7bb756d6652fb
448
+ ```
449
+
450
+ w600k_r50.onnx
451
+
452
+ ```
453
+ MD5:80248d427976241cbd1343889ed132b3
454
+ SHA256:4c06341c33c2ca1f86781dab0e829f88ad5b64be9fba56e56bc9ebdefc619e43
455
+ ```
456
+
457
+ **Пожалуйста, сравните хэш, если вы скачиваете данные модели из непроверенных источников**
458
+
459
+ <a name="credits">
460
+
461
+ ## Благодарности и авторы компонентов
462
+
463
+ <details>
464
+ <summary><a>Нажмите, чтобы посмотреть</a></summary>
465
+
466
+ <br>
467
+
468
+ |файл|источник|лицензия|
469
+ |----|--------|--------|
470
+ |[buffalo_l.zip](https://huggingface.co/datasets/Gourieff/ReActor/blob/main/models/buffalo_l.zip) | [DeepInsight](https://github.com/deepinsight/insightface) | ![license](https://img.shields.io/badge/license-non_commercial-red) |
471
+ | [codeformer-v0.1.0.pth](https://huggingface.co/datasets/Gourieff/ReActor/blob/main/models/facerestore_models/codeformer-v0.1.0.pth) | [sczhou](https://github.com/sczhou/CodeFormer) | ![license](https://img.shields.io/badge/license-non_commercial-red) |
472
+ | [GFPGANv1.3.pth](https://huggingface.co/datasets/Gourieff/ReActor/blob/main/models/facerestore_models/GFPGANv1.3.pth) | [TencentARC](https://github.com/TencentARC/GFPGAN) | ![license](https://img.shields.io/badge/license-Apache_2.0-green.svg) |
473
+ | [GFPGANv1.4.pth](https://huggingface.co/datasets/Gourieff/ReActor/blob/main/models/facerestore_models/GFPGANv1.4.pth) | [TencentARC](https://github.com/TencentARC/GFPGAN) | ![license](https://img.shields.io/badge/license-Apache_2.0-green.svg) |
474
+ | [inswapper_128.onnx](https://github.com/facefusion/facefusion-assets/releases/download/models/inswapper_128.onnx) | [DeepInsight](https://github.com/deepinsight/insightface) | ![license](https://img.shields.io/badge/license-non_commercial-red) |
475
+ | [inswapper_128_fp16.onnx](https://github.com/facefusion/facefusion-assets/releases/download/models/inswapper_128_fp16.onnx) | [Hillobar](https://github.com/Hillobar/Rope) | ![license](https://img.shields.io/badge/license-non_commercial-red) |
476
+
477
+ [BasicSR](https://github.com/XPixelGroup/BasicSR) - [@XPixelGroup](https://github.com/XPixelGroup) <br>
478
+ [facexlib](https://github.com/xinntao/facexlib) - [@xinntao](https://github.com/xinntao) <br>
479
+
480
+ [@s0md3v](https://github.com/s0md3v), [@henryruhs](https://github.com/henryruhs) - оригинальное приложение Roop <br>
481
+ [@ssitu](https://github.com/ssitu) - первая версия расширения с поддержкой ComfyUI [ComfyUI_roop](https://github.com/ssitu/ComfyUI_roop)
482
+
483
+ </details>
484
+
485
+ <a name="note">
486
+
487
+ ### Обратите внимание!
488
+
489
+ **Если у вас возникли какие-либо ошибки при очередном использовании Нода ReActor - не торопитесь открывать Issue, для начала попробуйте удалить текущий Нод из вашего рабочего пространства и добавить его снова**
490
+
491
+ **ReActor Node периодически получает обновления, появляются новые функции, из-за чего имеющийся Нод может работать с ошибками или не работать вовсе**
custom_nodes/ComfyUI-ReActor/__init__.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ import os
3
+
4
+ repo_dir = os.path.dirname(os.path.realpath(__file__))
5
+ sys.path.insert(0, repo_dir)
6
+ original_modules = sys.modules.copy()
7
+
8
+ # Place aside existing modules if using a1111 web ui
9
+ modules_used = [
10
+ "modules",
11
+ "modules.images",
12
+ "modules.processing",
13
+ "modules.scripts_postprocessing",
14
+ "modules.scripts",
15
+ "modules.shared",
16
+ ]
17
+ original_webui_modules = {}
18
+ for module in modules_used:
19
+ if module in sys.modules:
20
+ original_webui_modules[module] = sys.modules.pop(module)
21
+
22
+ # Proceed with node setup
23
+ from .nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
24
+
25
+ __all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS"]
26
+
27
+ # Clean up imports
28
+ # Remove repo directory from path
29
+ sys.path.remove(repo_dir)
30
+ # Remove any new modules
31
+ modules_to_remove = []
32
+ for module in sys.modules:
33
+ if module not in original_modules and not module.startswith("google.protobuf") and not module.startswith("onnx") and not module.startswith("cv2"):
34
+ modules_to_remove.append(module)
35
+ for module in modules_to_remove:
36
+ del sys.modules[module]
37
+
38
+ # Restore original modules
39
+ sys.modules.update(original_webui_modules)
custom_nodes/ComfyUI-ReActor/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (1.71 kB). View file
 
custom_nodes/ComfyUI-ReActor/__pycache__/nodes.cpython-311.pyc ADDED
Binary file (57.2 kB). View file
 
custom_nodes/ComfyUI-ReActor/__pycache__/reactor_patcher.cpython-311.pyc ADDED
Binary file (10 kB). View file
 
custom_nodes/ComfyUI-ReActor/__pycache__/reactor_utils.cpython-311.pyc ADDED
Binary file (15.4 kB). View file
 
custom_nodes/ComfyUI-ReActor/install.bat ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @echo off
2
+ setlocal enabledelayedexpansion
3
+
4
+ :: Try to use embedded python first
5
+ if exist ..\..\..\python_embeded\python.exe (
6
+ :: Use the embedded python
7
+ set PYTHON=..\..\..\python_embeded\python.exe
8
+ ) else (
9
+ :: Embedded python not found, check for python in the PATH
10
+ for /f "tokens=* USEBACKQ" %%F in (`python --version 2^>^&1`) do (
11
+ set PYTHON_VERSION=%%F
12
+ )
13
+ if errorlevel 1 (
14
+ echo I couldn't find an embedded version of Python, nor one in the Windows PATH. Please install manually.
15
+ pause
16
+ exit /b 1
17
+ ) else (
18
+ :: Use python from the PATH (if it's the right version and the user agrees)
19
+ echo I couldn't find an embedded version of Python, but I did find !PYTHON_VERSION! in your Windows PATH.
20
+ echo Would you like to proceed with the install using that version? (Y/N^)
21
+ set /p USE_PYTHON=
22
+ if /i "!USE_PYTHON!"=="Y" (
23
+ set PYTHON=python
24
+ ) else (
25
+ echo Okay. Please install manually.
26
+ pause
27
+ exit /b 1
28
+ )
29
+ )
30
+ )
31
+
32
+ :: Install the package
33
+ echo Installing...
34
+ %PYTHON% install.py
35
+ echo Done^!
36
+
37
+ @pause
custom_nodes/ComfyUI-ReActor/install.py ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import warnings
2
+ warnings.filterwarnings("ignore", category=DeprecationWarning)
3
+
4
+ import subprocess
5
+ import os, sys
6
+ try:
7
+ from pkg_resources import get_distribution as distributions
8
+ except:
9
+ from importlib_metadata import distributions
10
+ from tqdm import tqdm
11
+ import urllib.request
12
+ from packaging import version as pv
13
+ try:
14
+ from folder_paths import models_dir
15
+ except:
16
+ from pathlib import Path
17
+ models_dir = os.path.join(Path(__file__).parents[2], "models")
18
+
19
+ sys.path.append(os.path.dirname(os.path.realpath(__file__)))
20
+
21
+ req_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), "requirements.txt")
22
+
23
+ model_url = "https://huggingface.co/datasets/Gourieff/ReActor/resolve/main/models/inswapper_128.onnx"
24
+ model_name = os.path.basename(model_url)
25
+ models_dir_path = os.path.join(models_dir, "insightface")
26
+ model_path = os.path.join(models_dir_path, model_name)
27
+
28
+ def run_pip(*args):
29
+ subprocess.run([sys.executable, "-m", "pip", "install", "--no-warn-script-location", *args])
30
+
31
+ def is_installed (
32
+ package: str, version: str = None, strict: bool = True
33
+ ):
34
+ has_package = None
35
+ try:
36
+ has_package = distributions(package)
37
+ if has_package is not None:
38
+ if version is not None:
39
+ installed_version = has_package.version
40
+ if (installed_version != version and strict == True) or (pv.parse(installed_version) < pv.parse(version) and strict == False):
41
+ return False
42
+ else:
43
+ return True
44
+ else:
45
+ return True
46
+ else:
47
+ return False
48
+ except Exception as e:
49
+ print(f"Status: {e}")
50
+ return False
51
+
52
+ def download(url, path, name):
53
+ request = urllib.request.urlopen(url)
54
+ total = int(request.headers.get('Content-Length', 0))
55
+ with tqdm(total=total, desc=f'[ReActor] Downloading {name} to {path}', unit='B', unit_scale=True, unit_divisor=1024) as progress:
56
+ urllib.request.urlretrieve(url, path, reporthook=lambda count, block_size, total_size: progress.update(block_size))
57
+
58
+ if not os.path.exists(models_dir_path):
59
+ os.makedirs(models_dir_path)
60
+
61
+ if not os.path.exists(model_path):
62
+ download(model_url, model_path, model_name)
63
+
64
+ with open(req_file) as file:
65
+ try:
66
+ ort = "onnxruntime-gpu"
67
+ import torch
68
+ cuda_version = None
69
+ if torch.cuda.is_available():
70
+ cuda_version = torch.version.cuda
71
+ print(f"CUDA {cuda_version}")
72
+ elif torch.backends.mps.is_available() or hasattr(torch,'dml') or hasattr(torch,'privateuseone'):
73
+ ort = "onnxruntime"
74
+ if cuda_version is not None and float(cuda_version)>=12 and torch.torch_version.__version__ <= "2.2.0": # CU12.x and torch<=2.2.0
75
+ print(f"Torch: {torch.torch_version.__version__}")
76
+ if not is_installed(ort,"1.17.0",False):
77
+ run_pip(ort,"--extra-index-url", "https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/")
78
+ elif cuda_version is not None and float(cuda_version)>=12 and torch.torch_version.__version__ >= "2.4.0" : # CU12.x and latest torch
79
+ print(f"Torch: {torch.torch_version.__version__}")
80
+ if not is_installed(ort,"1.20.1",False): # latest ort-gpu
81
+ run_pip(ort,"-U")
82
+ elif not is_installed(ort,"1.16.1",False):
83
+ run_pip(ort, "-U")
84
+ except Exception as e:
85
+ print(e)
86
+ print(f"Warning: Failed to install {ort}, ReActor will not work.")
87
+ raise e
88
+ strict = True
89
+ for package in file:
90
+ package_version = None
91
+ try:
92
+ package = package.strip()
93
+ if "==" in package:
94
+ package_version = package.split('==')[1]
95
+ elif ">=" in package:
96
+ package_version = package.split('>=')[1]
97
+ strict = False
98
+ if not is_installed(package,package_version,strict):
99
+ run_pip(package)
100
+ except Exception as e:
101
+ print(e)
102
+ print(f"Warning: Failed to install {package}, ReActor will not work.")
103
+ raise e
104
+ print("Ok")
custom_nodes/ComfyUI-ReActor/modules/__init__.py ADDED
File without changes
custom_nodes/ComfyUI-ReActor/modules/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (188 Bytes). View file
 
custom_nodes/ComfyUI-ReActor/modules/__pycache__/processing.cpython-311.pyc ADDED
Binary file (1.36 kB). View file
 
custom_nodes/ComfyUI-ReActor/modules/__pycache__/scripts.cpython-311.pyc ADDED
Binary file (996 Bytes). View file
 
custom_nodes/ComfyUI-ReActor/modules/__pycache__/scripts_postprocessing.cpython-311.pyc ADDED
Binary file (202 Bytes). View file
 
custom_nodes/ComfyUI-ReActor/modules/__pycache__/shared.cpython-311.pyc ADDED
Binary file (1.05 kB). View file
 
custom_nodes/ComfyUI-ReActor/modules/images.py ADDED
File without changes
custom_nodes/ComfyUI-ReActor/modules/processing.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class StableDiffusionProcessing:
2
+
3
+ def __init__(self, init_imgs):
4
+ self.init_images = init_imgs
5
+ self.width = init_imgs[0].width
6
+ self.height = init_imgs[0].height
7
+ self.extra_generation_params = {}
8
+
9
+
10
+ class StableDiffusionProcessingImg2Img(StableDiffusionProcessing):
11
+
12
+ def __init__(self, init_img):
13
+ super().__init__(init_img)
custom_nodes/ComfyUI-ReActor/modules/scripts.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+
4
+ class Script:
5
+ pass
6
+
7
+
8
+ def basedir():
9
+ return os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
10
+
11
+
12
+ class PostprocessImageArgs:
13
+ pass
custom_nodes/ComfyUI-ReActor/modules/scripts_postprocessing.py ADDED
File without changes
custom_nodes/ComfyUI-ReActor/modules/shared.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class Options:
2
+ img2img_background_color = "#ffffff" # Set to white for now
3
+
4
+
5
+ class State:
6
+ interrupted = False
7
+
8
+ def begin(self):
9
+ pass
10
+
11
+ def end(self):
12
+ pass
13
+
14
+
15
+ opts = Options()
16
+ state = State()
17
+ cmd_opts = None
18
+ sd_upscalers = []
19
+ face_restorers = []
custom_nodes/ComfyUI-ReActor/nodes.py ADDED
@@ -0,0 +1,1275 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os, glob, sys
2
+ import logging
3
+
4
+ import torch
5
+ import torch.nn.functional as torchfn
6
+ from torchvision.transforms.functional import normalize
7
+ from torchvision.ops import masks_to_boxes
8
+
9
+ import numpy as np
10
+ import cv2
11
+ import math
12
+ from typing import List
13
+ from PIL import Image
14
+ from scipy import stats
15
+ from insightface.app.common import Face
16
+ from segment_anything import sam_model_registry
17
+
18
+ from modules.processing import StableDiffusionProcessingImg2Img
19
+ from modules.shared import state
20
+ # from comfy_extras.chainner_models import model_loading
21
+ import comfy.model_management as model_management
22
+ import comfy.utils
23
+ import folder_paths
24
+
25
+ import scripts.reactor_version
26
+ from r_chainner import model_loading
27
+ from scripts.reactor_faceswap import (
28
+ FaceSwapScript,
29
+ get_models,
30
+ get_current_faces_model,
31
+ analyze_faces,
32
+ half_det_size,
33
+ providers
34
+ )
35
+ from scripts.reactor_swapper import (
36
+ unload_all_models,
37
+ )
38
+ from scripts.reactor_logger import logger
39
+ from reactor_utils import (
40
+ batch_tensor_to_pil,
41
+ batched_pil_to_tensor,
42
+ tensor_to_pil,
43
+ img2tensor,
44
+ tensor2img,
45
+ save_face_model,
46
+ load_face_model,
47
+ download,
48
+ set_ort_session,
49
+ prepare_cropped_face,
50
+ normalize_cropped_face,
51
+ add_folder_path_and_extensions,
52
+ rgba2rgb_tensor
53
+ )
54
+ from reactor_patcher import apply_patch
55
+ from r_facelib.utils.face_restoration_helper import FaceRestoreHelper
56
+ from r_basicsr.utils.registry import ARCH_REGISTRY
57
+ import scripts.r_archs.codeformer_arch
58
+ import scripts.r_masking.subcore as subcore
59
+ import scripts.r_masking.core as core
60
+ import scripts.r_masking.segs as masking_segs
61
+
62
+ import scripts.reactor_sfw as sfw
63
+
64
+
65
+ models_dir = folder_paths.models_dir
66
+ REACTOR_MODELS_PATH = os.path.join(models_dir, "reactor")
67
+ FACE_MODELS_PATH = os.path.join(REACTOR_MODELS_PATH, "faces")
68
+ NSFWDET_MODEL_PATH = os.path.join(models_dir, "nsfw_detector","vit-base-nsfw-detector")
69
+
70
+ if not os.path.exists(REACTOR_MODELS_PATH):
71
+ os.makedirs(REACTOR_MODELS_PATH)
72
+ if not os.path.exists(FACE_MODELS_PATH):
73
+ os.makedirs(FACE_MODELS_PATH)
74
+
75
+ if not os.path.exists(NSFWDET_MODEL_PATH):
76
+ os.makedirs(NSFWDET_MODEL_PATH)
77
+ nd_urls = [
78
+ "https://huggingface.co/AdamCodd/vit-base-nsfw-detector/resolve/main/config.json",
79
+ "https://huggingface.co/AdamCodd/vit-base-nsfw-detector/resolve/main/confusion_matrix.png",
80
+ "https://huggingface.co/AdamCodd/vit-base-nsfw-detector/resolve/main/model.safetensors",
81
+ "https://huggingface.co/AdamCodd/vit-base-nsfw-detector/resolve/main/preprocessor_config.json",
82
+ ]
83
+ for model_url in nd_urls:
84
+ model_name = os.path.basename(model_url)
85
+ model_path = os.path.join(NSFWDET_MODEL_PATH, model_name)
86
+ download(model_url, model_path, model_name)
87
+
88
+ dir_facerestore_models = os.path.join(models_dir, "facerestore_models")
89
+ os.makedirs(dir_facerestore_models, exist_ok=True)
90
+ folder_paths.folder_names_and_paths["facerestore_models"] = ([dir_facerestore_models], folder_paths.supported_pt_extensions)
91
+
92
+ BLENDED_FACE_MODEL = None
93
+ FACE_SIZE: int = 512
94
+ FACE_HELPER = None
95
+
96
+ if "ultralytics" not in folder_paths.folder_names_and_paths:
97
+ add_folder_path_and_extensions("ultralytics_bbox", [os.path.join(models_dir, "ultralytics", "bbox")], folder_paths.supported_pt_extensions)
98
+ add_folder_path_and_extensions("ultralytics_segm", [os.path.join(models_dir, "ultralytics", "segm")], folder_paths.supported_pt_extensions)
99
+ add_folder_path_and_extensions("ultralytics", [os.path.join(models_dir, "ultralytics")], folder_paths.supported_pt_extensions)
100
+ if "sams" not in folder_paths.folder_names_and_paths:
101
+ add_folder_path_and_extensions("sams", [os.path.join(models_dir, "sams")], folder_paths.supported_pt_extensions)
102
+
103
+ def get_facemodels():
104
+ models_path = os.path.join(FACE_MODELS_PATH, "*")
105
+ models = glob.glob(models_path)
106
+ models = [x for x in models if x.endswith(".safetensors")]
107
+ return models
108
+
109
+ def get_restorers():
110
+ models_path = os.path.join(models_dir, "facerestore_models/*")
111
+ models = glob.glob(models_path)
112
+ models = [x for x in models if (x.endswith(".pth") or x.endswith(".onnx"))]
113
+ if len(models) == 0:
114
+ fr_urls = [
115
+ "https://huggingface.co/datasets/Gourieff/ReActor/resolve/main/models/facerestore_models/GFPGANv1.3.pth",
116
+ "https://huggingface.co/datasets/Gourieff/ReActor/resolve/main/models/facerestore_models/GFPGANv1.4.pth",
117
+ "https://huggingface.co/datasets/Gourieff/ReActor/resolve/main/models/facerestore_models/codeformer-v0.1.0.pth",
118
+ "https://huggingface.co/datasets/Gourieff/ReActor/resolve/main/models/facerestore_models/GPEN-BFR-512.onnx",
119
+ ]
120
+ for model_url in fr_urls:
121
+ model_name = os.path.basename(model_url)
122
+ model_path = os.path.join(dir_facerestore_models, model_name)
123
+ download(model_url, model_path, model_name)
124
+ models = glob.glob(models_path)
125
+ models = [x for x in models if (x.endswith(".pth") or x.endswith(".onnx"))]
126
+ return models
127
+
128
+ def get_model_names(get_models):
129
+ models = get_models()
130
+ names = []
131
+ for x in models:
132
+ names.append(os.path.basename(x))
133
+ names.sort(key=str.lower)
134
+ names.insert(0, "none")
135
+ return names
136
+
137
+ def model_names():
138
+ models = get_models()
139
+ return {os.path.basename(x): x for x in models}
140
+
141
+
142
+ class reactor:
143
+ @classmethod
144
+ def INPUT_TYPES(s):
145
+ return {
146
+ "required": {
147
+ "enabled": ("BOOLEAN", {"default": True, "label_off": "OFF", "label_on": "ON"}),
148
+ "input_image": ("IMAGE",),
149
+ "swap_model": (list(model_names().keys()),),
150
+ "facedetection": (["retinaface_resnet50", "retinaface_mobile0.25", "YOLOv5l", "YOLOv5n"],),
151
+ "face_restore_model": (get_model_names(get_restorers),),
152
+ "face_restore_visibility": ("FLOAT", {"default": 1, "min": 0.1, "max": 1, "step": 0.05}),
153
+ "codeformer_weight": ("FLOAT", {"default": 0.5, "min": 0.0, "max": 1, "step": 0.05}),
154
+ "detect_gender_input": (["no","female","male"], {"default": "no"}),
155
+ "detect_gender_source": (["no","female","male"], {"default": "no"}),
156
+ "input_faces_index": ("STRING", {"default": "0"}),
157
+ "source_faces_index": ("STRING", {"default": "0"}),
158
+ "console_log_level": ([0, 1, 2], {"default": 1}),
159
+ },
160
+ "optional": {
161
+ "source_image": ("IMAGE",),
162
+ "face_model": ("FACE_MODEL",),
163
+ "face_boost": ("FACE_BOOST",),
164
+ },
165
+ "hidden": {"faces_order": "FACES_ORDER"},
166
+ }
167
+
168
+ RETURN_TYPES = ("IMAGE","FACE_MODEL")
169
+ FUNCTION = "execute"
170
+ CATEGORY = "🌌 ReActor"
171
+
172
+ def __init__(self):
173
+ # self.face_helper = None
174
+ self.faces_order = ["large-small", "large-small"]
175
+ # self.face_size = FACE_SIZE
176
+ self.face_boost_enabled = False
177
+ self.restore = True
178
+ self.boost_model = None
179
+ self.interpolation = "Bicubic"
180
+ self.boost_model_visibility = 1
181
+ self.boost_cf_weight = 0.5
182
+
183
+ def restore_face(
184
+ self,
185
+ input_image,
186
+ face_restore_model,
187
+ face_restore_visibility,
188
+ codeformer_weight,
189
+ facedetection,
190
+ ):
191
+
192
+ result = input_image
193
+
194
+ if face_restore_model != "none" and not model_management.processing_interrupted():
195
+
196
+ global FACE_SIZE, FACE_HELPER
197
+
198
+ self.face_helper = FACE_HELPER
199
+
200
+ faceSize = 512
201
+ if "1024" in face_restore_model.lower():
202
+ faceSize = 1024
203
+ elif "2048" in face_restore_model.lower():
204
+ faceSize = 2048
205
+
206
+ logger.status(f"Restoring with {face_restore_model} | Face Size is set to {faceSize}")
207
+
208
+ model_path = folder_paths.get_full_path("facerestore_models", face_restore_model)
209
+
210
+ device = model_management.get_torch_device()
211
+
212
+ if "codeformer" in face_restore_model.lower():
213
+
214
+ codeformer_net = ARCH_REGISTRY.get("CodeFormer")(
215
+ dim_embd=512,
216
+ codebook_size=1024,
217
+ n_head=8,
218
+ n_layers=9,
219
+ connect_list=["32", "64", "128", "256"],
220
+ ).to(device)
221
+ checkpoint = torch.load(model_path)["params_ema"]
222
+ codeformer_net.load_state_dict(checkpoint)
223
+ facerestore_model = codeformer_net.eval()
224
+
225
+ elif ".onnx" in face_restore_model:
226
+
227
+ ort_session = set_ort_session(model_path, providers=providers)
228
+ ort_session_inputs = {}
229
+ facerestore_model = ort_session
230
+
231
+ else:
232
+
233
+ sd = comfy.utils.load_torch_file(model_path, safe_load=True)
234
+ facerestore_model = model_loading.load_state_dict(sd).eval()
235
+ facerestore_model.to(device)
236
+
237
+ if faceSize != FACE_SIZE or self.face_helper is None:
238
+ self.face_helper = FaceRestoreHelper(1, face_size=faceSize, crop_ratio=(1, 1), det_model=facedetection, save_ext='png', use_parse=True, device=device)
239
+ FACE_SIZE = faceSize
240
+ FACE_HELPER = self.face_helper
241
+
242
+ image_np = 255. * result.numpy()
243
+
244
+ total_images = image_np.shape[0]
245
+
246
+ out_images = []
247
+
248
+ for i in range(total_images):
249
+
250
+ if total_images > 1:
251
+ logger.status(f"Restoring {i+1}")
252
+
253
+ cur_image_np = image_np[i,:, :, ::-1]
254
+
255
+ original_resolution = cur_image_np.shape[0:2]
256
+
257
+ if facerestore_model is None or self.face_helper is None:
258
+ return result
259
+
260
+ self.face_helper.clean_all()
261
+ self.face_helper.read_image(cur_image_np)
262
+ self.face_helper.get_face_landmarks_5(only_center_face=False, resize=640, eye_dist_threshold=5)
263
+ self.face_helper.align_warp_face()
264
+
265
+ restored_face = None
266
+
267
+ for idx, cropped_face in enumerate(self.face_helper.cropped_faces):
268
+
269
+ # if ".pth" in face_restore_model:
270
+ cropped_face_t = img2tensor(cropped_face / 255., bgr2rgb=True, float32=True)
271
+ normalize(cropped_face_t, (0.5, 0.5, 0.5), (0.5, 0.5, 0.5), inplace=True)
272
+ cropped_face_t = cropped_face_t.unsqueeze(0).to(device)
273
+
274
+ try:
275
+
276
+ with torch.no_grad():
277
+
278
+ if ".onnx" in face_restore_model: # ONNX models
279
+
280
+ for ort_session_input in ort_session.get_inputs():
281
+ if ort_session_input.name == "input":
282
+ cropped_face_prep = prepare_cropped_face(cropped_face)
283
+ ort_session_inputs[ort_session_input.name] = cropped_face_prep
284
+ if ort_session_input.name == "weight":
285
+ weight = np.array([ 1 ], dtype = np.double)
286
+ ort_session_inputs[ort_session_input.name] = weight
287
+
288
+ output = ort_session.run(None, ort_session_inputs)[0][0]
289
+ restored_face = normalize_cropped_face(output)
290
+
291
+ else: # PTH models
292
+
293
+ output = facerestore_model(cropped_face_t, w=codeformer_weight)[0] if "codeformer" in face_restore_model.lower() else facerestore_model(cropped_face_t)[0]
294
+ restored_face = tensor2img(output, rgb2bgr=True, min_max=(-1, 1))
295
+
296
+ del output
297
+ torch.cuda.empty_cache()
298
+
299
+ except Exception as error:
300
+
301
+ print(f"\tFailed inference: {error}", file=sys.stderr)
302
+ restored_face = tensor2img(cropped_face_t, rgb2bgr=True, min_max=(-1, 1))
303
+
304
+ if face_restore_visibility < 1:
305
+ restored_face = cropped_face * (1 - face_restore_visibility) + restored_face * face_restore_visibility
306
+
307
+ restored_face = restored_face.astype("uint8")
308
+ self.face_helper.add_restored_face(restored_face)
309
+
310
+ self.face_helper.get_inverse_affine(None)
311
+
312
+ restored_img = self.face_helper.paste_faces_to_input_image()
313
+ restored_img = restored_img[:, :, ::-1]
314
+
315
+ if original_resolution != restored_img.shape[0:2]:
316
+ restored_img = cv2.resize(restored_img, (0, 0), fx=original_resolution[1]/restored_img.shape[1], fy=original_resolution[0]/restored_img.shape[0], interpolation=cv2.INTER_AREA)
317
+
318
+ self.face_helper.clean_all()
319
+
320
+ # out_images[i] = restored_img
321
+ out_images.append(restored_img)
322
+
323
+ if state.interrupted or model_management.processing_interrupted():
324
+ logger.status("Interrupted by User")
325
+ return input_image
326
+
327
+ restored_img_np = np.array(out_images).astype(np.float32) / 255.0
328
+ restored_img_tensor = torch.from_numpy(restored_img_np)
329
+
330
+ result = restored_img_tensor
331
+
332
+ return result
333
+
334
+ def execute(self, enabled, input_image, swap_model, detect_gender_source, detect_gender_input, source_faces_index, input_faces_index, console_log_level, face_restore_model,face_restore_visibility, codeformer_weight, facedetection, source_image=None, face_model=None, faces_order=None, face_boost=None):
335
+
336
+ if face_boost is not None:
337
+ self.face_boost_enabled = face_boost["enabled"]
338
+ self.boost_model = face_boost["boost_model"]
339
+ self.interpolation = face_boost["interpolation"]
340
+ self.boost_model_visibility = face_boost["visibility"]
341
+ self.boost_cf_weight = face_boost["codeformer_weight"]
342
+ self.restore = face_boost["restore_with_main_after"]
343
+ else:
344
+ self.face_boost_enabled = False
345
+
346
+ if faces_order is None:
347
+ faces_order = self.faces_order
348
+
349
+ apply_patch(console_log_level)
350
+
351
+ if not enabled:
352
+ return (input_image,face_model)
353
+ elif source_image is None and face_model is None:
354
+ logger.error("Please provide 'source_image' or `face_model`")
355
+ return (input_image,face_model)
356
+
357
+ if face_model == "none":
358
+ face_model = None
359
+
360
+ script = FaceSwapScript()
361
+ pil_images = batch_tensor_to_pil(input_image)
362
+
363
+ # NSFW checker
364
+ logger.status("Checking for any unsafe content")
365
+ pil_images_sfw = []
366
+ tmp_img = "reactor_tmp.png"
367
+ for img in pil_images:
368
+ if state.interrupted or model_management.processing_interrupted():
369
+ logger.status("Interrupted by User")
370
+ break
371
+ img.save(tmp_img)
372
+ if not sfw.nsfw_image(tmp_img, NSFWDET_MODEL_PATH):
373
+ pil_images_sfw.append(img)
374
+ if os.path.exists(tmp_img):
375
+ os.remove(tmp_img)
376
+ pil_images = pil_images_sfw
377
+ # # #
378
+
379
+ if len(pil_images) > 0:
380
+
381
+ if source_image is not None:
382
+ source = tensor_to_pil(source_image)
383
+ else:
384
+ source = None
385
+ p = StableDiffusionProcessingImg2Img(pil_images)
386
+ script.process(
387
+ p=p,
388
+ img=source,
389
+ enable=True,
390
+ source_faces_index=source_faces_index,
391
+ faces_index=input_faces_index,
392
+ model=swap_model,
393
+ swap_in_source=True,
394
+ swap_in_generated=True,
395
+ gender_source=detect_gender_source,
396
+ gender_target=detect_gender_input,
397
+ face_model=face_model,
398
+ faces_order=faces_order,
399
+ # face boost:
400
+ face_boost_enabled=self.face_boost_enabled,
401
+ face_restore_model=self.boost_model,
402
+ face_restore_visibility=self.boost_model_visibility,
403
+ codeformer_weight=self.boost_cf_weight,
404
+ interpolation=self.interpolation,
405
+ )
406
+ result = batched_pil_to_tensor(p.init_images)
407
+
408
+ if face_model is None:
409
+ current_face_model = get_current_faces_model()
410
+ face_model_to_provide = current_face_model[0] if (current_face_model is not None and len(current_face_model) > 0) else face_model
411
+ else:
412
+ face_model_to_provide = face_model
413
+
414
+ if self.restore or not self.face_boost_enabled:
415
+ result = reactor.restore_face(self,result,face_restore_model,face_restore_visibility,codeformer_weight,facedetection)
416
+
417
+ else:
418
+ image_black = Image.new("RGB", (512, 512))
419
+ result = batched_pil_to_tensor([image_black])
420
+ face_model_to_provide = None
421
+
422
+ return (result,face_model_to_provide)
423
+
424
+
425
+ class ReActorPlusOpt:
426
+ @classmethod
427
+ def INPUT_TYPES(s):
428
+ return {
429
+ "required": {
430
+ "enabled": ("BOOLEAN", {"default": True, "label_off": "OFF", "label_on": "ON"}),
431
+ "input_image": ("IMAGE",),
432
+ "swap_model": (list(model_names().keys()),),
433
+ "facedetection": (["retinaface_resnet50", "retinaface_mobile0.25", "YOLOv5l", "YOLOv5n"],),
434
+ "face_restore_model": (get_model_names(get_restorers),),
435
+ "face_restore_visibility": ("FLOAT", {"default": 1, "min": 0.1, "max": 1, "step": 0.05}),
436
+ "codeformer_weight": ("FLOAT", {"default": 0.5, "min": 0.0, "max": 1, "step": 0.05}),
437
+ },
438
+ "optional": {
439
+ "source_image": ("IMAGE",),
440
+ "face_model": ("FACE_MODEL",),
441
+ "options": ("OPTIONS",),
442
+ "face_boost": ("FACE_BOOST",),
443
+ }
444
+ }
445
+
446
+ RETURN_TYPES = ("IMAGE","FACE_MODEL")
447
+ FUNCTION = "execute"
448
+ CATEGORY = "🌌 ReActor"
449
+
450
+ def __init__(self):
451
+ # self.face_helper = None
452
+ self.faces_order = ["large-small", "large-small"]
453
+ self.detect_gender_input = "no"
454
+ self.detect_gender_source = "no"
455
+ self.input_faces_index = "0"
456
+ self.source_faces_index = "0"
457
+ self.console_log_level = 1
458
+ # self.face_size = 512
459
+ self.face_boost_enabled = False
460
+ self.restore = True
461
+ self.boost_model = None
462
+ self.interpolation = "Bicubic"
463
+ self.boost_model_visibility = 1
464
+ self.boost_cf_weight = 0.5
465
+
466
+ def execute(self, enabled, input_image, swap_model, facedetection, face_restore_model, face_restore_visibility, codeformer_weight, source_image=None, face_model=None, options=None, face_boost=None):
467
+
468
+ if options is not None:
469
+ self.faces_order = [options["input_faces_order"], options["source_faces_order"]]
470
+ self.console_log_level = options["console_log_level"]
471
+ self.detect_gender_input = options["detect_gender_input"]
472
+ self.detect_gender_source = options["detect_gender_source"]
473
+ self.input_faces_index = options["input_faces_index"]
474
+ self.source_faces_index = options["source_faces_index"]
475
+
476
+ if face_boost is not None:
477
+ self.face_boost_enabled = face_boost["enabled"]
478
+ self.restore = face_boost["restore_with_main_after"]
479
+ else:
480
+ self.face_boost_enabled = False
481
+
482
+ result = reactor.execute(
483
+ self,enabled,input_image,swap_model,self.detect_gender_source,self.detect_gender_input,self.source_faces_index,self.input_faces_index,self.console_log_level,face_restore_model,face_restore_visibility,codeformer_weight,facedetection,source_image,face_model,self.faces_order, face_boost=face_boost
484
+ )
485
+
486
+ return result
487
+
488
+
489
+ class LoadFaceModel:
490
+ @classmethod
491
+ def INPUT_TYPES(s):
492
+ return {
493
+ "required": {
494
+ "face_model": (get_model_names(get_facemodels),),
495
+ }
496
+ }
497
+
498
+ RETURN_TYPES = ("FACE_MODEL",)
499
+ FUNCTION = "load_model"
500
+ CATEGORY = "🌌 ReActor"
501
+
502
+ def load_model(self, face_model):
503
+ self.face_model = face_model
504
+ self.face_models_path = FACE_MODELS_PATH
505
+ if self.face_model != "none":
506
+ face_model_path = os.path.join(self.face_models_path, self.face_model)
507
+ out = load_face_model(face_model_path)
508
+ else:
509
+ out = None
510
+ return (out, )
511
+
512
+
513
+ class BuildFaceModel:
514
+ def __init__(self):
515
+ self.output_dir = FACE_MODELS_PATH
516
+
517
+ @classmethod
518
+ def INPUT_TYPES(s):
519
+ return {
520
+ "required": {
521
+ "save_mode": ("BOOLEAN", {"default": True, "label_off": "OFF", "label_on": "ON"}),
522
+ "send_only": ("BOOLEAN", {"default": False, "label_off": "NO", "label_on": "YES"}),
523
+ "face_model_name": ("STRING", {"default": "default"}),
524
+ "compute_method": (["Mean", "Median", "Mode"], {"default": "Mean"}),
525
+ },
526
+ "optional": {
527
+ "images": ("IMAGE",),
528
+ "face_models": ("FACE_MODEL",),
529
+ }
530
+ }
531
+
532
+ RETURN_TYPES = ("FACE_MODEL",)
533
+ FUNCTION = "blend_faces"
534
+
535
+ OUTPUT_NODE = True
536
+
537
+ CATEGORY = "🌌 ReActor"
538
+
539
+ def build_face_model(self, image: Image.Image, det_size=(640, 640)):
540
+ logging.StreamHandler.terminator = "\n"
541
+ if image is None:
542
+ error_msg = "Please load an Image"
543
+ logger.error(error_msg)
544
+ return error_msg
545
+ image = cv2.cvtColor(np.array(image), cv2.COLOR_RGB2BGR)
546
+ face_model = analyze_faces(image, det_size)
547
+
548
+ if len(face_model) == 0:
549
+ print("")
550
+ det_size_half = half_det_size(det_size)
551
+ face_model = analyze_faces(image, det_size_half)
552
+ if face_model is not None and len(face_model) > 0:
553
+ print("...........................................................", end=" ")
554
+
555
+ if face_model is not None and len(face_model) > 0:
556
+ return face_model[0]
557
+ else:
558
+ no_face_msg = "No face found, please try another image"
559
+ # logger.error(no_face_msg)
560
+ return no_face_msg
561
+
562
+ def blend_faces(self, save_mode, send_only, face_model_name, compute_method, images=None, face_models=None):
563
+ global BLENDED_FACE_MODEL
564
+ blended_face: Face = BLENDED_FACE_MODEL
565
+
566
+ if send_only and blended_face is None:
567
+ send_only = False
568
+
569
+ if (images is not None or face_models is not None) and not send_only:
570
+
571
+ faces = []
572
+ embeddings = []
573
+
574
+ apply_patch(1)
575
+
576
+ if images is not None:
577
+ images_list: List[Image.Image] = batch_tensor_to_pil(images)
578
+
579
+ n = len(images_list)
580
+
581
+ for i,image in enumerate(images_list):
582
+ logging.StreamHandler.terminator = " "
583
+ logger.status(f"Building Face Model {i+1} of {n}...")
584
+ face = self.build_face_model(image)
585
+ if isinstance(face, str):
586
+ logger.error(f"No faces found in image {i+1}, skipping")
587
+ continue
588
+ else:
589
+ print(f"{int(((i+1)/n)*100)}%")
590
+ faces.append(face)
591
+ embeddings.append(face.embedding)
592
+
593
+ elif face_models is not None:
594
+
595
+ n = len(face_models)
596
+
597
+ for i,face_model in enumerate(face_models):
598
+ logging.StreamHandler.terminator = " "
599
+ logger.status(f"Extracting Face Model {i+1} of {n}...")
600
+ face = face_model
601
+ if isinstance(face, str):
602
+ logger.error(f"No faces found for face_model {i+1}, skipping")
603
+ continue
604
+ else:
605
+ print(f"{int(((i+1)/n)*100)}%")
606
+ faces.append(face)
607
+ embeddings.append(face.embedding)
608
+
609
+ logging.StreamHandler.terminator = "\n"
610
+ if len(faces) > 0:
611
+ # compute_method_name = "Mean" if compute_method == 0 else "Median" if compute_method == 1 else "Mode"
612
+ logger.status(f"Blending with Compute Method '{compute_method}'...")
613
+ blended_embedding = np.mean(embeddings, axis=0) if compute_method == "Mean" else np.median(embeddings, axis=0) if compute_method == "Median" else stats.mode(embeddings, axis=0)[0].astype(np.float32)
614
+ blended_face = Face(
615
+ bbox=faces[0].bbox,
616
+ kps=faces[0].kps,
617
+ det_score=faces[0].det_score,
618
+ landmark_3d_68=faces[0].landmark_3d_68,
619
+ pose=faces[0].pose,
620
+ landmark_2d_106=faces[0].landmark_2d_106,
621
+ embedding=blended_embedding,
622
+ gender=faces[0].gender,
623
+ age=faces[0].age
624
+ )
625
+ if blended_face is not None:
626
+ BLENDED_FACE_MODEL = blended_face
627
+ if save_mode:
628
+ face_model_path = os.path.join(FACE_MODELS_PATH, face_model_name + ".safetensors")
629
+ save_face_model(blended_face,face_model_path)
630
+ # done_msg = f"Face model has been saved to '{face_model_path}'"
631
+ # logger.status(done_msg)
632
+ logger.status("--Done!--")
633
+ # return (blended_face,)
634
+ else:
635
+ no_face_msg = "Something went wrong, please try another set of images"
636
+ logger.error(no_face_msg)
637
+ # return (blended_face,)
638
+ # logger.status("--Done!--")
639
+ if images is None and face_models is None:
640
+ logger.error("Please provide `images` or `face_models`")
641
+ return (blended_face,)
642
+
643
+
644
+ class SaveFaceModel:
645
+ def __init__(self):
646
+ self.output_dir = FACE_MODELS_PATH
647
+
648
+ @classmethod
649
+ def INPUT_TYPES(s):
650
+ return {
651
+ "required": {
652
+ "save_mode": ("BOOLEAN", {"default": True, "label_off": "OFF", "label_on": "ON"}),
653
+ "face_model_name": ("STRING", {"default": "default"}),
654
+ "select_face_index": ("INT", {"default": 0, "min": 0}),
655
+ },
656
+ "optional": {
657
+ "image": ("IMAGE",),
658
+ "face_model": ("FACE_MODEL",),
659
+ }
660
+ }
661
+
662
+ RETURN_TYPES = ()
663
+ FUNCTION = "save_model"
664
+
665
+ OUTPUT_NODE = True
666
+
667
+ CATEGORY = "🌌 ReActor"
668
+
669
+ def save_model(self, save_mode, face_model_name, select_face_index, image=None, face_model=None, det_size=(640, 640)):
670
+ if save_mode and image is not None:
671
+ source = tensor_to_pil(image)
672
+ source = cv2.cvtColor(np.array(source), cv2.COLOR_RGB2BGR)
673
+ apply_patch(1)
674
+ logger.status("Building Face Model...")
675
+ face_model_raw = analyze_faces(source, det_size)
676
+ if len(face_model_raw) == 0:
677
+ det_size_half = half_det_size(det_size)
678
+ face_model_raw = analyze_faces(source, det_size_half)
679
+ try:
680
+ face_model = face_model_raw[select_face_index]
681
+ except:
682
+ logger.error("No face(s) found")
683
+ return face_model_name
684
+ logger.status("--Done!--")
685
+ if save_mode and (face_model != "none" or face_model is not None):
686
+ face_model_path = os.path.join(self.output_dir, face_model_name + ".safetensors")
687
+ save_face_model(face_model,face_model_path)
688
+ if image is None and face_model is None:
689
+ logger.error("Please provide `face_model` or `image`")
690
+ return face_model_name
691
+
692
+
693
+ class RestoreFace:
694
+ @classmethod
695
+ def INPUT_TYPES(s):
696
+ return {
697
+ "required": {
698
+ "image": ("IMAGE",),
699
+ "facedetection": (["retinaface_resnet50", "retinaface_mobile0.25", "YOLOv5l", "YOLOv5n"],),
700
+ "model": (get_model_names(get_restorers),),
701
+ "visibility": ("FLOAT", {"default": 1, "min": 0.0, "max": 1, "step": 0.05}),
702
+ "codeformer_weight": ("FLOAT", {"default": 0.5, "min": 0.0, "max": 1, "step": 0.05}),
703
+ },
704
+ }
705
+
706
+ RETURN_TYPES = ("IMAGE",)
707
+ FUNCTION = "execute"
708
+ CATEGORY = "🌌 ReActor"
709
+
710
+ # def __init__(self):
711
+ # self.face_helper = None
712
+ # self.face_size = 512
713
+
714
+ def execute(self, image, model, visibility, codeformer_weight, facedetection):
715
+ result = reactor.restore_face(self,image,model,visibility,codeformer_weight,facedetection)
716
+ return (result,)
717
+
718
+
719
+ class MaskHelper:
720
+ def __init__(self):
721
+ # self.threshold = 0.5
722
+ # self.dilation = 10
723
+ # self.crop_factor = 3.0
724
+ # self.drop_size = 1
725
+ self.labels = "all"
726
+ self.detailer_hook = None
727
+ self.device_mode = "AUTO"
728
+ self.detection_hint = "center-1"
729
+ # self.sam_dilation = 0
730
+ # self.sam_threshold = 0.93
731
+ # self.bbox_expansion = 0
732
+ # self.mask_hint_threshold = 0.7
733
+ # self.mask_hint_use_negative = "False"
734
+ # self.force_resize_width = 0
735
+ # self.force_resize_height = 0
736
+ # self.resize_behavior = "source_size"
737
+
738
+ @classmethod
739
+ def INPUT_TYPES(s):
740
+ bboxs = ["bbox/"+x for x in folder_paths.get_filename_list("ultralytics_bbox")]
741
+ segms = ["segm/"+x for x in folder_paths.get_filename_list("ultralytics_segm")]
742
+ sam_models = [x for x in folder_paths.get_filename_list("sams") if 'hq' not in x]
743
+ return {
744
+ "required": {
745
+ "image": ("IMAGE",),
746
+ "swapped_image": ("IMAGE",),
747
+ "bbox_model_name": (bboxs + segms, ),
748
+ "bbox_threshold": ("FLOAT", {"default": 0.5, "min": 0.0, "max": 1.0, "step": 0.01}),
749
+ "bbox_dilation": ("INT", {"default": 10, "min": -512, "max": 512, "step": 1}),
750
+ "bbox_crop_factor": ("FLOAT", {"default": 3.0, "min": 1.0, "max": 100, "step": 0.1}),
751
+ "bbox_drop_size": ("INT", {"min": 1, "max": 8192, "step": 1, "default": 10}),
752
+ "sam_model_name": (sam_models, ),
753
+ "sam_dilation": ("INT", {"default": 0, "min": -512, "max": 512, "step": 1}),
754
+ "sam_threshold": ("FLOAT", {"default": 0.93, "min": 0.0, "max": 1.0, "step": 0.01}),
755
+ "bbox_expansion": ("INT", {"default": 0, "min": 0, "max": 1000, "step": 1}),
756
+ "mask_hint_threshold": ("FLOAT", {"default": 0.7, "min": 0.0, "max": 1.0, "step": 0.01}),
757
+ "mask_hint_use_negative": (["False", "Small", "Outter"], ),
758
+ "morphology_operation": (["dilate", "erode", "open", "close"],),
759
+ "morphology_distance": ("INT", {"default": 0, "min": 0, "max": 128, "step": 1}),
760
+ "blur_radius": ("INT", {"default": 9, "min": 0, "max": 48, "step": 1}),
761
+ "sigma_factor": ("FLOAT", {"default": 1.0, "min": 0.01, "max": 3., "step": 0.01}),
762
+ },
763
+ "optional": {
764
+ "mask_optional": ("MASK",),
765
+ }
766
+ }
767
+
768
+ RETURN_TYPES = ("IMAGE","MASK","IMAGE","IMAGE")
769
+ RETURN_NAMES = ("IMAGE","MASK","MASK_PREVIEW","SWAPPED_FACE")
770
+ FUNCTION = "execute"
771
+ CATEGORY = "🌌 ReActor"
772
+
773
+ def execute(self, image, swapped_image, bbox_model_name, bbox_threshold, bbox_dilation, bbox_crop_factor, bbox_drop_size, sam_model_name, sam_dilation, sam_threshold, bbox_expansion, mask_hint_threshold, mask_hint_use_negative, morphology_operation, morphology_distance, blur_radius, sigma_factor, mask_optional=None):
774
+
775
+ # images = [image[i:i + 1, ...] for i in range(image.shape[0])]
776
+
777
+ images = image
778
+
779
+ if mask_optional is None:
780
+
781
+ bbox_model_path = folder_paths.get_full_path("ultralytics", bbox_model_name)
782
+ bbox_model = subcore.load_yolo(bbox_model_path)
783
+ bbox_detector = subcore.UltraBBoxDetector(bbox_model)
784
+
785
+ segs = bbox_detector.detect(images, bbox_threshold, bbox_dilation, bbox_crop_factor, bbox_drop_size, self.detailer_hook)
786
+
787
+ if isinstance(self.labels, list):
788
+ self.labels = str(self.labels[0])
789
+
790
+ if self.labels is not None and self.labels != '':
791
+ self.labels = self.labels.split(',')
792
+ if len(self.labels) > 0:
793
+ segs, _ = masking_segs.filter(segs, self.labels)
794
+ # segs, _ = masking_segs.filter(segs, "all")
795
+
796
+ sam_modelname = folder_paths.get_full_path("sams", sam_model_name)
797
+
798
+ if 'vit_h' in sam_model_name:
799
+ model_kind = 'vit_h'
800
+ elif 'vit_l' in sam_model_name:
801
+ model_kind = 'vit_l'
802
+ else:
803
+ model_kind = 'vit_b'
804
+
805
+ sam = sam_model_registry[model_kind](checkpoint=sam_modelname)
806
+ size = os.path.getsize(sam_modelname)
807
+ sam.safe_to = core.SafeToGPU(size)
808
+
809
+ device = model_management.get_torch_device()
810
+
811
+ sam.safe_to.to_device(sam, device)
812
+
813
+ sam.is_auto_mode = self.device_mode == "AUTO"
814
+
815
+ combined_mask, _ = core.make_sam_mask_segmented(sam, segs, images, self.detection_hint, sam_dilation, sam_threshold, bbox_expansion, mask_hint_threshold, mask_hint_use_negative)
816
+
817
+ else:
818
+ combined_mask = mask_optional
819
+
820
+ # *** MASK TO IMAGE ***:
821
+
822
+ mask_image = combined_mask.reshape((-1, 1, combined_mask.shape[-2], combined_mask.shape[-1])).movedim(1, -1).expand(-1, -1, -1, 3)
823
+
824
+ # *** MASK MORPH ***:
825
+
826
+ mask_image = core.tensor2mask(mask_image)
827
+
828
+ if morphology_operation == "dilate":
829
+ mask_image = self.dilate(mask_image, morphology_distance)
830
+ elif morphology_operation == "erode":
831
+ mask_image = self.erode(mask_image, morphology_distance)
832
+ elif morphology_operation == "open":
833
+ mask_image = self.erode(mask_image, morphology_distance)
834
+ mask_image = self.dilate(mask_image, morphology_distance)
835
+ elif morphology_operation == "close":
836
+ mask_image = self.dilate(mask_image, morphology_distance)
837
+ mask_image = self.erode(mask_image, morphology_distance)
838
+
839
+ # *** MASK BLUR ***:
840
+
841
+ if len(mask_image.size()) == 3:
842
+ mask_image = mask_image.unsqueeze(3)
843
+
844
+ mask_image = mask_image.permute(0, 3, 1, 2)
845
+ kernel_size = blur_radius * 2 + 1
846
+ sigma = sigma_factor * (0.6 * blur_radius - 0.3)
847
+ mask_image_final = self.gaussian_blur(mask_image, kernel_size, sigma).permute(0, 2, 3, 1)
848
+ if mask_image_final.size()[3] == 1:
849
+ mask_image_final = mask_image_final[:, :, :, 0]
850
+
851
+ # *** CUT BY MASK ***:
852
+
853
+ if len(swapped_image.shape) < 4:
854
+ C = 1
855
+ else:
856
+ C = swapped_image.shape[3]
857
+
858
+ # We operate on RGBA to keep the code clean and then convert back after
859
+ swapped_image = core.tensor2rgba(swapped_image)
860
+ mask = core.tensor2mask(mask_image_final)
861
+
862
+ # Scale the mask to be a matching size if it isn't
863
+ B, H, W, _ = swapped_image.shape
864
+ mask = torch.nn.functional.interpolate(mask.unsqueeze(1), size=(H, W), mode='nearest')[:,0,:,:]
865
+ MB, _, _ = mask.shape
866
+
867
+ if MB < B:
868
+ assert(B % MB == 0)
869
+ mask = mask.repeat(B // MB, 1, 1)
870
+
871
+ # masks_to_boxes errors if the tensor is all zeros, so we'll add a single pixel and zero it out at the end
872
+ is_empty = ~torch.gt(torch.max(torch.reshape(mask,[MB, H * W]), dim=1).values, 0.)
873
+ mask[is_empty,0,0] = 1.
874
+ boxes = masks_to_boxes(mask)
875
+ mask[is_empty,0,0] = 0.
876
+
877
+ min_x = boxes[:,0]
878
+ min_y = boxes[:,1]
879
+ max_x = boxes[:,2]
880
+ max_y = boxes[:,3]
881
+
882
+ width = max_x - min_x + 1
883
+ height = max_y - min_y + 1
884
+
885
+ use_width = int(torch.max(width).item())
886
+ use_height = int(torch.max(height).item())
887
+
888
+ # if self.force_resize_width > 0:
889
+ # use_width = self.force_resize_width
890
+
891
+ # if self.force_resize_height > 0:
892
+ # use_height = self.force_resize_height
893
+
894
+ alpha_mask = torch.ones((B, H, W, 4))
895
+ alpha_mask[:,:,:,3] = mask
896
+
897
+ swapped_image = swapped_image * alpha_mask
898
+
899
+ cutted_image = torch.zeros((B, use_height, use_width, 4))
900
+ for i in range(0, B):
901
+ if not is_empty[i]:
902
+ ymin = int(min_y[i].item())
903
+ ymax = int(max_y[i].item())
904
+ xmin = int(min_x[i].item())
905
+ xmax = int(max_x[i].item())
906
+ single = (swapped_image[i, ymin:ymax+1, xmin:xmax+1,:]).unsqueeze(0)
907
+ resized = torch.nn.functional.interpolate(single.permute(0, 3, 1, 2), size=(use_height, use_width), mode='bicubic').permute(0, 2, 3, 1)
908
+ cutted_image[i] = resized[0]
909
+
910
+ # Preserve our type unless we were previously RGB and added non-opaque alpha due to the mask size
911
+ if C == 1:
912
+ cutted_image = core.tensor2mask(cutted_image)
913
+ elif C == 3 and torch.min(cutted_image[:,:,:,3]) == 1:
914
+ cutted_image = core.tensor2rgb(cutted_image)
915
+
916
+ # *** PASTE BY MASK ***:
917
+
918
+ image_base = core.tensor2rgba(images)
919
+ image_to_paste = core.tensor2rgba(cutted_image)
920
+ mask = core.tensor2mask(mask_image_final)
921
+
922
+ # Scale the mask to be a matching size if it isn't
923
+ B, H, W, C = image_base.shape
924
+ MB = mask.shape[0]
925
+ PB = image_to_paste.shape[0]
926
+
927
+ if B < PB:
928
+ assert(PB % B == 0)
929
+ image_base = image_base.repeat(PB // B, 1, 1, 1)
930
+ B, H, W, C = image_base.shape
931
+ if MB < B:
932
+ assert(B % MB == 0)
933
+ mask = mask.repeat(B // MB, 1, 1)
934
+ elif B < MB:
935
+ assert(MB % B == 0)
936
+ image_base = image_base.repeat(MB // B, 1, 1, 1)
937
+ if PB < B:
938
+ assert(B % PB == 0)
939
+ image_to_paste = image_to_paste.repeat(B // PB, 1, 1, 1)
940
+
941
+ mask = torch.nn.functional.interpolate(mask.unsqueeze(1), size=(H, W), mode='nearest')[:,0,:,:]
942
+ MB, MH, MW = mask.shape
943
+
944
+ # masks_to_boxes errors if the tensor is all zeros, so we'll add a single pixel and zero it out at the end
945
+ is_empty = ~torch.gt(torch.max(torch.reshape(mask,[MB, MH * MW]), dim=1).values, 0.)
946
+ mask[is_empty,0,0] = 1.
947
+ boxes = masks_to_boxes(mask)
948
+ mask[is_empty,0,0] = 0.
949
+
950
+ min_x = boxes[:,0]
951
+ min_y = boxes[:,1]
952
+ max_x = boxes[:,2]
953
+ max_y = boxes[:,3]
954
+ mid_x = (min_x + max_x) / 2
955
+ mid_y = (min_y + max_y) / 2
956
+
957
+ target_width = max_x - min_x + 1
958
+ target_height = max_y - min_y + 1
959
+
960
+ result = image_base.detach().clone()
961
+ face_segment = mask_image_final
962
+
963
+ for i in range(0, MB):
964
+ if is_empty[i]:
965
+ continue
966
+ else:
967
+ image_index = i
968
+ source_size = image_to_paste.size()
969
+ SB, SH, SW, _ = image_to_paste.shape
970
+
971
+ # Figure out the desired size
972
+ width = int(target_width[i].item())
973
+ height = int(target_height[i].item())
974
+ # if self.resize_behavior == "keep_ratio_fill":
975
+ # target_ratio = width / height
976
+ # actual_ratio = SW / SH
977
+ # if actual_ratio > target_ratio:
978
+ # width = int(height * actual_ratio)
979
+ # elif actual_ratio < target_ratio:
980
+ # height = int(width / actual_ratio)
981
+ # elif self.resize_behavior == "keep_ratio_fit":
982
+ # target_ratio = width / height
983
+ # actual_ratio = SW / SH
984
+ # if actual_ratio > target_ratio:
985
+ # height = int(width / actual_ratio)
986
+ # elif actual_ratio < target_ratio:
987
+ # width = int(height * actual_ratio)
988
+ # elif self.resize_behavior == "source_size" or self.resize_behavior == "source_size_unmasked":
989
+
990
+ width = SW
991
+ height = SH
992
+
993
+ # Resize the image we're pasting if needed
994
+ resized_image = image_to_paste[i].unsqueeze(0)
995
+ # if SH != height or SW != width:
996
+ # resized_image = torch.nn.functional.interpolate(resized_image.permute(0, 3, 1, 2), size=(height,width), mode='bicubic').permute(0, 2, 3, 1)
997
+
998
+ pasting = torch.ones([H, W, C])
999
+ ymid = float(mid_y[i].item())
1000
+ ymin = int(math.floor(ymid - height / 2)) + 1
1001
+ ymax = int(math.floor(ymid + height / 2)) + 1
1002
+ xmid = float(mid_x[i].item())
1003
+ xmin = int(math.floor(xmid - width / 2)) + 1
1004
+ xmax = int(math.floor(xmid + width / 2)) + 1
1005
+
1006
+ _, source_ymax, source_xmax, _ = resized_image.shape
1007
+ source_ymin, source_xmin = 0, 0
1008
+
1009
+ if xmin < 0:
1010
+ source_xmin = abs(xmin)
1011
+ xmin = 0
1012
+ if ymin < 0:
1013
+ source_ymin = abs(ymin)
1014
+ ymin = 0
1015
+ if xmax > W:
1016
+ source_xmax -= (xmax - W)
1017
+ xmax = W
1018
+ if ymax > H:
1019
+ source_ymax -= (ymax - H)
1020
+ ymax = H
1021
+
1022
+ pasting[ymin:ymax, xmin:xmax, :] = resized_image[0, source_ymin:source_ymax, source_xmin:source_xmax, :]
1023
+ pasting[:, :, 3] = 1.
1024
+
1025
+ pasting_alpha = torch.zeros([H, W])
1026
+ pasting_alpha[ymin:ymax, xmin:xmax] = resized_image[0, source_ymin:source_ymax, source_xmin:source_xmax, 3]
1027
+
1028
+ # if self.resize_behavior == "keep_ratio_fill" or self.resize_behavior == "source_size_unmasked":
1029
+ # # If we explicitly want to fill the area, we are ok with extending outside
1030
+ # paste_mask = pasting_alpha.unsqueeze(2).repeat(1, 1, 4)
1031
+ # else:
1032
+ # paste_mask = torch.min(pasting_alpha, mask[i]).unsqueeze(2).repeat(1, 1, 4)
1033
+ paste_mask = torch.min(pasting_alpha, mask[i]).unsqueeze(2).repeat(1, 1, 4)
1034
+ result[image_index] = pasting * paste_mask + result[image_index] * (1. - paste_mask)
1035
+
1036
+ face_segment = result
1037
+
1038
+ face_segment[...,3] = mask[i]
1039
+
1040
+ result = rgba2rgb_tensor(result)
1041
+
1042
+ return (result,combined_mask,mask_image_final,face_segment,)
1043
+
1044
+ def gaussian_blur(self, image, kernel_size, sigma):
1045
+ kernel = torch.Tensor(kernel_size, kernel_size).to(device=image.device)
1046
+ center = kernel_size // 2
1047
+ variance = sigma**2
1048
+ for i in range(kernel_size):
1049
+ for j in range(kernel_size):
1050
+ x = i - center
1051
+ y = j - center
1052
+ kernel[i, j] = math.exp(-(x**2 + y**2)/(2*variance))
1053
+ kernel /= kernel.sum()
1054
+
1055
+ # Pad the input tensor
1056
+ padding = (kernel_size - 1) // 2
1057
+ input_pad = torch.nn.functional.pad(image, (padding, padding, padding, padding), mode='reflect')
1058
+
1059
+ # Reshape the padded input tensor for batched convolution
1060
+ batch_size, num_channels, height, width = image.shape
1061
+ input_reshaped = input_pad.reshape(batch_size*num_channels, 1, height+padding*2, width+padding*2)
1062
+
1063
+ # Perform batched convolution with the Gaussian kernel
1064
+ output_reshaped = torch.nn.functional.conv2d(input_reshaped, kernel.unsqueeze(0).unsqueeze(0))
1065
+
1066
+ # Reshape the output tensor to its original shape
1067
+ output_tensor = output_reshaped.reshape(batch_size, num_channels, height, width)
1068
+
1069
+ return output_tensor
1070
+
1071
+ def erode(self, image, distance):
1072
+ return 1. - self.dilate(1. - image, distance)
1073
+
1074
+ def dilate(self, image, distance):
1075
+ kernel_size = 1 + distance * 2
1076
+ # Add the channels dimension
1077
+ image = image.unsqueeze(1)
1078
+ out = torchfn.max_pool2d(image, kernel_size=kernel_size, stride=1, padding=kernel_size // 2).squeeze(1)
1079
+ return out
1080
+
1081
+
1082
+ class ImageDublicator:
1083
+ @classmethod
1084
+ def INPUT_TYPES(s):
1085
+ return {
1086
+ "required": {
1087
+ "image": ("IMAGE",),
1088
+ "count": ("INT", {"default": 1, "min": 0}),
1089
+ },
1090
+ }
1091
+
1092
+ RETURN_TYPES = ("IMAGE",)
1093
+ RETURN_NAMES = ("IMAGES",)
1094
+ OUTPUT_IS_LIST = (True,)
1095
+ FUNCTION = "execute"
1096
+ CATEGORY = "🌌 ReActor"
1097
+
1098
+ def execute(self, image, count):
1099
+ images = [image for i in range(count)]
1100
+ return (images,)
1101
+
1102
+
1103
+ class ImageRGBA2RGB:
1104
+ @classmethod
1105
+ def INPUT_TYPES(s):
1106
+ return {
1107
+ "required": {
1108
+ "image": ("IMAGE",),
1109
+ },
1110
+ }
1111
+
1112
+ RETURN_TYPES = ("IMAGE",)
1113
+ FUNCTION = "execute"
1114
+ CATEGORY = "🌌 ReActor"
1115
+
1116
+ def execute(self, image):
1117
+ out = rgba2rgb_tensor(image)
1118
+ return (out,)
1119
+
1120
+
1121
+ class MakeFaceModelBatch:
1122
+ @classmethod
1123
+ def INPUT_TYPES(s):
1124
+ return {
1125
+ "required": {
1126
+ "face_model1": ("FACE_MODEL",),
1127
+ },
1128
+ "optional": {
1129
+ "face_model2": ("FACE_MODEL",),
1130
+ "face_model3": ("FACE_MODEL",),
1131
+ "face_model4": ("FACE_MODEL",),
1132
+ "face_model5": ("FACE_MODEL",),
1133
+ "face_model6": ("FACE_MODEL",),
1134
+ "face_model7": ("FACE_MODEL",),
1135
+ "face_model8": ("FACE_MODEL",),
1136
+ "face_model9": ("FACE_MODEL",),
1137
+ "face_model10": ("FACE_MODEL",),
1138
+ },
1139
+ }
1140
+
1141
+ RETURN_TYPES = ("FACE_MODEL",)
1142
+ RETURN_NAMES = ("FACE_MODELS",)
1143
+ FUNCTION = "execute"
1144
+
1145
+ CATEGORY = "🌌 ReActor"
1146
+
1147
+ def execute(self, **kwargs):
1148
+ if len(kwargs) > 0:
1149
+ face_models = [value for value in kwargs.values()]
1150
+ return (face_models,)
1151
+ else:
1152
+ logger.error("Please provide at least 1 `face_model`")
1153
+ return (None,)
1154
+
1155
+
1156
+ class ReActorOptions:
1157
+ @classmethod
1158
+ def INPUT_TYPES(s):
1159
+ return {
1160
+ "required": {
1161
+ "input_faces_order": (
1162
+ ["left-right","right-left","top-bottom","bottom-top","small-large","large-small"], {"default": "large-small"}
1163
+ ),
1164
+ "input_faces_index": ("STRING", {"default": "0"}),
1165
+ "detect_gender_input": (["no","female","male"], {"default": "no"}),
1166
+ "source_faces_order": (
1167
+ ["left-right","right-left","top-bottom","bottom-top","small-large","large-small"], {"default": "large-small"}
1168
+ ),
1169
+ "source_faces_index": ("STRING", {"default": "0"}),
1170
+ "detect_gender_source": (["no","female","male"], {"default": "no"}),
1171
+ "console_log_level": ([0, 1, 2], {"default": 1}),
1172
+ }
1173
+ }
1174
+
1175
+ RETURN_TYPES = ("OPTIONS",)
1176
+ FUNCTION = "execute"
1177
+ CATEGORY = "🌌 ReActor"
1178
+
1179
+ def execute(self,input_faces_order, input_faces_index, detect_gender_input, source_faces_order, source_faces_index, detect_gender_source, console_log_level):
1180
+ options: dict = {
1181
+ "input_faces_order": input_faces_order,
1182
+ "input_faces_index": input_faces_index,
1183
+ "detect_gender_input": detect_gender_input,
1184
+ "source_faces_order": source_faces_order,
1185
+ "source_faces_index": source_faces_index,
1186
+ "detect_gender_source": detect_gender_source,
1187
+ "console_log_level": console_log_level,
1188
+ }
1189
+ return (options, )
1190
+
1191
+
1192
+ class ReActorFaceBoost:
1193
+ @classmethod
1194
+ def INPUT_TYPES(s):
1195
+ return {
1196
+ "required": {
1197
+ "enabled": ("BOOLEAN", {"default": True, "label_off": "OFF", "label_on": "ON"}),
1198
+ "boost_model": (get_model_names(get_restorers),),
1199
+ "interpolation": (["Nearest","Bilinear","Bicubic","Lanczos"], {"default": "Bicubic"}),
1200
+ "visibility": ("FLOAT", {"default": 1, "min": 0.1, "max": 1, "step": 0.05}),
1201
+ "codeformer_weight": ("FLOAT", {"default": 0.5, "min": 0.0, "max": 1, "step": 0.05}),
1202
+ "restore_with_main_after": ("BOOLEAN", {"default": False}),
1203
+ }
1204
+ }
1205
+
1206
+ RETURN_TYPES = ("FACE_BOOST",)
1207
+ FUNCTION = "execute"
1208
+ CATEGORY = "🌌 ReActor"
1209
+
1210
+ def execute(self,enabled,boost_model,interpolation,visibility,codeformer_weight,restore_with_main_after):
1211
+ face_boost: dict = {
1212
+ "enabled": enabled,
1213
+ "boost_model": boost_model,
1214
+ "interpolation": interpolation,
1215
+ "visibility": visibility,
1216
+ "codeformer_weight": codeformer_weight,
1217
+ "restore_with_main_after": restore_with_main_after,
1218
+ }
1219
+ return (face_boost, )
1220
+
1221
+ class ReActorUnload:
1222
+ @classmethod
1223
+ def INPUT_TYPES(s):
1224
+ return {
1225
+ "required": {
1226
+ "trigger": ("IMAGE", ),
1227
+ },
1228
+ }
1229
+
1230
+ RETURN_TYPES = ("IMAGE",)
1231
+ FUNCTION = "execute"
1232
+ CATEGORY = "🌌 ReActor"
1233
+
1234
+ def execute(self, trigger):
1235
+ unload_all_models()
1236
+ return (trigger,)
1237
+
1238
+
1239
+ NODE_CLASS_MAPPINGS = {
1240
+ # --- MAIN NODES ---
1241
+ "ReActorFaceSwap": reactor,
1242
+ "ReActorFaceSwapOpt": ReActorPlusOpt,
1243
+ "ReActorOptions": ReActorOptions,
1244
+ "ReActorFaceBoost": ReActorFaceBoost,
1245
+ "ReActorMaskHelper": MaskHelper,
1246
+ # --- Operations with Face Models ---
1247
+ "ReActorSaveFaceModel": SaveFaceModel,
1248
+ "ReActorLoadFaceModel": LoadFaceModel,
1249
+ "ReActorBuildFaceModel": BuildFaceModel,
1250
+ "ReActorMakeFaceModelBatch": MakeFaceModelBatch,
1251
+ # --- Additional Nodes ---
1252
+ "ReActorRestoreFace": RestoreFace,
1253
+ "ReActorImageDublicator": ImageDublicator,
1254
+ "ImageRGBA2RGB": ImageRGBA2RGB,
1255
+ "ReActorUnload": ReActorUnload,
1256
+ }
1257
+
1258
+ NODE_DISPLAY_NAME_MAPPINGS = {
1259
+ # --- MAIN NODES ---
1260
+ "ReActorFaceSwap": "ReActor 🌌 Fast Face Swap",
1261
+ "ReActorFaceSwapOpt": "ReActor 🌌 Fast Face Swap [OPTIONS]",
1262
+ "ReActorOptions": "ReActor 🌌 Options",
1263
+ "ReActorFaceBoost": "ReActor 🌌 Face Booster",
1264
+ "ReActorMaskHelper": "ReActor 🌌 Masking Helper",
1265
+ # --- Operations with Face Models ---
1266
+ "ReActorSaveFaceModel": "Save Face Model 🌌 ReActor",
1267
+ "ReActorLoadFaceModel": "Load Face Model 🌌 ReActor",
1268
+ "ReActorBuildFaceModel": "Build Blended Face Model 🌌 ReActor",
1269
+ "ReActorMakeFaceModelBatch": "Make Face Model Batch 🌌 ReActor",
1270
+ # --- Additional Nodes ---
1271
+ "ReActorRestoreFace": "Restore Face 🌌 ReActor",
1272
+ "ReActorImageDublicator": "Image Dublicator (List) 🌌 ReActor",
1273
+ "ImageRGBA2RGB": "Convert RGBA to RGB 🌌 ReActor",
1274
+ "ReActorUnload": "Unload ReActor Models 🌌 ReActor",
1275
+ }
custom_nodes/ComfyUI-ReActor/pyproject.toml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "comfyui-reactor"
3
+ description = "(SFW-Friendly) The Fast and Simple Face Swap Extension Node for ComfyUI, based on ReActor SD-WebUI Face Swap Extension"
4
+ version = "0.5.2-b2"
5
+ license = { file = "LICENSE" }
6
+ dependencies = ["insightface==0.7.3", "onnx>=1.14.0", "opencv-python>=4.7.0.72", "numpy==1.26.3", "segment_anything", "albumentations>=1.4.16", "ultralytics"]
7
+
8
+ [project.urls]
9
+ Repository = "https://github.com/Gourieff/ComfyUI-ReActor"
10
+ # Used by Comfy Registry https://comfyregistry.org
11
+
12
+ [tool.comfy]
13
+ PublisherId = "gourieff"
14
+ DisplayName = "ComfyUI-ReActor"
15
+ Icon = ""
custom_nodes/ComfyUI-ReActor/r_basicsr/__init__.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # https://github.com/xinntao/BasicSR
2
+ # flake8: noqa
3
+ from .archs import *
4
+ from .data import *
5
+ from .losses import *
6
+ from .metrics import *
7
+ from .models import *
8
+ from .ops import *
9
+ from .test import *
10
+ from .train import *
11
+ from .utils import *
12
+ from .version import __gitsha__, __version__
custom_nodes/ComfyUI-ReActor/r_basicsr/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (524 Bytes). View file
 
custom_nodes/ComfyUI-ReActor/r_basicsr/__pycache__/test.cpython-311.pyc ADDED
Binary file (3.08 kB). View file
 
custom_nodes/ComfyUI-ReActor/r_basicsr/__pycache__/train.cpython-311.pyc ADDED
Binary file (13.3 kB). View file
 
custom_nodes/ComfyUI-ReActor/r_basicsr/__pycache__/version.cpython-311.pyc ADDED
Binary file (281 Bytes). View file
 
custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__init__.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import importlib
2
+ from copy import deepcopy
3
+ from os import path as osp
4
+
5
+ from r_basicsr.utils import get_root_logger, scandir
6
+ from r_basicsr.utils.registry import ARCH_REGISTRY
7
+
8
+ __all__ = ['build_network']
9
+
10
+ # automatically scan and import arch modules for registry
11
+ # scan all the files under the 'archs' folder and collect files ending with
12
+ # '_arch.py'
13
+ arch_folder = osp.dirname(osp.abspath(__file__))
14
+ arch_filenames = [osp.splitext(osp.basename(v))[0] for v in scandir(arch_folder) if v.endswith('_arch.py')]
15
+ # import all the arch modules
16
+ _arch_modules = [importlib.import_module(f'r_basicsr.archs.{file_name}') for file_name in arch_filenames]
17
+
18
+
19
+ def build_network(opt):
20
+ opt = deepcopy(opt)
21
+ network_type = opt.pop('type')
22
+ net = ARCH_REGISTRY.get(network_type)(**opt)
23
+ logger = get_root_logger()
24
+ logger.info(f'Network [{net.__class__.__name__}] is created.')
25
+ return net
custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (1.95 kB). View file
 
custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__pycache__/arch_util.cpython-311.pyc ADDED
Binary file (17.5 kB). View file
 
custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__pycache__/basicvsr_arch.cpython-311.pyc ADDED
Binary file (20.9 kB). View file
 
custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__pycache__/basicvsrpp_arch.cpython-311.pyc ADDED
Binary file (23.4 kB). View file
 
custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__pycache__/dfdnet_arch.cpython-311.pyc ADDED
Binary file (10.5 kB). View file
 
custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__pycache__/dfdnet_util.cpython-311.pyc ADDED
Binary file (10 kB). View file
 
custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__pycache__/discriminator_arch.cpython-311.pyc ADDED
Binary file (11.6 kB). View file
 
custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__pycache__/duf_arch.cpython-311.pyc ADDED
Binary file (15.9 kB). View file
 
custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__pycache__/ecbsr_arch.cpython-311.pyc ADDED
Binary file (17.1 kB). View file
 
custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__pycache__/edsr_arch.cpython-311.pyc ADDED
Binary file (3.56 kB). View file
 
custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__pycache__/edvr_arch.cpython-311.pyc ADDED
Binary file (24.1 kB). View file
 
custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__pycache__/hifacegan_arch.cpython-311.pyc ADDED
Binary file (13.6 kB). View file
 
custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__pycache__/hifacegan_util.cpython-311.pyc ADDED
Binary file (15.8 kB). View file
 
custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__pycache__/rcan_arch.cpython-311.pyc ADDED
Binary file (7.92 kB). View file
 
custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__pycache__/ridnet_arch.cpython-311.pyc ADDED
Binary file (11.5 kB). View file
 
custom_nodes/ComfyUI-ReActor/r_basicsr/archs/__pycache__/rrdbnet_arch.cpython-311.pyc ADDED
Binary file (8.04 kB). View file