Commit 36fbaab
Improve wildcards and fix a bug (#319)
* Improve wildcards and fix a bug
This commit fixes two issues with wildcards:
- Using a single count value no longer worked due to .strip() being
called on a None value from matching the upper range,
when using a wildcard like {2$$a|b|c},
while {2-2$$a|b|c} worked fine. Added a check to fix that.
- Choosing options was implemented in an odd way. The code would choose
up to `count` values, then put them in a `set` to prevent duplicates.
Then retry up to 10 times to get values in case the correct count
wasn't reached. This had a few issues: {2$$a|a|b} would always choose
"b a", always in this order! However, {2$$1::a|a|b}, which should be
identical, gives either "a a" or "b a"!
- When the number of items to choose was more than the count of items to
choose, the items would be returned in the original order, meaning for
example {3-6$$a|b|c|d} returns "a b c d" way more often than it
should. This is changed to shuffle the order when choosing all the
items.
- As NumPy already had a way to choose N items without replacement and
with weights, the code has been changed to use a NumPy Generator. This
means previous seeds are no longer compatible, but also means we don't
re-seed the built-in Python `random` generator.
- I have also added a "ImpactWildcardUnprocessed" node, in order to have
a multiline text input node that doesn't do ComfyUI's built in
wildcard replacement, so it's possible to put a prompt in a separate
node from the WildcardProcessor (or have a few ones to connect
manually). Due to the way things are processed both on the JS side and
the backend side, sadly concatenating text for use in wildcards
doesn't work yet.
* fix: random_gen.shuffle is side-effect function
* version marker
---------
Co-authored-by: Dr.Lt.Data <dr.lt.data@gmail.com>1 parent c5cdfa2 commit 36fbaab
2 files changed
+11
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| 73 | + | |
72 | 74 | | |
73 | 75 | | |
74 | 76 | | |
| |||
92 | 94 | | |
93 | 95 | | |
94 | 96 | | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
| |||
133 | 134 | | |
134 | 135 | | |
135 | 136 | | |
136 | | - | |
| 137 | + | |
137 | 138 | | |
138 | 139 | | |
| 140 | + | |
139 | 141 | | |
140 | 142 | | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
| 143 | + | |
150 | 144 | | |
151 | 145 | | |
152 | 146 | | |
| |||
172 | 166 | | |
173 | 167 | | |
174 | 168 | | |
175 | | - | |
| 169 | + | |
176 | 170 | | |
177 | 171 | | |
178 | 172 | | |
| |||
185 | 179 | | |
186 | 180 | | |
187 | 181 | | |
188 | | - | |
| 182 | + | |
189 | 183 | | |
190 | 184 | | |
191 | 185 | | |
| |||
0 commit comments