Commit Graph

561 Commits

Author SHA1 Message Date
guill 5cfe38f41c
Execution Model Inversion (#2666)
* Execution Model Inversion

This PR inverts the execution model -- from recursively calling nodes to
using a topological sort of the nodes. This change allows for
modification of the node graph during execution. This allows for two
major advantages:

    1. The implementation of lazy evaluation in nodes. For example, if a
    "Mix Images" node has a mix factor of exactly 0.0, the second image
    input doesn't even need to be evaluated (and visa-versa if the mix
    factor is 1.0).

    2. Dynamic expansion of nodes. This allows for the creation of dynamic
    "node groups". Specifically, custom nodes can return subgraphs that
    replace the original node in the graph. This is an incredibly
    powerful concept. Using this functionality, it was easy to
    implement:
        a. Components (a.k.a. node groups)
        b. Flow control (i.e. while loops) via tail recursion
        c. All-in-one nodes that replicate the WebUI functionality
        d. and more
    All of those were able to be implemented entirely via custom nodes,
    so those features are *not* a part of this PR. (There are some
    front-end changes that should occur before that functionality is
    made widely available, particularly around variant sockets.)

The custom nodes associated with this PR can be found at:
https://github.com/BadCafeCode/execution-inversion-demo-comfyui

Note that some of them require that variant socket types ("*") be
enabled.

* Allow `input_info` to be of type `None`

* Handle errors (like OOM) more gracefully

* Add a command-line argument to enable variants

This allows the use of nodes that have sockets of type '*' without
applying a patch to the code.

* Fix an overly aggressive assertion.

This could happen when attempting to evaluate `IS_CHANGED` for a node
during the creation of the cache (in order to create the cache key).

* Fix Pyright warnings

* Add execution model unit tests

* Fix issue with unused literals

Behavior should now match the master branch with regard to undeclared
inputs. Undeclared inputs that are socket connections will be used while
undeclared inputs that are literals will be ignored.

* Make custom VALIDATE_INPUTS skip normal validation

Additionally, if `VALIDATE_INPUTS` takes an argument named `input_types`,
that variable will be a dictionary of the socket type of all incoming
connections. If that argument exists, normal socket type validation will
not occur. This removes the last hurdle for enabling variant types
entirely from custom nodes, so I've removed that command-line option.

I've added appropriate unit tests for these changes.

* Fix example in unit test

This wouldn't have caused any issues in the unit test, but it would have
bugged the UI if someone copy+pasted it into their own node pack.

* Use fstrings instead of '%' formatting syntax

* Use custom exception types.

* Display an error for dependency cycles

Previously, dependency cycles that were created during node expansion
would cause the application to quit (due to an uncaught exception). Now,
we'll throw a proper error to the UI. We also make an attempt to 'blame'
the most relevant node in the UI.

* Add docs on when ExecutionBlocker should be used

* Remove unused functionality

* Rename ExecutionResult.SLEEPING to PENDING

* Remove superfluous function parameter

* Pass None for uneval inputs instead of default

This applies to `VALIDATE_INPUTS`, `check_lazy_status`, and lazy values
in evaluation functions.

* Add a test for mixed node expansion

This test ensures that a node that returns a combination of expanded
subgraphs and literal values functions correctly.

* Raise exception for bad get_node calls.

* Minor refactor of IsChangedCache.get

* Refactor `map_node_over_list` function

* Fix ui output for duplicated nodes

* Add documentation on `check_lazy_status`

* Add file for execution model unit tests

* Clean up Javascript code as per review

* Improve documentation

Converted some comments to docstrings as per review

* Add a new unit test for mixed lazy results

This test validates that when an output list is fed to a lazy node, the
node will properly evaluate previous nodes that are needed by any inputs
to the lazy node.

No code in the execution model has been changed. The test already
passes.

* Allow kwargs in VALIDATE_INPUTS functions

When kwargs are used, validation is skipped for all inputs as if they
had been mentioned explicitly.

* List cached nodes in `execution_cached` message

This was previously just bugged in this PR.
2024-08-15 11:21:11 -04:00
pythongosssss e60e19b175
Add support for simple tooltips (#3842)
* Add support for simple tooltips

* Fix overflow

* Add tooltips for nodes in the default workflow

* new line

* Prevent potential crash

* PR feedback

* Hide tooltip when clicking (e.g. combo widget)

* Refactor tooltips, add node level support

* Fix

* move

* Fix test (and undo last change)

* Fixed indent

* Fix dom widgets, dont show tooltip if not over canvas
2024-08-14 01:22:10 -04:00
comfyanonymous 17bbd83176 Fix bug loading flac workflow when it contains = character. 2024-08-02 13:14:28 -04:00
bymyself ab76abc767
Active workflow use primary fg color (#4090) 2024-07-27 23:34:19 -04:00
filtered b6779d8df3
Fix undo incorrectly undoing text input (#4114)
Fixes an issue where under certain conditions, the ComfyUI custom undo / redo functions would not run when intended to.

When trying to undo an action like deleting several nodes, instead the native browser undo runs - e.g. a textarea gets focus and the last typed text is undone.  Clicking outside the text area and typing again just keeps doing the same thing.
2024-07-26 12:25:42 -04:00
Chenlei Hu 6045ed31f8
Supress frontend exception on unhandled message type (#4078)
* Supress frontend exception on unhandled message type

* nit
2024-07-21 21:15:01 -04:00
Greg Wainer 11b74147ee
Fix/webp exif little endian (#4061)
* Fix for isLittleEndian flag in parseExifData.

* Add break after reading first exif chunk in getWebpMetadata.
2024-07-19 18:39:04 -04:00
bymyself 011b11d8d7
LoadAudio restores file value from workflow (#4043)
* LoadAudio restores file value from workflow

* use onAfterGraphConfigured

* Don't use anonnymous function
2024-07-18 21:59:18 -04:00
bymyself 374e093e09
Disable audio widget trying to get previews (#4044) 2024-07-17 16:11:10 -04:00
pythongosssss 79547efb65
New menu fixes - fix send to workflow (#3909)
* Fix send to workflow
Fix center align of close workflow dialog
Better support for elements around canvas

* More resilent to extra elements added to body
2024-07-14 02:04:40 -04:00
bymyself d160073829
Fix loadGraphData call during restore (#3976) 2024-07-09 11:23:26 -04:00
bymyself 24b969d3da
Skip state check hook on first load (#3915) 2024-07-03 20:30:07 -04:00
ruucm e53b1592ba
enable cmd shortcuts for mac (mute & bypass) (#3792) 2024-07-01 13:45:34 -04:00
Chenlei Hu 7c5fa7f4a2
Fix loadGraphData func call (#3918) 2024-07-01 12:10:44 -04:00
comfyanonymous 521421f53e Fix workflow not importing from flac files on some systems. 2024-06-30 15:51:54 -04:00
comfyanonymous 05e831697a Switch to the real cfg++ method in the samplers.
The old _pp ones will be updated automatically to the regular ones with 2x
the cfg.

My fault for not checking what the "_pp" samplers actually did.
2024-06-29 11:59:48 -04:00
comfyanonymous fbb7a1f1b6 PreviewAudio node. 2024-06-29 01:33:22 -04:00
pythongosssss 0d9009c96e
New menu/workflows fixes (#3900)
* Fix auto queue

* Detect added nodes via search

* Fix loading workflows

* Add button click style
2024-06-28 01:07:19 -04:00
Chenlei Hu 5ff3d4eb3a
Fix audio upload when no audio in input dir (#3891) 2024-06-27 09:13:52 -04:00
comfyanonymous 4650e7d6e9 Save and load workflow from the flac files output by SaveAudio. 2024-06-27 02:07:29 -04:00
Chenlei Hu 3b423afcca
Add audio widget (#3863)
* Add audio widget

* Fix audio bugs

* Add CSS

* Populate audio widget when load history
2024-06-27 00:22:55 -04:00
pythongosssss e3579f3360
Fix merge issue breaking api json loading (#3876) 2024-06-26 09:08:48 -04:00
Chenlei Hu e99d97a9d9
Remove duplicated Reset View button (#3865)
* Remove duplicated Reset View button

* Disable flaky test
2024-06-26 01:23:55 -04:00
pythongosssss 90aebb6c86
New Menu & Workflow Management (#3112)
* menu

* wip

* wip

* wip

* wip

* wip

* workflow saving/loading

* Support inserting workflows
Move buttosn to top of lists

* fix session storage
implement renaming

* temp

* refactor, better workflow instance management

* wip

* progress on progress

* added send to workflow
various fixes

* Support multiple image loaders

* Support dynamic size breakpoints based on content

* various fixes
add close unsaved warning

* Add filtering tree

* prevent renaming unsaved

* fix zindex on hover

* fix top offset

* use filename as workflow name

* resize on setting change

* hide element until it is drawn

* remove glow

* Fix export name

* Fix test, revert accidental changes to groupNode

* Fix colors on all themes

* show hover items on smaller screen (mobile)

* remove debugging code

* dialog fix

* Dont reorder open workflows
Allow elements around canvas

* Toggle body display on setting change

* Fix menu disappearing on chrome

* Increase delay when typing, remove margin on Safari, fix dialog location

* Fix overflow issue on iOS

* Add reset view button
Prevent view changes causing history entries

* Bottom menu wip

* Various fixes

* Fix merge

* Fix breaking old menu position

* Fix merge adding restore view to loadGraphData
2024-06-25 06:49:25 -04:00
Juanjuan 379ff92e9e
fix app.js no graph defined (#3754)
* local test

* fix "graph" not found

* fix

---------

Co-authored-by: Xiujuan Li <xiujuali@amazon.com>
2024-06-17 07:56:53 -04:00
comfyanonymous cb8d0ebccc Don't load the view coordinates when loading a workflow from the history.
I think this makes things slightly less annoying for some users.
2024-06-03 19:48:27 -04:00
luke zhang 34030fed92
improve dom widget performance (#3584) 2024-05-27 14:26:07 -04:00
Regis Gaughan, III f6a203951f
Extend core snapToGrid to LiteGraph Groups. (#3393)
Extends the core Comfy.SnapToGrid behavior for nodes to apply to LiteGraph's LGraphGroup with the same behavior. Also, pulls out redundant rounding code into util function.
2024-05-27 14:05:51 -04:00
DLohn 5b87369474
Load titles from API format JSON (#3563) 2024-05-24 23:53:15 -04:00
comfyanonymous 6507a9c716 Remove the CTRL-Delete keybind.
On some keyboards it's apparently too easy to accidentally do CTRL-Delete
when pressing CTRL-Enter repeatedly.

CTRL-Backspace can still be used to clear the workflow.
2024-05-23 01:29:22 -04:00
comfyanonymous 1c4af5918a Better error message if the webcam node doesn't work. 2024-05-17 14:02:09 -04:00
pythongosssss 91590adf04
Add webcam node (#3497)
* Add webcam node

* unused import
2024-05-17 13:16:08 -04:00
freakabcd cf6e1efb69
Show message on error when loading wf from file (works on drag and drop) (#3466) 2024-05-13 15:22:22 -04:00
comfyanonymous 4f63ee99f1 Add a button to reset the view. 2024-05-10 17:30:52 -04:00
pythongosssss f374ea714d
Setting for saving and restoring canvas position and zoom level (#3437) 2024-05-10 17:07:46 -04:00
Dr.Lt.Data d7fa417bfa
feat: shortcuts for zoom in/out (#3410)
* feat: shortcuts for zoom in/out

* feat: pen support for canvas zoom

ctrl + LMB + vertical drag

* Ctrl+LMB+Drag -> ctrl+Shift+LMB+Drag

---------

Co-authored-by: Lt.Dr.Data <lt.dr.data@gmail.com>
2024-05-07 04:40:56 -04:00
vilanele 9a70b70de4
add opacity slider in maskeditor (#3404)
Co-authored-by: vilanele <nomail@email.com>
2024-05-05 05:01:06 -04:00
comfyanonymous daa92a8ff4 Fix potential issues with the int rounding fix. 2024-05-03 05:49:21 -04:00
comfyanonymous 89d0e9abeb Fix int widgets rounding. 2024-05-02 03:34:19 -04:00
Torbjörn Lönnemark a88b0ebc2d
Improve node input/widget conversion sub-menus (#3281)
* Make input/widget conversion sub-menus optional

* Improve input/widget conversion sub-menu text

- Fix incorrect text for conversion from widget to input, previously it
  effectively said "convert input to input"
- Use "input" instead of "🔘".  The former is clearer and consistent
  with the rest of the application.
- Use title case (consistent with the rest of the menu entries).
- Strip the trailing periods. There is already a visual indicator for
  sub-menus, and no other sub-menus use trailing periods.
2024-04-18 16:41:23 -04:00
comfyanonymous d64e217427 Fix annoying float issue causing the value to be rounded to above the max. 2024-04-17 17:34:02 -04:00
Dr.Lt.Data 072e3bd2b5
Fixed an issue where the main menu disappears intermittently as the coordinates become negative. (#3269) 2024-04-17 16:36:49 -04:00
comfyanonymous 744ac944db Don't make dynamicPrompts the default on multiline string inputs.
This should be less confusing to those who want to use multiline input
without them.
2024-04-13 16:18:00 -04:00
NyaamZ 2bef134ebf
change Convert.. input (#3246) 2024-04-12 17:02:17 -04:00
comfyanonymous 4bd7d55b90 Add some colors to SamplerCustom links.
If you don't like them I am open to a PR.
2024-04-11 22:43:05 -04:00
Gorka Eguileor de172f8be7
Improve A1111 metadata parsing (#3216)
* A1111 import: Set VAE name

This patch sets the VAE name for the `VAELoader` when present in the png
metadata.

* A1111 import: Skip all hashes

When importing from A1111 the parsing assumes that values of a key will
never contain a ":", which is not correct.

There are 2 cases where we can have ":" in the value:

- Inside a string. E.g.:
  Lora hashes: "xl_more_art-full_v1: fe3b4816be83, add-detail-xl: 9c783c8ce46c"

- When the value is a json dictionary. E.g.:
  Hashes: {"vae": "63aeecb90f", "embed:negativeXL_D": "fff5d51ab6"}

This patch changes how we parse the metadata to take those 2 cases into
account and also skips the following additional keys that are present in
some Forge images:

- Version
- VAE hash
- TI hashes
- Lora hashes
- Hashes

* A1111 import: Parse Hires steps

This patch parses the `Hires steps` parameter that is part of the High
Resolution Upscale configuration when it  is present, and fallbacks to
the one from the `samplerNode` (like the code currently does) if it's
not present.
2024-04-06 12:10:17 -04:00
comfyanonymous a7dd82e668 Fix copy paste issue with litegraph. 2024-04-05 14:59:05 -04:00
shiimizu 5171414143 Support additional PNG info. 2024-02-18 17:57:53 -08:00
chrisgoringe cf4910a3a4
Prevent hideWidget being called twice for same widget
Fix for #2766
2024-02-12 08:59:25 +11:00
Steven Lu 02409c30d9
Safari: Draws certain elements on CPU. In case of search popup, can cause 10 seconds+ main thread lock due to painting. (#2763)
* lets toggle this setting first.

* also makes it easier for debug. I'll be honest this is generally preferred behavior as well for me but I ain't no power user shrug.

* attempting trick to put the work for filter: brightness on GPU as a first attempt before falling back to not using filter for large lists!

* revert litegraph.core.js changes from branch

* oops
2024-02-12 03:44:53 +09:00