Compare commits

...
21 Commits
Author SHA1 Message Date
ausboss 9e9121accb Merge pull request #375 from ausboss/release/2.26.4
Release 2.26.4
2026-11-18 14:55:35 -06:00
ausboss 905ee4033f Release 2.26.4 2026-11-18 14:53:34 -06:00
ausboss 3ef9e5f51d Stop a video upload at 4 GB and remove the partial file 2026-11-18 14:50:46 -06:00
ausboss 05628b7834 Merge pull request #370 from ausboss/feat/h3-camera-from-video
H3 Prompt Writer: Camera reads "from the video" when the clip sets it
2026-11-18 14:50:35 -06:00
ausboss c1c1a5e054 Move the Layout Boxes and Camera notes to Unreleased 2026-11-18 14:49:20 -06:00
ausboss a3eb72a30c H3 Prompt Writer: Camera reads "from the video" when the clip sets it
The first Camera choice adds no camera words. With a live clip wired for
copy its moves, swap the person, new voice or change something, the prompt
already hands H3 the clip's own camera, so the list now shows that choice
as "from the video". Keep going makes new footage and keeps "as typed".

Only the shown text changes: the saved value stays "as typed", so saved
workflows and API prompts are unchanged. Card labels functions now also
receive the node, which the label needs to read the wire and the job.
2026-11-18 14:48:54 -06:00
ausboss cacadcf3b1 Merge pull request #369 from ausboss/feat/layout-boxes-h3
Layout Boxes: h3_prompt output for MiniMax H3 Image
2026-11-18 14:48:31 -06:00
ausboss 467505748d Merge pull request #373 from ausboss/test/privacy-browser-faces
Nightly face test: also run as a privacy browser
2026-11-18 14:48:26 -06:00
ausboss c100ef82c4 Merge pull request #374 from KBerwari/patch-1
Fix image previews for filenames with leading spaces
2026-11-18 14:48:22 -06:00
Kurdin Bekes Berwari fa695038ce Add regression tests for image filename whitespace in media_list.test.mjs 2026-11-18 15:36:59 +01:00
Kurdin Bekes Berwari 30cc27b985 Add regression tests for image filename whitespace 2026-11-18 15:35:50 +01:00
Kurdin Bekes Berwari 081379ae97 Preserve empty image selection handling 2026-11-18 15:27:28 +01:00
ausboss 21f97580e9 Merge pull request #372 from ausboss/fix/compare-rest-switch
Image Compare: save the picture it rests on, B for a new node
2026-11-17 23:38:09 -06:00
ausboss 8c6599d2d4 Run the face smoke test as a privacy browser too
--blocked-reads blanks every canvas pixel read the page makes, gives each
node that loads a picture a sample picture, and fails when its face then
draws none. The nightly ComfyUI check runs it beside classic and Nodes 2.0.
2026-11-17 23:34:19 -06:00
ausboss 78312c7bf5 Image Compare: save the picture it rests on, B for a new node
A new node rests on B, the after picture, and saves that with the
workflow. Right-click the node to rest on A instead. A workflow saved by an
earlier version has no saved side: it is worked out from the links as
before and held in memory, so older workflows show what they did and do not
open marked as changed. It is written only when a side is picked.
2026-11-17 23:21:43 -06:00
ausboss 16796566c4 Image Compare: rest on the result when the before comes out of a switch
A before picture that is a switch, handing on your picture for an edit and
the result for a new picture, is fed by the result. The panel read that as
the before being made from the result and rested on it. A switch now only
counts as made from the other picture when one branch is and no branch can
hand on the picture that one started from; a picture the other side can
hand on is the result.
2026-11-17 22:44:32 -06:00
ausboss 3f36952095 Merge pull request #371 from ausboss/fix/blocked-pixel-reads
Show the crop node's picture where the browser blanks pixel reads
2026-11-17 22:43:34 -06:00
ausboss 0f4bd5b135 Draw the crop node's picture where the browser blanks pixel reads
Some browsers and privacy add-ons return blank pixels when a page reads a
canvas. The see-through check read that as a fully see-through picture,
so the stage drew nothing. Probe pixel reads once per page and draw the
picture as it is when they cannot be trusted.
2026-11-17 22:36:57 -06:00
ausboss 8a5fbfe1fb Layout Boxes: drop an unused import 2026-11-17 20:31:01 -06:00
ausboss f6503cc7af Layout Boxes: h3_prompt output for MiniMax H3 Image
A fifth output says the boxes in words for MiniMax H3 Image: where each
box is across and up and down, how much of the frame it takes, and which
box it stands beside. The picture on background is <Picture 1>. An
object box with no description takes the next reference picture.

Places are said only in words, never as coordinates: H3 Image draws
numbers from the prompt onto the picture as text. The help page leads
with descriptions that name the picture and the pose ("the man from
<Picture 2>, sitting on the couch"). With those, people land in their
boxes far more often than with empty boxes.
2026-11-17 20:21:04 -06:00
Kurdin Bekes Berwari 9d7bcfbfb6 Fix image previews for filenames with leading spaces
Preserve filename whitespace when building image preview URLs. Trimming caused files with leading spaces to fail to display in Image Crop + Rotate + Pad and other nodes using the shared parser.
2026-11-17 19:13:20 +01:00
35 changed files with 783 additions and 72 deletions
+5 -2
View File
@@ -13,7 +13,9 @@ name: ComfyUI updates
# and required input the example workflows use.
# 4. scripts/dev/face_smoke.mjs puts every node on a graph in headless
# Chrome, in the classic node view and in Nodes 2.0: its face comes up
# and nothing throws.
# and nothing throws. A third run acts like a privacy browser that
# blanks canvas pixel reads: a node that loads a picture must still
# draw it.
#
# A failure on the release opens an issue (or adds to the open one) and fails
# the run. The development head breaks and mends itself often, so that job
@@ -117,7 +119,7 @@ jobs:
echo "ComfyUI did not come up"; tail -60 "$GITHUB_WORKSPACE/comfyui.log"; exit 1
- name: Every node is offered and every example still fits
run: python ComfyUI-AusBoss/scripts/compat_boot.py --url http://127.0.0.1:8188 --log comfyui.log
- name: Every node's face comes up, classic and Nodes 2.0
- name: Every node's face comes up, classic, Nodes 2.0 and a privacy browser
run: |
google-chrome --headless=new --remote-debugging-port=9333 --no-sandbox --disable-gpu --disable-dev-shm-usage \
--user-data-dir="$RUNNER_TEMP/chrome" about:blank > "$GITHUB_WORKSPACE/chrome.log" 2>&1 &
@@ -125,6 +127,7 @@ jobs:
status=0
node ComfyUI-AusBoss/scripts/dev/face_smoke.mjs 9333 || status=1
node ComfyUI-AusBoss/scripts/dev/face_smoke.mjs 9333 --vue || status=1
node ComfyUI-AusBoss/scripts/dev/face_smoke.mjs 9333 --blocked-reads || status=1
exit "$status"
- name: ComfyUI's log
if: ${{ always() }}
+39
View File
@@ -2,6 +2,45 @@
All notable changes to ComfyUI-AusBoss are documented here.
## 2.26.4 - 2026-11-18
- **A video upload stops at 4 GB.** Dropping a video on Load Video had no
size limit, so a huge file could fill the input folder. An upload over
4 GB is now refused with a message, and the partly saved file is removed.
- **Image Crop + Rotate + Pad shows your picture in every browser.** Some
browsers and privacy add-ons (Firefox's fingerprint protection, Brave
Shields, canvas blockers) blank a picture when a page reads its pixels.
The node read that as a fully see-through picture and drew an empty stage,
although the size line and the run were right. It now checks first and,
where reads are blocked, draws the picture as it is; only the teal tint
over see-through parts is missing there.
- **Image Compare A/B always rests on the same picture.** While the
pointer is away, a new node shows B, the "after" picture. To show A
instead, right-click the node; the choice is saved with the workflow.
Earlier versions worked the side out from the links on every run, and a
workflow whose "before" came out of a switch showed the before. A
workflow saved by an earlier version keeps showing the picture it did.
- **Layout Boxes 🆎 places people for MiniMax H3 Image.** A new
`h3_prompt` output says the boxes in words: who goes where, how big, and
who stands beside whom. Describe each person in their box by their
picture and what they do, such as "the man from <Picture 2>, sitting on
the couch"; the scene on `background` is `<Picture 1>`. Places are said in
words only, because H3 Image draws numbers from a prompt onto the picture.
- **H3 Prompt Writer's Camera says "from the video" when the video sets
the camera.** With a clip wired to copy its moves, swap the person, give it
a new voice or change something, the first Camera choice now reads "from
the video": the camera does what it does in the clip. It is the same
choice as "as typed", so saved workflows are unchanged.
- **A picture whose name starts with a space now shows its preview.** The
name was trimmed before the preview was asked for, so Image Crop + Rotate
+ Pad and the other nodes that share that code looked for a file that
did not exist.
## 2.26.3 - 2026-11-17
- **Tone match now works on inpaints.** On a Crop For Inpaint 🆎 crop,
+4 -2
View File
@@ -330,7 +330,7 @@ run by hand against any ComfyUI:
```bash
AUSBOSS_COMFY_ROOT=<ComfyUI> python tests/test_comfy_core_contract.py
python scripts/compat_boot.py --url http://127.0.0.1:8188
node scripts/dev/face_smoke.mjs <chrome port> # and again with --vue
node scripts/dev/face_smoke.mjs <chrome port> # and again with --vue, and --blocked-reads
```
- `test_comfy_core_contract.py` reads the pack's own source for everything
@@ -341,7 +341,9 @@ node scripts/dev/face_smoke.mjs <chrome port> # and again with --vue
- `compat_boot.py` asks a running ComfyUI which nodes it offers: every public
node of the pack, and every node and required input the examples use.
- `face_smoke.mjs` puts every node on a graph and fails when a face does not
come up or something throws.
come up or something throws. With `--blocked-reads` it acts like a privacy
browser that blanks pixel reads, and fails when a node that loads a
picture then draws none.
A failure on the release opens an issue labelled `comfyui-update`. What these
cannot see is anything that needs a model: run the real thing on a GPU
+3 -3
View File
@@ -1,9 +1,9 @@
<svg xmlns="http://www.w3.org/2000/svg" width="105" height="20" role="img" aria-label="release: v2.26.3">
<title>release: v2.26.3</title>
<svg xmlns="http://www.w3.org/2000/svg" width="105" height="20" role="img" aria-label="release: v2.26.4">
<title>release: v2.26.4</title>
<path fill="#555" d="M0 0h48v20H0z"/>
<path fill="#00b4aa" d="M48 0h57v20H48z"/>
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
<text x="24" y="14">release</text>
<text x="76.5" y="14">v2.26.3</text>
<text x="76.5" y="14">v2.26.4</text>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 425 B

After

Width:  |  Height:  |  Size: 425 B

+1 -1
View File
@@ -42,7 +42,7 @@ recipe.
| `cdp_drag.mjs <port> <setup.js> <mid.png\|-> <after.png\|-> [check.js]` | `setup.js` returns `{from, to, __clip}` in client pixels; presses at `from`, moves to `to`, screenshots mid-drag, releases, evaluates `check.js`, screenshots again |
| `audit_workflows.mjs <port> <output-dir> [workflow.json ...]` | loads every example (or selected files), exports API and loaded graphs, captures screenshots, and fails on overlaps, missing nodes, browser exceptions, or exposed AusBoss number widgets |
| `wheel_sweep.mjs <port> [--vue] [--only=Type,Type] [--workflow=file.json] [--shots=dir]` | turns the mouse wheel at every point of every node of the pack (or of the nodes in one workflow) and fails on any spot where the graph does not zoom, naming the element that took the wheel; `--real` sends real wheel turns, slower and on a coarser grid |
| `face_smoke.mjs <port> [--vue] [--only=Type,Type]` | puts one of each node of the pack on an empty graph and fails when a face does not come up: no node, a panel that is not on the page or has no size, an error thrown, a file of the pack that did not load. Needs no model, so it also runs in the nightly ComfyUI check |
| `face_smoke.mjs <port> [--vue] [--blocked-reads] [--only=Type,Type]` | puts one of each node of the pack on an empty graph and fails when a face does not come up: no node, a panel that is not on the page or has no size, an error thrown, a file of the pack that did not load. `--blocked-reads` acts like a privacy browser that blanks canvas pixel reads, gives every node that loads a picture a sample picture, and fails when its face then draws no picture. Needs no model, so it also runs in the nightly ComfyUI check |
| `cdp_nav_debug.mjs <port>` | navigates the tab in place and logs every CDP event, for when a tab stops answering |
| `cdp_hang.mjs <port>` | pre-arms the debugger on a fresh tab, loads ComfyUI, and pauses to print the stack if the page stops answering |
+60 -9
View File
@@ -14,6 +14,10 @@ import {
compareBadges,
compareClip,
compareResultSide,
REST_PROPERTY,
savedRestSide,
SWITCH_CONTROL_INPUTS,
SWITCH_NODE_TYPES,
compareSizeLabel,
compareSwitchValue,
findComparePairs,
@@ -182,9 +186,15 @@ function linkView(graph) {
const link = lookupLink(graph, linkId);
return link ? { id: String(link.origin_id), slot: link.origin_slot } : null;
};
const inputs = (id) => graph?.getNodeById?.(id)?.inputs ?? [];
return {
origin,
feeds: (id) => (graph?.getNodeById?.(id)?.inputs ?? []).map((input) => origin(input?.link)?.id),
feeds: (id) => inputs(id).map((input) => origin(input?.link)?.id),
branches(id) {
const node = graph?.getNodeById?.(id);
if (!SWITCH_NODE_TYPES.has(node?.comfyClass ?? node?.type)) return null;
return inputs(id).filter((input) => !SWITCH_CONTROL_INPUTS.has(input?.name)).map((input) => origin(input?.link)?.id);
},
inside(id) {
const subgraph = graph?.getNodeById?.(id)?.subgraph;
if (!subgraph) return null;
@@ -195,18 +205,40 @@ function linkView(graph) {
}
// Which input holds the result, read from the graph the panel sits in.
function resultSide(node) {
function guessResultSide(node) {
const view = linkView(node.graph);
const source = (name) => view.origin(node.inputs?.find((input) => input?.name === name)?.link);
return compareResultSide(source("image_a"), source("image_b"), view);
}
// Slide mode rests on the result while the pointer is away.
// The picture the panel rests on, saved with the node. A node from a
// workflow saved before the choice existed has none: its side is worked out
// from the links, as earlier versions did, and held in memory only. Writing
// it into the node would mark every older workflow as changed when it opens;
// it is written when someone picks a side in the menu.
function restSide(node) {
const saved = savedRestSide(node.properties?.[REST_PROPERTY]);
if (saved) return saved;
node.__ausbossRestGuess ??= guessResultSide(node);
return node.__ausbossRestGuess;
}
// Slide mode rests on its saved picture while the pointer is away.
function showResult(state) {
state.fraction = resultSide(state.node) === "B" ? 0 : 1;
state.fraction = restSide(state.node) === "B" ? 0 : 1;
applyClip(state);
}
// The right-click choice: rest on the other picture from now on.
function setRestSide(node, side) {
node.properties ??= {};
node.properties[REST_PROPERTY] = side;
const state = node.__ausbossCompare;
if (state && getMode(node) === "slide" && !state.stage.matches(":hover")) showResult(state);
node.setDirtyCanvas?.(true, true);
notifyAusbossChange();
}
// A click on the mode switch. The mode saves with the workflow; a flip
// between A and B within the lock does too, through the side it stores.
function pickMode(state, value) {
@@ -433,10 +465,11 @@ app.registerExtension({
defaultValue: true,
category: ["🆎 AusBoss", "Image Compare", "Rest on the result"],
tooltip:
"While the pointer is away, Image Compare A/B shows the result: "
+ "after every run, and again each time the pointer leaves the "
+ "picture. Off: it stays on the picture nearest to where the "
+ "pointer left, and a new run does not change it.",
"While the pointer is away, Image Compare A/B shows the picture it "
+ "rests on: B on a new node, or the one picked in the node's "
+ "right-click menu. It does after every run, and again each time "
+ "the pointer leaves the picture. Off: it stays on the picture "
+ "nearest to where the pointer left, and a new run does not change it.",
onChange(value) {
restOnResult = value !== false;
},
@@ -454,6 +487,9 @@ app.registerExtension({
beforeRegisterNodeDef(nodeType, nodeData) {
if (nodeData?.name !== NODE_NAME) return;
chainCallback(nodeType.prototype, "onNodeCreated", function () {
// A new node rests on B. A loaded one gets its saved side back in onConfigure.
this.properties ??= {};
this.properties[REST_PROPERTY] = "B";
buildPanel(this);
// Only for a genuinely new node: onConfigure restores a saved size after
// this runs, so a workflow's own dimensions still win.
@@ -462,8 +498,12 @@ app.registerExtension({
Math.max(DEFAULT_NODE_SIZE[1], this.size?.[1] ?? 0),
]);
});
chainCallback(nodeType.prototype, "onConfigure", function () {
chainCallback(nodeType.prototype, "onConfigure", function (info) {
const state = this.__ausbossCompare;
// Saved before the choice existed: drop the new node's B, so the side
// is worked out from the links.
if (!savedRestSide(info?.properties?.[REST_PROPERTY])) delete this.properties?.[REST_PROPERTY];
this.__ausbossRestGuess = undefined;
queueMicrotask(() => {
if (!state || this.__ausbossCompare !== state || state.abort.signal.aborted) return;
state.showingB = this.properties?.ausboss_compare_side === "B";
@@ -482,8 +522,19 @@ app.registerExtension({
if (!pairs.length) setEmpty(state, "Execution finished without compare previews");
app.canvas?.setDirty?.(true, true);
});
// Which picture the panel rests on, kept with the workflow.
chainCallback(nodeType.prototype, "getExtraMenuOptions", function (_canvas, options) {
if (!Array.isArray(options)) return;
const side = restSide(this);
const other = side === "A" ? "B" : "A";
options.unshift(
{ content: `Show ${other} when the pointer is away (now ${side})`, callback: () => setRestSide(this, other) },
null,
);
});
// A link on the filename input decides whether the name is typed here.
chainCallback(nodeType.prototype, "onConnectionsChange", function () {
this.__ausbossRestGuess = undefined; // an older node's side follows its links
this.__ausbossCompare?.eraser?.refresh();
});
chainCallback(nodeType.prototype, "onRemoved", function () {
+15 -14
View File
@@ -20,10 +20,9 @@ middle of a graph without breaking anything downstream.
Run the workflow once to load the previews. The switch under the picture
picks what the panel does, and its marker slides to your choice:
- **Slide** (default): the panel shows the result. Move the pointer across
it to compare: A appears on the left of the line and B on the right. Move
the pointer away and the result is back. Every new run shows its result
too.
- **Slide** (default): the panel shows B, the result. Move the pointer
across it to compare: A appears on the left of the line and B on the
right. Move the pointer away and B is back. Every new run shows it too.
- **A** / **B**: show that picture and hold it, whatever the pointer does.
- **Erase**: mix the two pictures by hand. One picture is on top; paint on
it and it rubs away, so the other one shows through. Then save the mix.
@@ -132,11 +131,12 @@ Your paint is kept with the workflow. A new run keeps it while the picture
keeps its size, so you can change a seed and look again; press **CLEAR**
to start over. Pictures of another size start clean.
## Which picture is the result
## Which picture shows when the pointer is away
B, the "after" picture. If your graph makes A out of B's picture (B is the
picture you loaded and A is the edited one), the result is A. To keep one
picture up whatever happens, use the **A** or **B** button.
B, the "after" picture, on a new node. If your result is wired to A,
right-click the node and choose **Show A when the pointer is away**. The
choice is saved with the workflow. To keep one picture up whatever the
pointer does, use the **A** or **B** button.
## Outputs
@@ -152,12 +152,13 @@ network requests are made.
## Technical details
- While sliding, the outer 6% on either side snaps to a full image.
- The result is found from the links: when the node that feeds `image_b` is
somewhere upstream of the node that feeds `image_a`, A was made from B and
A is the result. When both pictures come out of one subgraph, the same
check is made inside it. In every other case it is B: two unrelated
pictures, both pictures out of one plain node, or a link the node cannot
follow (a Set and Get pair, for example).
- The side is saved in the node's `ausboss_compare_rest` property. A
workflow saved by an earlier version has none, so its side is worked out
from the links, the way earlier versions did, until a side is picked in
the menu: when A is made from B's picture, A is the result. A switch
counts only when it cannot hand on the picture B started from. When both
pictures come out of one subgraph, the same check is made inside it. In
every other case it is B.
- Settings → AusBoss → Image Compare → **Rest on the result** switches this
off. The panel then stays on the picture nearest to where the pointer
left, and a new run does not change it.
+3 -1
View File
@@ -210,7 +210,9 @@ as not plugged in.
`sound:` line.
- **Music** (`music`): the music for the whole clip. Same as a `music:` line.
- **Length** (`seconds`): how long the clip is, 4 to 15.
- **Camera** (`camera`): how the camera moves the whole way through.
- **Camera** (`camera`): how the camera moves the whole way through. The first
choice adds no camera words. With a video wired it reads **from the video**:
the camera does what it does in the video. Pick a move only to change it.
- **Look** (`look`): from the picture keeps your photo's look. The others redraw
the clip. Clay and 3D don't work from words, so change your picture first with
an edit model.
+49 -1
View File
@@ -26,6 +26,40 @@ Boxes only shows "Node 2.0 only".
Wire `preview` to a Preview Image to see the boxes with their numbers and words.
## Place people with MiniMax H3 Image
The `h3_prompt` output says the boxes in words for MiniMax H3 Image: who goes
where, what they do there, how big, and who stands beside whom. Use it to put the people from your
reference pictures into a scene, each one where you drew a box.
1. Wire your scene picture into `background` and into the first picture of
the H3 Image node: it is `<Picture 1>`, the picture that is changed.
2. Wire the people's pictures into the next ones: `<Picture 2>`,
`<Picture 3>` and so on.
3. Draw one **object** box for each person. In its **Description**, name
their picture and say what they do there, for example "the man from
`<Picture 2>`, sitting on the couch". That second part is what puts them
in the box: told only where to go, H3 Image keeps people standing as in
their own picture, often outside the box.
4. A box with no description still gets the next picture, `<Picture 2>`, then
`<Picture 3>`, in the order of the boxes, and keeps that person's face,
hair and clothes. It is a rough place only. A description without a
picture is a thing: a dog, a sofa. A **text** box writes its words at its
place.
5. Wire `h3_prompt` to the prompt of the H3 Image node. To add words of your
own, such as the light or the mood, join the two texts first, for example
with ComfyUI's Concatenate Text node.
Without a picture on `background` there is no scene picture, and the people
start at `<Picture 1>`.
The prompt says every place in words, never in numbers: H3 Image draws
numbers from a prompt onto the picture as text. Tried on three rooms and two
seeds: with a description like the one above, the man was in his box 6 times
of 6 and the woman 4 of 6, and the room stayed as it was; with empty boxes,
2 of 12. Keep `preview` out of H3
Image's pictures too, or the boxes' lines can stay in the picture.
## Change the words in a picture
The `mask` output is white inside every box. Use it to change only one part
@@ -149,11 +183,12 @@ removes it. The first color also colors the box on the canvas.
| `bboxes` | The boxes in pixels of the canvas (x, y, width, height), for nodes that take bounding boxes. A turned box gives the straight box around it. |
| `elements` | The boxes as prompt elements. Wire it to MOSS-Image Layout Prompt. A turned box gives the straight box around it, and a turned text box says its slant in its description. |
| `mask` | White inside every box, black elsewhere, to change only those places of a picture. A turned box is white inside its turned shape only. |
| `h3_prompt` | The boxes as a prompt for MiniMax H3 Image, in words: where each thing goes and how big it is. Name each person's picture and what they do in the box's description. See **Place people with MiniMax H3 Image**. |
## In place of Create Bounding Boxes
Layout Boxes has the same inputs and the same outputs in the same order (and
`mask` after them), so the wires move straight over. For the same boxes it
`mask` and `h3_prompt` after them), so the wires move straight over. For the same boxes it
gives the same `bboxes` and `elements`, and MOSS-Image Layout Prompt makes the
same prompt from them.
@@ -209,5 +244,18 @@ run once: they fill the canvas. Then remove the old node.
- Like Create Bounding Boxes, it is an output node: it runs with the workflow
even when nothing is wired to its outputs, so new boxes on the `bboxes` wire
reach the canvas.
- `h3_prompt` has an opening sentence (one photograph of the scene in
`<Picture 1>`, kept as it is), one sentence per box in box order, and a
closing one (the same ground and light for everything). Across, a box is at
the far left, left, middle, right or far right by its centre; it is "high"
or "low" when its centre is in the top or bottom third and it is less than
0.6 of the frame tall. Its height and width are said as a tenth, a quarter,
a third, half, two thirds, three quarters or all of the frame. Each object
is placed against the object on its left when the two share some height:
right beside it (a gap under 5% of the frame), a little to the right (under
15%), well to the right, or partly in front of or behind it when they
overlap (the later box is in front). Text boxes are placed by the frame
only. A turned box is placed by the straight box around it. A text box with
no text and no description is left out. No boxes give an empty text.
- The background is saved, shrunk, in ComfyUI's temp folder for the node's
face. Nothing else is written.
+42 -6
View File
@@ -131,6 +131,21 @@ export function compareBadges(fraction, stageWidth, badgeWidth = 22, gap = 5) {
return { a: a >= 4 ? a : null, b: b + badgeWidth <= width - 4 ? b : null };
}
// The node property that holds the picture the panel rests on: "A" or "B",
// saved with the workflow. A new node rests on B, the "after" picture.
export const REST_PROPERTY = "ausboss_compare_rest";
// A saved resting side, or null when the node has none yet (a workflow
// saved before the choice existed).
export function savedRestSide(value) {
return value === "A" || value === "B" ? value : null;
}
// Node types that hand on one of their pictures and make nothing new.
export const SWITCH_NODE_TYPES = new Set(["ComfySwitchNode", "ComfySoftSwitchNode", "AUSBOSS_NODES_Switch"]);
// The inputs of a switch that choose a branch rather than carry a picture.
export const SWITCH_CONTROL_INPUTS = new Set(["switch", "select", "boolean", "index"]);
// Is `target` somewhere upstream of `start`? `feeds(id)` lists the ids of
// the nodes wired into node `id`.
function isUpstream(target, start, feeds) {
@@ -147,15 +162,34 @@ function isUpstream(target, start, feeds) {
return false;
}
// Is the picture out of `start` made from `target`'s picture? A switch only
// hands one of its pictures on, so it counts only when one branch is made
// from `target` and no branch can hand on a picture from before `target`.
// `branches(id)` lists a switch's picture branches, null for other nodes.
function madeFrom(start, target, graph, memo = new Map()) {
if (start === target) return true;
if (memo.has(start)) return memo.get(start);
memo.set(start, false); // a loop in the links proves nothing
const branches = graph.branches?.(start) ?? null;
const ids = (branches ?? graph.feeds(start) ?? []).filter((id) => id != null);
const answer = ids.some((id) => madeFrom(id, target, graph, memo))
&& !(branches && ids.some((id) => id !== target && isUpstream(id, target, graph.feeds)));
memo.set(start, answer);
return answer;
}
// Which input holds the result, the picture the panel rests on. B is the
// "after" picture by convention. When B's picture feeds the node that makes
// A, they are wired the other way round and the result is A.
// "after" picture by convention. When A is made from B's picture, they are
// wired the other way round and the result is A. A switch that can hand on
// either the other picture or the one it started from is a "before" picker:
// the picture it can hand on is the result.
//
// `a` and `b` say where the two pictures come from: { id, slot } of the node
// and output wired to each input. `graph` reads the links: feeds(id) lists
// the ids of the nodes wired into node `id`, and inside(id) opens a
// subgraph: the same two calls for the graph in it, plus output(slot),
// where that output comes from in there.
// the ids of the nodes wired into node `id`, branches(id) the picture
// branches of a switch (null for other nodes), and inside(id) opens a
// subgraph: the same calls for the graph in it, plus output(slot), where
// that output comes from in there.
export function compareResultSide(a, b, graph) {
// Both pictures out of one subgraph: the answer is inside it.
for (let depth = 0; a && b && a.id === b.id && depth < 16; depth += 1) {
@@ -164,5 +198,7 @@ export function compareResultSide(a, b, graph) {
[a, b, graph] = [inner.output(a.slot), inner.output(b.slot), inner];
}
if (!a || !b || a.id === b.id) return "B";
return isUpstream(b.id, a.id, graph.feeds) ? "A" : "B";
if (madeFrom(a.id, b.id, graph)) return "A";
if (madeFrom(b.id, a.id, graph)) return "B";
return isUpstream(a.id, b.id, graph.feeds) ? "A" : "B";
}
+13
View File
@@ -48,6 +48,19 @@ export function clipLengthWords(timing) {
return { title: `H3 makes ${made} frames · ${seconds(made)} s`, note: `That is its shortest length; the clip has ${timing.frames} frames.`, warn: true };
}
// These video jobs keep the clip's own camera (Python MOVES_ARE and
// SWAP_VIDEO say so; a new voice or a change keeps the clip as it was shot).
// "keep going" makes new footage, so its camera is still the user's words.
const CAMERA_FROM_CLIP = ["copy its moves", "swap the person", "new voice", "change something"];
// The Camera list's first choice adds no camera words. With a clip wired for
// one of those jobs that means the clip's own camera, so it reads that way.
export function cameraChoiceLabel(value, values, node) {
if (value !== "as typed" || !node) return undefined;
const job = node.widgets?.find((widget) => widget.name === "video_job")?.value;
return CAMERA_FROM_CLIP.includes(job) && linkSource(node, "video") !== null ? "from the video" : undefined;
}
// Keep in step with Python KEEPS_ITS_LENGTH. Other jobs use seconds normally.
export function clipSetsDuration(node, values) {
return ["copy its moves", "swap the person", "new voice", "change something"].includes(values.video_job)
+1 -1
View File
@@ -9,7 +9,7 @@ import { app } from "../../../scripts/app.js";
// Must match `version` in pyproject.toml — scripts/release_preflight.py
// enforces it. The backend serves its copy at /ausboss/pack_version; a
// mismatch means the browser cached JavaScript from an older install.
export const AUSBOSS_JS_VERSION = "2.26.3";
export const AUSBOSS_JS_VERSION = "2.26.4";
export const BRAND = "#00b4aa"; // AusBoss teal — keep node accents consistent.
export const BRAND_DARK = "#007f78";
+5 -4
View File
@@ -19,13 +19,14 @@ export const PAD_SIDES = ["left", "top", "right", "bottom"];
// "sub/dir\\name.png [temp]" -> { filename, subfolder, type } for a /view
// query. Handles Windows backslashes, subfolders, and the "name [type]"
// annotation ComfyUI appends outside the input folder.
// Preserves filename whitespace.
export function parseImageReference(value) {
let text = String(value ?? "").trim();
if (!text) return null;
let text = String(value ?? "");
if (!text.trim()) return null;
let type = "input";
const annotated = /^(.*)\s+\[(input|output|temp)\]$/i.exec(text);
const annotated = /^(.*) \[(input|output|temp)\]$/i.exec(text);
if (annotated) {
text = annotated[1].trim();
text = annotated[1];
type = annotated[2].toLowerCase();
}
const normalized = text.replaceAll("\\", "/");
+13
View File
@@ -136,6 +136,19 @@ export function seeThroughMap(rgba) {
return map;
}
// Some browsers and privacy add-ons hand back blank or made-up pixels when a
// page reads a canvas (Firefox's fingerprint protection, canvas blockers).
// Blank pixels read as a fully see-through picture, so the stage would draw
// nothing. PIXEL_PROBE is painted on a small canvas and read back; the read
// is trusted only when it comes back solid and close to what was painted
// (small colour noise, as Brave adds, is fine: only alpha decides here).
export const PIXEL_PROBE = [[255, 0, 0], [0, 0, 255]];
export function pixelReadTrusted(rgba) {
if (!rgba || rgba.length < PIXEL_PROBE.length * 4) return false;
return PIXEL_PROBE.every((color, p) =>
rgba[p * 4 + 3] === 255 && color.every((channel, c) => Math.abs(rgba[p * 4 + c] - channel) <= 16));
}
// Work-resolution planning for the overlay. Blend and grow are output
// pixels AFTER any resize; the stage draws the pre-resize canvas. One
// output pixel is `unit` work pixels (the two axes can differ by a step
+20 -1
View File
@@ -13,7 +13,7 @@ import { normalizeFillColor } from "./fill_color.mjs";
import { makeSlideSwitch } from "./slide_switch.mjs";
import { makeScrubInput } from "./scrub_input.mjs";
import { confirmDiscard } from "./discard_prompt.mjs";
import { featherGeneratedMask, generatedAreaMask, overlayPlan, seeThroughMap, stitchBlendFromMask } from "./stitch_preview.mjs";
import { PIXEL_PROBE, featherGeneratedMask, generatedAreaMask, overlayPlan, pixelReadTrusted, seeThroughMap, stitchBlendFromMask } from "./stitch_preview.mjs";
import { suppressCoreVideoPreview } from "./core_preview.mjs";
import { gearIconSvg, loadSettings, openSettingsMenu } from "./settings_menu.mjs";
import { createSettle } from "./settle.mjs";
@@ -2863,6 +2863,9 @@ function maskLayer(state) {
if (state.seeThrough?.image === state.image) return state.seeThrough.layer;
let layer = null;
try {
// A browser that blanks pixel reads would make the whole picture look
// see-through: draw it as it is instead.
if (!canReadPixels()) throw new Error("pixel reads are blocked");
const k = Math.min(1, MASK_LAYER_SIDE / Math.max(state.sourceWidth, state.sourceHeight));
const width = Math.max(1, Math.round(state.sourceWidth * k));
const height = Math.max(1, Math.round(state.sourceHeight * k));
@@ -2890,6 +2893,22 @@ function maskLayer(state) {
return layer;
}
// Whether this browser hands back the pixels a canvas holds (pixelReadTrusted).
// Asked once per page.
let pixelReadsWork = null;
function canReadPixels() {
if (pixelReadsWork !== null) return pixelReadsWork;
try {
const probe = document.createElement("canvas"); probe.width = PIXEL_PROBE.length; probe.height = 1;
const context = probe.getContext("2d");
PIXEL_PROBE.forEach(([r, g, b], x) => { context.fillStyle = `rgb(${r},${g},${b})`; context.fillRect(x, 0, 1, 1); });
pixelReadsWork = pixelReadTrusted(context.getImageData(0, 0, PIXEL_PROBE.length, 1).data);
} catch {
pixelReadsWork = false;
}
return pixelReadsWork;
}
// White where the tint is, for Show blend's raster.
function maskStencil(layer) {
if (!layer.stencil) {
+2 -2
View File
@@ -337,7 +337,7 @@ export function mountWidgetCard(node, { rows, minWidth = 300, first = false, hid
const seg = el("div", "ausboss-card-seg");
const buttons = new Map();
const add = (value, values) => {
const button = el("button", "", choiceLabel(row, value, values));
const button = el("button", "", choiceLabel(row, value, values, node));
button.type = "button"; button.title = row.titles?.[value] ?? String(value);
button.addEventListener("click", () => setWidget(name, value));
seg.append(button); buttons.set(value, button);
@@ -381,7 +381,7 @@ export function mountWidgetCard(node, { rows, minWidth = 300, first = false, hid
const options = comboValues(widget);
const list = options.includes(current) || current === undefined || current === "" ? options : [...options, current];
for (const value of list) {
const option = el("option", "", choiceLabel(row, value, options)); option.value = String(value); select.append(option);
const option = el("option", "", choiceLabel(row, value, options, node)); option.value = String(value); select.append(option);
}
select.value = String(current ?? "");
};
+2 -2
View File
@@ -196,8 +196,8 @@ export function markSocketless(nodeData, names) {
// `labels` is a map from value to words, or a function of the value and of
// all the values, for a list that is only known on the user's machine (the
// model files they have).
export function choiceLabel(row, value, values = []) {
const own = typeof row?.labels === "function" ? row.labels(value, values) : row?.labels?.[value];
export function choiceLabel(row, value, values = [], node = null) {
const own = typeof row?.labels === "function" ? row.labels(value, values, node) : row?.labels?.[value];
return own ?? String(value);
}
+2 -2
View File
@@ -11,7 +11,7 @@ import { chainCallback, notifyAusbossChange } from "../shared/index.mjs";
import { formatWidgetVisibility } from "../shared/save_video_formats.mjs";
import { hideInputsInDef } from "../shared/widget_visibility.mjs";
import { castChips } from "../shared/h3_cast_chips.mjs";
import { clipSetsDuration } from "../shared/h3_duration.mjs";
import { cameraChoiceLabel, clipSetsDuration } from "../shared/h3_duration.mjs";
import { loadImagePreview, loadImageStrip } from "../shared/load_image_strip.mjs";
import { momentStrip } from "../shared/moment_strip.mjs";
import { mountWidgetCard } from "../shared/widget_card.mjs";
@@ -395,7 +395,7 @@ const CARDS = {
{ section: "Pictures and settings" },
{ panel: castChips, height: 30 },
{ widget: "seconds", label: "Length", suffix: "s", readOnlyText: (node, values) => clipSetsDuration(node, values) ? "From the clip" : "", readOnlyTitle: "This video job uses the incoming clip, so Length is not used." },
{ widget: "camera", label: "Camera", kind: "select" },
{ widget: "camera", label: "Camera", kind: "select", labels: cameraChoiceLabel },
{ widget: "look", label: "Look", kind: "select" },
{ group: "more", label: "More" },
{ widget: "song_start", label: "Song starts at", suffix: "s", decimals: 1, trimZeros: true, group: "more" },
+3
View File
@@ -648,6 +648,9 @@
},
"3": {
"name": "遮罩"
},
"4": {
"name": "H3 提示词"
}
}
},
+194
View File
@@ -0,0 +1,194 @@
"""Layout Boxes' `h3_prompt` output: the boxes as a MiniMax H3 Image prompt.
H3 Image places things from words, and it reads its pictures as
<Picture 1>, <Picture 2>, ... in the order they are wired. So every box
becomes one sentence that says where it is in plain words: left or right,
high or low, how much of the frame it takes, and who stands beside it. An
object box with no description stands for the person in the next reference
picture, with their face, hair and clothes.
The prompt never holds coordinates. Written as numbers they come back drawn
on the picture as text (tried on H3 Image: 6 renders of 6), so places and
sizes are said in words only, and nothing in the prompt talks about boxes,
lines or frames either.
With a picture on `background`, that picture is the scene: <Picture 1>, the
one H3 Image changes, and the subjects start at <Picture 2>. Without one the
subjects start at <Picture 1>.
"""
from __future__ import annotations
from ._layout_boxes_helpers import _turned_extent, angle_of, element_desc
# Fractions of the frame, said as words.
SHARES = (
(0.15, "a tenth"),
(0.29, "a quarter"),
(0.42, "a third"),
(0.58, "half"),
(0.71, "two thirds"),
(0.88, "three quarters"),
)
# A name for the box beside it, from its description: at most this many words.
NAME_WORDS = 8
def _extent(region: dict, shape: tuple[float, float]) -> tuple[float, float, float, float]:
"""(left, top, right, bottom) as fractions of the frame, cut to it."""
if angle_of(region):
left, top, right, bottom = _turned_extent(region, shape)
else:
x, y = float(region.get("x", 0.0)), float(region.get("y", 0.0))
w, h = float(region.get("w", 0.0)), float(region.get("h", 0.0))
left, right = sorted((x, x + w))
top, bottom = sorted((y, y + h))
return tuple(min(1.0, max(0.0, value)) for value in (left, top, right, bottom))
def share_words(part: float) -> str:
"""0.5 -> "half", 0.34 -> "a third", 0.95 -> "all"."""
for upto, words in SHARES:
if part < upto:
return words
return "all"
def across_words(middle: float) -> str:
if middle < 0.2:
return "at the far left of the frame"
if middle < 0.4:
return "on the left of the frame"
if middle <= 0.6:
return "in the middle of the frame"
if middle <= 0.8:
return "on the right of the frame"
return "at the far right of the frame"
def high_or_low(top: float, bottom: float) -> str:
""" "high " or "low " in front of the place across, when it says something."""
middle = (top + bottom) / 2
if bottom - top >= 0.6:
return ""
if middle < 0.34:
return "high "
if middle > 0.66:
return "low "
return ""
def size_words(left: float, top: float, right: float, bottom: float) -> str:
tall, wide = share_words(bottom - top), share_words(right - left)
of_height = "the frame's full height" if tall == "all" else f"{tall} of the frame's height"
of_width = "all of its width" if wide == "all" else f"{wide} of its width"
return f"taking up about {of_height} and {of_width}"
def _short_name(desc: str) -> str:
"""A box's description cut to a name to place another box by."""
first = desc.strip().split(",")[0].split(".")[0].strip()
words = first.split()
if not words:
return ""
name = " ".join(words[:NAME_WORDS])
return name[:1].lower() + name[1:] if not name[:2].isupper() else name
def _beside_words(gap: float, name: str, in_front: bool) -> str:
"""Where a box is against its neighbour on the left."""
if gap < 0:
return f"partly {'in front of' if in_front else 'behind'} {name}"
if gap < 0.05:
return f"right beside {name}, on its right"
if gap < 0.15:
return f"a little to the right of {name}"
return f"well to the right of {name}"
def _overlap_down(one: dict, other: dict) -> bool:
return one["extent"][1] < other["extent"][3] and other["extent"][1] < one["extent"][3]
def _subjects(regions: list[dict], shape: tuple[float, float], first_picture: int) -> list[dict]:
"""One entry per box worth a sentence, in the boxes' order."""
items = []
picture = first_picture
for order, region in enumerate(regions):
if not isinstance(region, dict):
continue
desc = element_desc(region).strip()
kind = "text" if region.get("type") == "text" else "obj"
item = {"order": order, "kind": kind, "desc": desc, "extent": _extent(region, shape), "picture": 0}
if kind == "text":
item["text"] = str(region.get("text", "") or "").strip()
if not item["text"] and not desc:
continue
item["name"] = f'the words "{item["text"]}"' if item["text"] else _short_name(desc)
elif desc:
item["name"] = _short_name(desc)
else:
item["picture"] = picture
item["name"] = f"the person from <Picture {picture}>"
picture += 1
items.append(item)
return items
def _place(item: dict, beside: str) -> str:
left, top, right, bottom = item["extent"]
parts = [high_or_low(top, bottom) + across_words((left + right) / 2)]
if beside:
parts.append(beside)
parts.append(size_words(left, top, right, bottom))
return ", ".join(parts)
def _sentence(item: dict, beside: str) -> str:
place = _place(item, beside)
if item["kind"] == "text":
words = f'The words "{item["text"]}" are written' if item["text"] else "Writing is"
look = f" The lettering: {item['desc'].rstrip('.')}." if item["desc"] else ""
return f"{words} {place}.{look}"
if item["picture"]:
n = item["picture"]
# "Exactly as in <Picture N>" made H3 Image copy that whole picture,
# backdrop and all, over the scene: name only what to keep.
return f"The person from <Picture {n}>, with the same face, hair and clothes as in <Picture {n}>. Placed {place}."
desc = item["desc"].rstrip(".")
return f"{desc[:1].upper()}{desc[1:]}. Placed {place}."
def h3_prompt(regions: list[dict], shape: tuple[float, float] | None = None, scene: bool = False) -> str:
"""The `h3_prompt` output. `shape` is the (width, height) of the canvas
the boxes were drawn on; `scene` is True when a picture is on
`background`, which is then <Picture 1>. No boxes give an empty text."""
shape = shape or (1.0, 1.0)
items = _subjects(regions, shape, 2 if scene else 1)
if not items:
return ""
# Each object is placed against the object on its left, when the two
# share some height; words in the picture are placed by the frame only.
beside = {}
things = [item for item in items if item["kind"] == "obj"]
by_across = sorted(things, key=lambda item: (item["extent"][0] + item["extent"][2]) / 2)
for before, item in zip(by_across, by_across[1:]):
if not _overlap_down(before, item):
continue
gap = item["extent"][0] - before["extent"][2]
beside[item["order"]] = _beside_words(gap, before["name"], item["order"] > before["order"])
if scene:
opening = (
"One photograph of the scene in <Picture 1>, kept as it is: the same place, the same "
"background and the same light, seen from the same camera."
)
else:
opening = "One photograph, seen from one camera, in one light."
opening += " Everything below is together in this one picture, not in separate pictures side by side."
lines = [opening]
lines += [_sentence(item, beside.get(item["order"], "")) for item in items]
lines.append(
"Everyone and everything in the picture shares the same ground and the same light, with "
"matching shadows. It is a plain photograph: only the scene, what is in it, and the light."
)
return "\n\n".join([lines[0], "\n".join(lines[1:-1]), lines[-1]])
+6
View File
@@ -7,6 +7,8 @@ from pathlib import Path
import av
MAX_VIDEO_UPLOAD_BYTES = 4 * 1024 ** 3
def upload_name(filename: str, extensions: set[str]) -> str:
name = str(filename or "")
@@ -44,8 +46,12 @@ async def stream_video_upload(request, root: Path, extensions: set[str]) -> dict
name = upload_name(part.filename, extensions)
path, handle = reserve_upload(root.resolve(), name)
complete = False
written = 0
try:
while chunk := await part.read_chunk(size=1024 * 1024):
written += len(chunk)
if written > MAX_VIDEO_UPLOAD_BYTES:
raise ValueError("That video is too large to upload (4 GB limit).")
await asyncio.to_thread(handle.write, chunk)
handle.close()
await asyncio.to_thread(validate_video, path)
+1 -1
View File
@@ -203,7 +203,7 @@ class AusBossH3PromptWriter:
[AS_TYPED, *CAMERAS],
{
"default": AS_TYPED,
"tooltip": "How the camera moves the whole way through. As typed leaves it to your words.",
"tooltip": "How the camera moves the whole way through. As typed leaves it to your words; with a video wired it shows as from the video and keeps the video's own camera.",
},
),
"look": (
+14 -5
View File
@@ -6,7 +6,8 @@ at the place you drew it. Wire `elements` to MOSS-Image Layout Prompt.
It gives what ComfyUI's own Create Bounding Boxes gives, in the same order
and worked out the same way (preview, bboxes, elements), so it can stand in
for that node. A fourth output, `mask`, is white inside every box, to change
only those places of a picture. A box can be turned, for words at a slant:
only those places of a picture. A fifth, `h3_prompt`, says the same boxes in
words for MiniMax H3 Image (_layout_boxes_h3.py). A box can be turned, for words at a slant:
the mask is the turned box itself. Its canvas is a panel of the pack's own
(js/layout_boxes/index.js), so it draws in the classic look as well as in
Nodes 2.0. The panel drives ordinary hidden widgets, so saving, loading,
@@ -38,6 +39,7 @@ from ._layout_boxes_helpers import (
render_preview,
turned_mask_rows,
)
from ._layout_boxes_h3 import h3_prompt
from ._preview_helpers import first_frame_to_pil, temp_prefix
try:
@@ -116,11 +118,14 @@ class AusBossLayoutBoxes:
"ComfyUI's own Create Bounding Boxes gives, so it can take that node's "
"place. A picture on background shows under the boxes and sets the "
"canvas size. The mask output is white inside every box: use it to "
"change only those places of a picture, such as the words on a sign."
"change only those places of a picture, such as the words on a sign. "
"h3_prompt says the boxes in words for MiniMax H3 Image: describe each "
"person as \"the man from <Picture 2>, sitting on the couch\"."
)
SEARCH_ALIASES = [
"bounding boxes", "create bounding boxes", "bbox", "boxes", "layout",
"regions", "ideogram", "moss", "moss-image", "ausboss",
"regions", "ideogram", "moss", "moss-image", "h3", "h3 image", "minimax",
"placement", "ausboss",
]
@classmethod
@@ -161,8 +166,8 @@ class AusBossLayoutBoxes:
},
}
RETURN_TYPES = ("IMAGE", "BOUNDING_BOX", "ARRAY", "MASK")
RETURN_NAMES = ("preview", "bboxes", "elements", "mask")
RETURN_TYPES = ("IMAGE", "BOUNDING_BOX", "ARRAY", "MASK", "STRING")
RETURN_NAMES = ("preview", "bboxes", "elements", "mask", "h3_prompt")
OUTPUT_TOOLTIPS = (
"A picture of the boxes with their numbers and words, to check the layout. "
"Wire it to Preview Image.",
@@ -172,6 +177,9 @@ class AusBossLayoutBoxes:
"MOSS-Image Layout Prompt. A turned text box says its slant in its description.",
"The boxes as a mask: white inside every box, turned boxes as they are turned. "
"Use it to change only those places of a picture, such as the words on a sign.",
"The boxes as a prompt for MiniMax H3 Image: where each thing goes, in words. "
"Describe each person by their picture and what they do, such as "
"\"the man from <Picture 2>, sitting on the couch\". The background is <Picture 1>.",
)
OUTPUT_NODE = True
FUNCTION = "draw"
@@ -205,6 +213,7 @@ class AusBossLayoutBoxes:
bounding_boxes(regions, width, height, shape),
prompt_elements(regions, shape),
_boxes_mask(regions, width, height, picture),
h3_prompt(regions, shape, scene=picture is not None),
),
}
+1 -1
View File
@@ -3,7 +3,7 @@ name = "ausboss-nodes"
# Manager/registry search matches against this text, so it names the actual
# nodes instead of describing the collection abstractly.
description = "ComfyUI-AusBoss (AusBoss nodes): image and video nodes with compact controls: Image and Video Crop + Rotate + Pad (frame or clip), Load Image, Load Image + Pad, Image Folder, Image Resize, Align Image, Image Size, Color Match, Image Compare A/B, Realign to Source (experimental), Save Image (PNG, WebP/JXL, captions), Load Video, Load Audio, Save Video, Select Frame, Frame Interpolate, Mask Refine, Mask by Name and Mask by Touch, LaMa Inpaint, Crop For Inpaint, Stitch Inpaint, Tiled Upscale and Tiled Upscale Stitch, FlashVSR Upscale, Edit Lock and Edit Lock Restore, LoRA Loader, Krea 2 Encode and Outpaint Model Patch, Latent Size, Layout Boxes, Seed, Select Every Nth, Split Batch, Merge Batches, Text, Text Lines, Prompt Variations, H3 Prompt Writer, Integer, Float, Math Expression, Show Text, Free Memory, Workflow Note, Workflow Note Tile, Callout, Callout Tile, Workflow Switches, Run Timer, and Step Preview. Example workflows for Qwen Image 2.1, Krea 2, Klein 9B and LTX 2.3."
version = "2.26.3"
version = "2.26.4"
# comfy-cli serializes this to JSON verbatim, so `file` publishes the literal
# string {"file": "LICENSE"} to the registry listing. `text` puts a readable
# name there instead. Both forms are supported; the LICENSE file is unchanged.
+67 -5
View File
@@ -1,4 +1,4 @@
// face_smoke.mjs <port> [--vue] [--only=Type,Type]
// face_smoke.mjs <port> [--vue] [--blocked-reads] [--only=Type,Type]
// Puts one of each of the pack's nodes on an empty graph and checks that its
// face comes up. Run it against a ComfyUI tab on the headless Chrome at
// <port> (COMFY_URL picks the server). No model is needed and nothing is
@@ -14,6 +14,12 @@
// often says things of its own.
//
// --vue Nodes 2.0 instead of the classic renderer
// --blocked-reads
// acts like a privacy browser (Firefox's fingerprint protection,
// canvas blockers) that hands back blank pixels when a page reads
// a canvas. Every node that loads a picture gets a sample picture,
// and fails when its face then draws no picture: the bug that
// left Image Crop + Rotate + Pad's stage empty in those browsers.
// --only= a comma-separated list of node types
//
// Exits 1 when a node fails, 2 when the pack registered no node at all.
@@ -22,8 +28,9 @@ const args = process.argv.slice(2);
const port = args.find((arg) => !arg.startsWith("--"));
const flag = (name) => args.find((arg) => arg.startsWith(`--${name}=`))?.slice(name.length + 3) ?? null;
const vue = args.includes("--vue");
const blockedReads = args.includes("--blocked-reads");
const only = flag("only")?.split(",").filter(Boolean) ?? null;
if (!port) { console.error("usage: face_smoke.mjs <port> [--vue] [--only=Type,Type]"); process.exit(2); }
if (!port) { console.error("usage: face_smoke.mjs <port> [--vue] [--blocked-reads] [--only=Type,Type]"); process.exit(2); }
const COMFY = new URL(process.env.COMFY_URL || "http://127.0.0.1:8188/").href;
const page = await (await fetch(`http://127.0.0.1:${port}/json/new?about:blank`, { method: "PUT" })).json();
@@ -67,6 +74,17 @@ const ofThePack = (entry) => OF_THE_PACK.test(entry.text) || OF_THE_PACK.test(en
await send("Page.enable"); await send("Runtime.enable");
await send("Emulation.setDeviceMetricsOverride", { width: 1800, height: 1100, deviceScaleFactor: 1, mobile: false });
await send("Network.enable"); await send("Network.setCacheDisabled", { cacheDisabled: true });
// Blank every pixel read the page makes, before any of its code runs. The
// smoke test keeps the real read for itself, to see what a face drew.
if (blockedReads) {
await send("Page.addScriptToEvaluateOnNewDocument", { source: `(() => {
const real = CanvasRenderingContext2D.prototype.getImageData;
Object.defineProperty(window, "__faceSmokeRealRead", { value: real });
CanvasRenderingContext2D.prototype.getImageData = function (...args) {
const data = real.apply(this, args); data.data.fill(0); return data;
};
})();` });
}
await send("Page.navigate", { url: COMFY });
let ready = false;
for (let i = 0; i < 240 && !ready; i++) { await sleep(500); ready = await evalJs("Boolean(window.app?.graph && window.app?.canvas && window.LiteGraph?.registered_node_types)").catch(() => false); }
@@ -85,6 +103,26 @@ if (only) {
if (!types.length) { console.error(`None of ${only.join(", ")} is a node of the pack on this page.`); ws.close(); process.exit(2); }
}
// The sample picture for --blocked-reads, put in ComfyUI's input folder.
const SAMPLE = "ausboss_face_smoke.png";
if (blockedReads) {
const { readFileSync } = await import("node:fs");
const bytes = readFileSync(new URL("../../example_workflows/inputs/ausboss_pier_sunrise.png", import.meta.url)).toString("base64");
const uploaded = await evalJs(`(async () => {
const bytes = Uint8Array.from(atob(${JSON.stringify(bytes)}), (c) => c.charCodeAt(0));
const body = new FormData();
body.append("image", new Blob([bytes], { type: "image/png" }), ${JSON.stringify(SAMPLE)});
body.append("overwrite", "true");
const response = await window.comfyAPI.api.api.fetchApi("/upload/image", { method: "POST", body });
return response.ok;
})()`).catch((error) => String(error.message ?? error));
if (uploaded !== true) { console.error(`Could not upload the sample picture: ${uploaded}`); ws.close(); process.exit(2); }
}
// How many different colours a face's canvases show, read with the real
// pixel read. With the sample picture a face that drew it shows 350 or more;
// the empty crop stage of the bug, with its handles and tint, showed 100.
const PICTURE_COLOURS = 200;
const loading = said.splice(0).filter(ofThePack);
let failed = 0;
for (const entry of loading) { failed += 1; console.log(`FAIL while the page loaded: ${entry.text}`); }
@@ -115,7 +153,28 @@ for (const type of types) {
shown: widget.element.isConnected && getComputedStyle(widget.element).display !== "none",
size: widget.element.isConnected ? box(widget.element) : [0, 0],
}));
return { size: [Math.round(node.size[0]), Math.round(node.size[1])], drawn: host ? box(host) : null, widgets: (node.widgets ?? []).length, panels };
let colours = null;
const source = ${blockedReads} ? (node.widgets ?? []).find((widget) => widget.name === "image" && Array.isArray(widget.options?.values)) : null;
if (source) {
if (!source.options.values.includes(${JSON.stringify(SAMPLE)})) source.options.values.push(${JSON.stringify(SAMPLE)});
source.value = ${JSON.stringify(SAMPLE)}; source.callback?.(source.value);
app.canvas.setDirty(true, true);
await new Promise((resolve) => setTimeout(resolve, 2500));
await new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)));
const canvases = (node.widgets ?? []).filter((widget) => widget.element instanceof Element)
.flatMap((widget) => [widget.element, ...widget.element.querySelectorAll("canvas")])
.filter((el) => el instanceof HTMLCanvasElement && el.width > 0 && el.height > 0);
if (canvases.length) {
colours = 0;
for (const canvas of canvases) {
const data = window.__faceSmokeRealRead.call(canvas.getContext("2d"), 0, 0, canvas.width, canvas.height).data;
const seen = new Set();
for (let i = 0; i < data.length; i += 4 * 7) seen.add((data[i] >> 3) << 10 | (data[i + 1] >> 3) << 5 | data[i + 2] >> 3);
colours = Math.max(colours, seen.size);
}
}
}
return { size: [Math.round(node.size[0]), Math.round(node.size[1])], drawn: host ? box(host) : null, widgets: (node.widgets ?? []).length, panels, colours };
})()`).catch((error) => ({ error: String(error.message ?? error).slice(0, 400) }));
await sleep(150);
const problems = [];
@@ -127,6 +186,9 @@ for (const type of types) {
}
if (vue && !seen.drawn) problems.push("Nodes 2.0 drew no element for the node");
if (seen.drawn && !(seen.drawn[0] > 20 && seen.drawn[1] > 20)) problems.push(`the node is drawn ${seen.drawn.join(" x ")}`);
if (seen.colours != null && seen.colours < PICTURE_COLOURS) {
problems.push(`with pixel reads blocked its face drew no picture (${seen.colours} colours on its canvas)`);
}
for (const panel of seen.panels) {
if (!panel.onPage) problems.push(`its panel '${panel.name}' is not on the page`);
else if (panel.shown && !(panel.size[0] > 4 && panel.size[1] > 4)) problems.push(`its panel '${panel.name}' is ${panel.size.join(" x ")}`);
@@ -137,7 +199,7 @@ for (const type of types) {
}
const others = said.filter((entry) => !entry.thrown && !ofThePack(entry));
failed += problems.length ? 1 : 0;
const sizes = seen.error ? "" : ` ${seen.size.join(" x ")}${seen.panels.length ? `, ${seen.panels.length} panel${seen.panels.length > 1 ? "s" : ""}` : ""}`;
const sizes = seen.error ? "" : ` ${seen.size.join(" x ")}${seen.panels.length ? `, ${seen.panels.length} panel${seen.panels.length > 1 ? "s" : ""}` : ""}${seen.colours != null ? `, ${seen.colours} colours` : ""}`;
console.log(`${problems.length ? "FAIL" : "ok "} ${type}${sizes}`);
for (const problem of problems) console.log(` ${problem}`);
for (const entry of others) console.log(` (console, not counted) ${entry.text.slice(0, 200)}`);
@@ -145,7 +207,7 @@ for (const type of types) {
for (const file of lostFiles) { failed += 1; console.log(`FAIL a file of the pack did not load: ${file}`); }
await evalJs(`(async () => { window.app.graph.clear(); await window.app.extensionManager.setting.set("Comfy.VueNodes.Enabled", ${JSON.stringify(rendererBefore ?? false)}); return true; })()`).catch(() => {});
console.log(`\n${vue ? "Nodes 2.0" : "classic"}: ${types.length} nodes, ${failed} failed`);
console.log(`\n${vue ? "Nodes 2.0" : "classic"}${blockedReads ? ", pixel reads blocked" : ""}: ${types.length} nodes, ${failed} failed`);
await fetch(`http://127.0.0.1:${port}/json/close/${page.id}`).catch(() => {});
ws.close();
process.exit(failed ? 1 : 0);
+35 -2
View File
@@ -7,6 +7,7 @@ import {
slideFraction,
compareClip,
compareResultSide,
savedRestSide,
compareSizeLabel,
findCompareImages,
findComparePairs,
@@ -167,13 +168,14 @@ test("A and B sit on either side of the split line and move with it", () => {
// A graph as { node id: ids of the nodes wired into it }. A subgraph node
// also lists, under `subgraphs`, the graph inside it and where each of its
// outputs comes from in there.
function view(feeds, subgraphs = {}) {
function view(feeds, subgraphs = {}, switches = {}) {
return {
feeds: (id) => feeds[id] ?? [],
branches: (id) => switches[id] ?? null,
inside(id) {
const inner = subgraphs[id];
if (!inner) return null;
return { ...view(inner.feeds, inner.subgraphs), output: (slot) => inner.outputs[slot] ?? null };
return { ...view(inner.feeds, inner.subgraphs, inner.switches), output: (slot) => inner.outputs[slot] ?? null };
},
};
}
@@ -211,6 +213,37 @@ test("both pictures out of one subgraph are told apart inside it", () => {
assert.equal(compareResultSide(from(12, 0), from(12, 1), open), "B");
});
test("a before that a switch can fill with the result still rests on the result", () => {
// An edit-or-generate subgraph: decode 213 is the picture, and "before" is
// switch 460, your picture (-10) for an edit or the picture itself for a
// new one. B feeds A only through one branch of the switch, so A is not
// made from B and the panel rests on B, the result.
const inner = {
feeds: { 212: [-10], 213: [212], 480: [213], 460: [480, -10, -10] },
switches: { 480: [213], 460: [480, -10] },
outputs: [from(480), from(460)],
};
const graph = view({ 39: [6] }, { 39: inner });
assert.equal(compareResultSide(from(39, 1), from(39, 0), graph), "B");
assert.equal(compareResultSide(from(39, 0), from(39, 1), graph), "A");
// The same at the top level: 4 hands on the result 3 or the loader 1.
const picker = view({ 2: [1], 3: [2], 4: [3, 1, 9] }, {}, { 4: [3, 1] });
assert.equal(compareResultSide(from(4), from(3), picker), "B");
assert.equal(compareResultSide(from(3), from(4), picker), "A");
// A switch between an edit of B and B itself, or a picture from elsewhere,
// is still made from B.
assert.equal(compareResultSide(from(4), from(1), view({ 2: [1], 4: [2, 1, 9] }, {}, { 4: [2, 1] })), "A");
assert.equal(compareResultSide(from(4), from(1), view({ 2: [1], 4: [2, 7, 9] }, {}, { 4: [2, 7] })), "A");
// A switch with no picture wired proves nothing.
assert.equal(compareResultSide(from(4), from(1), view({ 4: [9] }, {}, { 4: [] })), "B");
});
test("only A or B counts as a saved resting side", () => {
assert.equal(savedRestSide("A"), "A");
assert.equal(savedRestSide("B"), "B");
for (const value of [undefined, null, "", "a", "b", "slide", 1, true]) assert.equal(savedRestSide(value), null);
});
test("an input with nothing to compare against rests on B", () => {
assert.equal(compareResultSide(null, from(1), view({})), "B");
assert.equal(compareResultSide(from(1), null, view({})), "B");
+4
View File
@@ -562,6 +562,10 @@
[
"MASK",
"mask"
],
[
"STRING",
"h3_prompt"
]
]
},
+19 -1
View File
@@ -1,7 +1,8 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { readFileSync } from 'node:fs';
import { clipSetsDuration, linkSource } from '../js/shared/h3_duration.mjs';
import { cameraChoiceLabel, clipSetsDuration, linkSource } from '../js/shared/h3_duration.mjs';
import { choiceLabel } from '../js/shared/widget_card_math.mjs';
const graphWith = (mode = 0, useMap = false) => {
const source = { id: 150, mode };
@@ -16,6 +17,23 @@ test('only the four backend duration overrides use the clip', () => {
for(const job of ['copy its moves','swap the person','new voice','change something']) assert.equal(clipSetsDuration(node,{video_job:job}),true);
for(const job of ['keep going','',undefined]) assert.equal(clipSetsDuration(node,{video_job:job}),false);
});
test('Camera\'s first choice reads "from the video" while a live clip gives H3 its camera', () => {
const {node,source}=graphWith();
const row={labels:cameraChoiceLabel};
const job=(value)=>{node.widgets=[{name:'video_job',value}];};
for(const value of ['copy its moves','swap the person','new voice','change something']) {
job(value);assert.equal(choiceLabel(row,'as typed',[],node),'from the video',value);
}
// Keep going makes new footage, so the camera is still the user's words.
job('keep going');assert.equal(choiceLabel(row,'as typed',[],node),'as typed');
job('swap the person');
// Only the first choice changes; a picked move keeps its own name.
assert.equal(choiceLabel(row,'slow push in',[],node),'slow push in');
// A muted clip, no clip, or no node: the plain name.
source.mode=4;assert.equal(choiceLabel(row,'as typed',[],node),'as typed');
source.mode=0;node.inputs[0].link=null;assert.equal(choiceLabel(row,'as typed',[],node),'as typed');
assert.equal(choiceLabel(row,'as typed',[]),'as typed');
});
test('Full Video OFF/bypassed/missing/disconnected restore seconds; both link stores work', () => {
for(const map of [false,true]) {
const {node,source}=graphWith(0,map);
+14
View File
@@ -12,6 +12,20 @@ test("mediaViewQuery names the file, its subfolder and its folder type", () => {
assert.equal(mediaViewQuery(null), "");
});
test("mediaViewQuery preserves leading spaces in the requested filename", () => {
const filename = " 00_25.083 frame=377.png";
for (const type of ["input", "output", "temp"]) {
const suffix = type === "input" ? "" : ` [${type}]`;
for (const subfolder of ["", "pasted"]) {
const prefix = subfolder ? `${subfolder}/` : "";
const query = new URLSearchParams(mediaViewQuery(`${prefix}${filename}${suffix}`));
assert.equal(query.get("filename"), filename);
assert.equal(query.get("subfolder"), subfolder);
assert.equal(query.get("type"), type);
}
}
});
test("filterMedia keeps values holding every term, ignoring case", () => {
const values = ["pasted/ausboss_night_bridge.png", "ausboss_day_sky_square.mp4", "Night_Alley.PNG"];
assert.deepEqual(filterMedia(values, ""), values);
+12
View File
@@ -58,6 +58,18 @@ test("both padded sides keep the multiple remainder on the far side", () => {
});
});
test("image references preserve filename whitespace around folder annotations", () => {
for (const suffix of ["", " [input]", " [output]", " [temp]"]) {
const type = suffix ? suffix.slice(2, -1) : "input";
for (const filename of [" 00_25.083 frame=377.png", " photo.png "]) {
assert.deepEqual(parseImageReference(filename + suffix), { filename, subfolder: "", type });
assert.deepEqual(parseImageReference(` sub\\dir\\${filename}${suffix}`), {
filename, subfolder: " sub/dir", type,
});
}
}
});
test("one padded side takes the whole remainder", () => {
// Pinned in tests/test_pad_helpers.py too.
assert.deepEqual(padGeometry(100, 64, pads(20, 0, 0, 0, 16)), {
+1
View File
@@ -209,6 +209,7 @@ test("deferred configuration cannot recreate removed or replaced panels", () =>
hideInputsInDef() {}, livePanels: new Set(), unwatchSource() {}, clearMedia() {},
buildPanel() { rebuilt += 1; return { eraser: {}, alive: true }; },
syncErase() {}, syncAdvanced() {}, scheduleRefresh() {}, getMode: () => "slide", updateModeButtons() {},
REST_PROPERTY: "ausboss_compare_rest", savedRestSide: () => null,
});
const file = kind === "compare" ? COMPARE : PREVIEW;
vm.runInContext('const NODE_NAME="Compare"; const REST_SETTING="test"; const NODE_CONFIG={Preview:{}}; const INPUT_SIDE=1;'
+19 -1
View File
@@ -2,7 +2,7 @@ import test from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import {
SEE_THROUGH_KEEP_PERCENT, blurMask, featherGeneratedMask, generatedAreaMask, growShrinkMask, overlayPlan, seeThroughMap,
SEE_THROUGH_KEEP_PERCENT, blurMask, featherGeneratedMask, generatedAreaMask, growShrinkMask, overlayPlan, pixelReadTrusted, seeThroughMap,
stitchBlendFromMask,
} from "../js/shared/stitch_preview.mjs";
import { resolveCrop, resolvePadding, rotatedSize, scaleToMegapixels } from "../js/shared/transform_geometry.mjs";
@@ -74,6 +74,24 @@ test("seeThroughMap leaves a solid picture alone and paints an empty one", () =>
assert.deepEqual(Array.from(seeThroughMap(pixels(0, 0, 0))), [1, 1, 1]);
});
// A blocked pixel read comes back all zero, which seeThroughMap would call
// see-through everywhere: the stage then drew nothing at all.
test("a blank or made-up pixel read is not trusted, a true or lightly noised one is", () => {
const read = (...px) => Uint8ClampedArray.from(px.flat());
assert.equal(pixelReadTrusted(read([255, 0, 0, 255], [0, 0, 255, 255])), true);
assert.equal(pixelReadTrusted(read([250, 3, 1, 255], [2, 1, 249, 255])), true);
assert.equal(pixelReadTrusted(read([0, 0, 0, 0], [0, 0, 0, 0])), false);
assert.equal(pixelReadTrusted(read([255, 255, 255, 255], [255, 255, 255, 255])), false);
assert.equal(pixelReadTrusted(read([255, 0, 0, 254], [0, 0, 255, 255])), false);
assert.equal(pixelReadTrusted(null), false);
});
test("the stage checks the browser's pixel reads before reading a picture's see-through parts", () => {
const editor = readFileSync(new URL("../js/shared/transform_editor.mjs", import.meta.url), "utf8");
const body = editor.slice(editor.indexOf("function maskLayer("), editor.indexOf("getImageData", editor.indexOf("function maskLayer(")));
assert.match(body, /canReadPixels\(\)/);
});
test("the see-through threshold is the backend's", () => {
const engine = readFileSync(new URL("../nodes/_transform_engine.py", import.meta.url), "utf8");
assert.equal(Number(/^SEE_THROUGH_KEEP_PERCENT = (\d+)$/m.exec(engine)?.[1]), SEE_THROUGH_KEEP_PERCENT);
+90
View File
@@ -0,0 +1,90 @@
"""Layout Boxes 🆎: the `h3_prompt` output (nodes/_layout_boxes_h3.py).
Plain Python, no torch."""
from __future__ import annotations
from pathlib import Path
import re
import sys
import unittest
ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(ROOT))
if "nodes" in sys.modules and not hasattr(sys.modules["nodes"], "__path__"):
del sys.modules["nodes"]
from nodes._layout_boxes_h3 import h3_prompt, share_words
SHAPE = (1344, 768)
def box(x, y, w, h, kind="obj", text="", desc="", angle=None):
region = {"x": x, "y": y, "w": w, "h": h, "type": kind, "text": text, "desc": desc, "palette": []}
if angle:
region["angle"] = angle
return region
TWO_PEOPLE = [box(0.08, 0.25, 0.22, 0.7), box(0.33, 0.3, 0.2, 0.65)]
class H3PromptTests(unittest.TestCase):
def test_no_boxes_give_no_prompt(self):
self.assertEqual(h3_prompt([], SHAPE, scene=True), "")
def test_empty_boxes_take_the_reference_pictures_in_box_order(self):
words = h3_prompt(TWO_PEOPLE, SHAPE, scene=True)
self.assertIn("the scene in <Picture 1>", words)
first, second = words.index("The person from <Picture 2>"), words.index("The person from <Picture 3>")
self.assertLess(first, second)
self.assertIn("with the same face, hair and clothes as in <Picture 2>. Placed", words)
def test_without_a_scene_the_subjects_start_at_picture_one(self):
words = h3_prompt(TWO_PEOPLE, SHAPE, scene=False)
self.assertNotIn("<Picture 3>", words)
self.assertIn("The person from <Picture 1>", words)
self.assertNotIn("the scene in", words)
def test_a_described_box_keeps_its_words_and_takes_no_picture(self):
regions = [box(0.7, 0.55, 0.25, 0.4, desc="a golden retriever lying on the rug"), *TWO_PEOPLE]
words = h3_prompt(regions, SHAPE, scene=True)
self.assertIn("A golden retriever lying on the rug. Placed low at the far right", words)
self.assertIn("<Picture 2>", words)
self.assertNotIn("<Picture 4>", words)
def test_places_and_neighbours_are_said_in_words(self):
words = h3_prompt(TWO_PEOPLE, SHAPE, scene=True)
self.assertIn("at the far left of the frame", words)
self.assertIn("right beside the person from <Picture 2>, on its right", words)
self.assertIn("two thirds of the frame's height and a quarter of its width", words)
def test_text_boxes_write_their_words_with_the_slant(self):
regions = [box(0.3, 0.04, 0.4, 0.12, kind="text", text="OPEN", desc="red neon letters", angle=10)]
words = h3_prompt(regions, SHAPE)
self.assertIn('The words "OPEN" are written high in the middle of the frame', words)
self.assertIn("The lettering: red neon letters, tilted about 10 degrees, running downhill", words)
def test_an_empty_text_box_is_left_out(self):
self.assertEqual(h3_prompt([box(0.1, 0.1, 0.2, 0.2, kind="text")], SHAPE), "")
def test_no_numbers_and_no_drawing_words_reach_the_model(self):
# Coordinates written in an H3 Image prompt come back drawn on the
# picture, so the prompt has no digit outside its <Picture N> tags.
regions = [
*TWO_PEOPLE,
box(0.6, 0.2, 0.3, 0.75, desc=""),
box(0.1, 0.02, 0.8, 0.1, kind="text", text="SALE", angle=-30),
]
words = h3_prompt(regions, SHAPE, scene=True)
bare = re.sub(r"<Picture \d+>", "", words).replace("tilted about 30 degrees", "")
self.assertIsNone(re.search(r"\d", bare), bare)
self.assertIsNone(re.search(r"\b(box|boxes|rectangle|outline|grid|coordinate)", bare, re.I), bare)
def test_share_words(self):
self.assertEqual(share_words(0.5), "half")
self.assertEqual(share_words(0.34), "a third")
self.assertEqual(share_words(0.95), "all")
if __name__ == "__main__":
unittest.main()
+15 -5
View File
@@ -54,7 +54,7 @@ class LayoutBoxesNode(unittest.TestCase):
def test_the_canvas_boxes_make_all_four_outputs(self):
out = self.node.draw(width=W, height=H, layout=layout(box(320, 96, 512, 640, desc="a cat"), box(0, 0, W, 64, "text", "OPEN", "neon")))
preview, frames, elements, mask = out["result"]
preview, frames, elements, mask, _words = out["result"]
self.assertEqual(tuple(preview.shape), (1, 585, 1024, 3), "the canvas's shape, 1024 on its long side")
self.assertEqual(preview.dtype, torch.float32)
self.assertTrue(0.0 <= float(preview.min()) and float(preview.max()) <= 1.0)
@@ -69,7 +69,7 @@ class LayoutBoxesNode(unittest.TestCase):
self.assertTrue(torch.equal(mask, expected), "1 inside every box, 0 elsewhere")
def test_no_boxes(self):
preview, frames, elements, mask = self.node.draw(width=512, height=1024)["result"]
preview, frames, elements, mask, _words = self.node.draw(width=512, height=1024)["result"]
self.assertEqual(tuple(preview.shape), (1, 1024, 512, 3))
self.assertEqual((frames, elements), ([], []))
self.assertEqual(tuple(mask.shape), (1, 1024, 512))
@@ -116,7 +116,7 @@ class LayoutBoxesNode(unittest.TestCase):
def test_a_turned_box_makes_a_turned_mask(self):
# 25, -55 and 90 degrees, apart on a 1344 x 768 canvas; each white area is its turned rectangle.
boxes = [dict(box(100, 300, 369, 103), angle=25), dict(box(560, 300, 300, 80), angle=-55), dict(box(1000, 250, 200, 100), angle=90)]
_preview, frames, elements, mask = self.node.draw(width=W, height=H, layout=layout(*boxes))["result"]
_preview, frames, elements, mask, _words = self.node.draw(width=W, height=H, layout=layout(*boxes))["result"]
self.assertEqual(tuple(mask.shape), (1, H, W))
def area(x0, x1):
return int(mask[0, :, x0:x1].sum())
@@ -144,9 +144,19 @@ class LayoutBoxesNode(unittest.TestCase):
self.assertEqual(before[2], after[2])
self.assertTrue(torch.equal(before[3], after[3]))
def test_h3_prompt_counts_the_background_as_picture_one(self):
person = box(100, 200, 300, 500)
plain = self.node.draw(width=W, height=H, layout=layout(person))["result"][4]
self.assertIn("The person from <Picture 1>", plain)
picture = torch.rand(1, H, W, 3)
with tempfile.TemporaryDirectory() as temp_dir, patch.object(node_layout_boxes, "folder_paths", fake_folder_paths(temp_dir)):
scene = self.node.draw(background=picture, width=W, height=H, layout=layout(person))["result"][4]
self.assertIn("the scene in <Picture 1>", scene)
self.assertIn("The person from <Picture 2>", scene)
def test_a_turned_text_box_tells_the_model_its_slant(self):
sign = dict(box(613, 300, 369, 102, "text", "No Phones", "bold black letters on a white sign"), angle=25.2)
_preview, frames, elements, _mask = self.node.draw(width=W, height=H, layout=layout(sign))["result"]
_preview, frames, elements, _mask, _words = self.node.draw(width=W, height=H, layout=layout(sign))["result"]
self.assertEqual(elements[0]["desc"], "bold black letters on a white sign, tilted about 25 degrees, running downhill to the right")
self.assertEqual(elements[0]["text"], "No Phones")
level = self.node.draw(width=W, height=H, layout=layout(dict(sign, angle=0)))["result"]
@@ -158,7 +168,7 @@ class LayoutBoxesNode(unittest.TestCase):
# shape, so the box is turned there and the mask is a true rectangle on the photo.
picture = torch.rand(1, 750, 1000, 3)
words = {"x": 0.4, "y": 0.4, "w": 0.3, "h": 0.08, "type": "text", "text": "SALE", "desc": "red letters", "angle": -30}
_preview, frames, _elements, mask = self.node.draw(background=picture, width=1024, height=1536, layout=layout(words))["result"]
_preview, frames, _elements, mask, _words = self.node.draw(background=picture, width=1024, height=1536, layout=layout(words))["result"]
self.assertEqual(tuple(mask.shape), (1, 750, 1000))
self.assertLess(abs(int(mask.sum()) - 300 * 60), 2 * (300 + 60), "300 x 60 photo pixels, turned")
cx, cy, a = 550, 330, math.radians(-30)
+9
View File
@@ -15,6 +15,7 @@ from aiohttp.test_utils import make_mocked_request
ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(ROOT))
from nodes import _media_upload
from nodes._media_upload import stream_video_upload, upload_name
@@ -83,6 +84,14 @@ class UploadTests(unittest.IsolatedAsyncioTestCase):
self.assertEqual(response.status, 400)
self.assertFalse((self.root / 'clip.mp4').exists())
async def test_upload_over_the_size_cap_is_refused_and_removed(self):
from unittest.mock import patch
with patch.object(_media_upload, 'MAX_VIDEO_UPLOAD_BYTES', len(self.body) - 1):
response = await self.upload(self.body)
self.assertEqual(response.status, 400)
self.assertIn('too large', response.text)
self.assertEqual(list(self.root.iterdir()), [])
def test_only_plain_supported_filenames_are_accepted(self):
for name in ['../clip.mp4', '/clip.mp4', 'C:\\clip.mp4', 'clip.py', 'x\0.mp4']:
with self.subTest(name=name), self.assertRaises(ValueError):