2023-04-05 23:41:23 -04:00
import argparse
2023-06-05 13:19:02 -05:00
import enum
2024-07-16 11:26:11 -04:00
import os
2023-09-13 11:38:20 -04:00
import comfy . options
2023-06-05 13:19:02 -05:00
2024-07-16 11:26:11 -04:00
2023-06-05 13:19:02 -05:00
class EnumAction ( argparse . Action ) :
"""
Argparse action for handling Enums
"""
def __init__ ( self , * * kwargs ) :
# Pop off the type value
enum_type = kwargs . pop ( " type " , None )
# Ensure an Enum subclass is provided
if enum_type is None :
raise ValueError ( " type must be assigned an Enum when using EnumAction " )
if not issubclass ( enum_type , enum . Enum ) :
raise TypeError ( " type must be an Enum when using EnumAction " )
# Generate choices from the Enum
choices = tuple ( e . value for e in enum_type )
kwargs . setdefault ( " choices " , choices )
kwargs . setdefault ( " metavar " , f " [ { ' , ' . join ( list ( choices ) ) } ] " )
super ( EnumAction , self ) . __init__ ( * * kwargs )
self . _enum = enum_type
def __call__ ( self , parser , namespace , values , option_string = None ) :
# Convert value back into an Enum
value = self . _enum ( values )
setattr ( namespace , self . dest , value )
2023-04-05 23:41:23 -04:00
parser = argparse . ArgumentParser ( )
2024-09-23 04:38:19 -04:00
parser . add_argument ( " --listen " , type = str , default = " 127.0.0.1 " , metavar = " IP " , nargs = " ? " , const = " 0.0.0.0,:: " , help = " Specify the IP address to listen on (default: 127.0.0.1). You can give a list of ip addresses by separating them with a comma like: 127.2.2.2,127.3.3.3 If --listen is provided without an argument, it defaults to 0.0.0.0,:: (listens on all ipv4 and ipv6) " )
2023-04-05 23:41:23 -04:00
parser . add_argument ( " --port " , type = int , default = 8188 , help = " Set the listen port. " )
2024-04-30 20:17:02 -04:00
parser . add_argument ( " --tls-keyfile " , type = str , help = " Path to TLS (SSL) key file. Enables TLS, makes app accessible at https://... requires --tls-certfile to function " )
parser . add_argument ( " --tls-certfile " , type = str , help = " Path to TLS (SSL) certificate file. Enables TLS, makes app accessible at https://... requires --tls-keyfile to function " )
2023-04-06 19:06:39 -04:00
parser . add_argument ( " --enable-cors-header " , type = str , default = None , metavar = " ORIGIN " , nargs = " ? " , const = " * " , help = " Enable CORS (Cross-Origin Resource Sharing) with optional origin or allow all with default ' * ' . " )
2023-10-29 03:55:46 -04:00
parser . add_argument ( " --max-upload-size " , type = float , default = 100 , help = " Set the maximum upload size in MB. " )
2025-01-30 00:06:28 +11:00
parser . add_argument ( " --base-directory " , type = str , default = None , help = " Set the ComfyUI base directory for models, custom_nodes, input, output, temp, and user directories. " )
2023-04-06 19:06:39 -04:00
parser . add_argument ( " --extra-model-paths-config " , type = str , default = None , metavar = " PATH " , nargs = ' + ' , action = ' append ' , help = " Load one or more extra_model_paths.yaml files. " )
2025-01-30 00:06:28 +11:00
parser . add_argument ( " --output-directory " , type = str , default = None , help = " Set the ComfyUI output directory. Overrides --base-directory. " )
parser . add_argument ( " --temp-directory " , type = str , default = None , help = " Set the ComfyUI temp directory (default is in the ComfyUI directory). Overrides --base-directory. " )
parser . add_argument ( " --input-directory " , type = str , default = None , help = " Set the ComfyUI input directory. Overrides --base-directory. " )
2023-05-06 16:59:40 -04:00
parser . add_argument ( " --auto-launch " , action = " store_true " , help = " Automatically launch ComfyUI in the default browser. " )
2023-08-07 02:22:26 -04:00
parser . add_argument ( " --disable-auto-launch " , action = " store_true " , help = " Disable auto launching the browser. " )
2023-04-06 19:06:39 -04:00
parser . add_argument ( " --cuda-device " , type = int , default = None , metavar = " DEVICE_ID " , help = " Set the id of the cuda device this instance will use. " )
2023-07-17 14:40:29 -04:00
cm_group = parser . add_mutually_exclusive_group ( )
2024-08-14 08:38:07 -04:00
cm_group . add_argument ( " --cuda-malloc " , action = " store_true " , help = " Enable cudaMallocAsync (enabled by default for torch 2.0 and up). " )
cm_group . add_argument ( " --disable-cuda-malloc " , action = " store_true " , help = " Disable cudaMallocAsync. " )
2023-07-17 14:40:29 -04:00
2023-07-01 22:42:35 -04:00
fp_group = parser . add_mutually_exclusive_group ( )
fp_group . add_argument ( " --force-fp32 " , action = " store_true " , help = " Force fp32 (If this makes your GPU work better please report it). " )
fp_group . add_argument ( " --force-fp16 " , action = " store_true " , help = " Force fp16. " )
2023-12-04 11:10:00 -05:00
fpunet_group = parser . add_mutually_exclusive_group ( )
2024-11-25 05:00:23 -05:00
fpunet_group . add_argument ( " --fp32-unet " , action = " store_true " , help = " Run the diffusion model in fp32. " )
fpunet_group . add_argument ( " --fp64-unet " , action = " store_true " , help = " Run the diffusion model in fp64. " )
fpunet_group . add_argument ( " --bf16-unet " , action = " store_true " , help = " Run the diffusion model in bf16. " )
fpunet_group . add_argument ( " --fp16-unet " , action = " store_true " , help = " Run the diffusion model in fp16 " )
2023-12-04 11:10:00 -05:00
fpunet_group . add_argument ( " --fp8_e4m3fn-unet " , action = " store_true " , help = " Store unet weights in fp8_e4m3fn. " )
fpunet_group . add_argument ( " --fp8_e5m2-unet " , action = " store_true " , help = " Store unet weights in fp8_e5m2. " )
2025-04-22 03:17:38 -07:00
fpunet_group . add_argument ( " --fp8_e8m0fnu-unet " , action = " store_true " , help = " Store unet weights in fp8_e8m0fnu. " )
2023-10-13 14:51:10 -04:00
2023-07-06 18:04:28 -04:00
fpvae_group = parser . add_mutually_exclusive_group ( )
fpvae_group . add_argument ( " --fp16-vae " , action = " store_true " , help = " Run the VAE in fp16, might cause black images. " )
2023-08-27 23:06:19 -04:00
fpvae_group . add_argument ( " --fp32-vae " , action = " store_true " , help = " Run the VAE in full precision fp32. " )
fpvae_group . add_argument ( " --bf16-vae " , action = " store_true " , help = " Run the VAE in bf16. " )
2023-07-06 18:04:28 -04:00
2023-12-30 05:38:21 -05:00
parser . add_argument ( " --cpu-vae " , action = " store_true " , help = " Run the VAE on the CPU. " )
2023-11-17 02:56:59 -05:00
fpte_group = parser . add_mutually_exclusive_group ( )
fpte_group . add_argument ( " --fp8_e4m3fn-text-enc " , action = " store_true " , help = " Store text encoder weights in fp8 (e4m3fn variant). " )
fpte_group . add_argument ( " --fp8_e5m2-text-enc " , action = " store_true " , help = " Store text encoder weights in fp8 (e5m2 variant). " )
fpte_group . add_argument ( " --fp16-text-enc " , action = " store_true " , help = " Store text encoder weights in fp16. " )
fpte_group . add_argument ( " --fp32-text-enc " , action = " store_true " , help = " Store text encoder weights in fp32. " )
2025-04-01 23:18:53 +05:30
fpte_group . add_argument ( " --bf16-text-enc " , action = " store_true " , help = " Store text encoder weights in bf16. " )
2023-11-17 02:56:59 -05:00
2024-06-15 01:08:12 -04:00
parser . add_argument ( " --force-channels-last " , action = " store_true " , help = " Force channels last format when inferencing the models. " )
2023-11-17 02:56:59 -05:00
2023-04-28 16:51:35 -04:00
parser . add_argument ( " --directml " , type = int , nargs = " ? " , metavar = " DIRECTML_DEVICE " , const = - 1 , help = " Use torch-directml. " )
2023-04-05 23:41:23 -04:00
2024-12-23 00:18:32 -08:00
parser . add_argument ( " --oneapi-device-selector " , type = str , default = None , metavar = " SELECTOR_STRING " , help = " Sets the oneAPI device(s) this instance will use. " )
parser . add_argument ( " --disable-ipex-optimize " , action = " store_true " , help = " Disables ipex.optimize default when loading models with Intel ' s Extension for Pytorch. " )
2025-05-23 14:43:50 -07:00
parser . add_argument ( " --supports-fp8-compute " , action = " store_true " , help = " ComfyUI will act like if the device supports fp8 compute. " )
2023-08-17 03:12:17 -07:00
2023-06-05 18:59:10 -05:00
class LatentPreviewMethod ( enum . Enum ) :
2023-06-06 01:26:52 -04:00
NoPreviews = " none "
2023-06-05 18:59:10 -05:00
Auto = " auto "
2023-06-05 18:39:56 -05:00
Latent2RGB = " latent2rgb "
2023-06-05 13:19:02 -05:00
TAESD = " taesd "
2023-06-06 01:26:52 -04:00
parser . add_argument ( " --preview-method " , type = LatentPreviewMethod , default = LatentPreviewMethod . NoPreviews , help = " Default preview method for sampler nodes. " , action = EnumAction )
2023-06-05 13:19:02 -05:00
2024-09-04 01:16:38 +02:00
parser . add_argument ( " --preview-size " , type = int , default = 512 , help = " Sets the maximum preview size for sampler nodes. " )
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 08:21:11 -07:00
cache_group = parser . add_mutually_exclusive_group ( )
cache_group . add_argument ( " --cache-classic " , action = " store_true " , help = " Use the old style (aggressive) caching. " )
cache_group . add_argument ( " --cache-lru " , type = int , default = 0 , help = " Use LRU caching with a maximum of N node results cached. May use more RAM/VRAM. " )
2025-04-11 11:55:51 +01:00
cache_group . add_argument ( " --cache-none " , action = " store_true " , help = " Reduced RAM/VRAM usage at the expense of executing every node for each run. " )
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 08:21:11 -07:00
2023-04-05 23:41:23 -04:00
attn_group = parser . add_mutually_exclusive_group ( )
2023-06-26 12:55:07 -04:00
attn_group . add_argument ( " --use-split-cross-attention " , action = " store_true " , help = " Use the split cross attention optimization. Ignored when xformers is used. " )
attn_group . add_argument ( " --use-quad-cross-attention " , action = " store_true " , help = " Use the sub-quadratic cross attention optimization . Ignored when xformers is used. " )
2023-04-05 23:41:23 -04:00
attn_group . add_argument ( " --use-pytorch-cross-attention " , action = " store_true " , help = " Use the new pytorch 2.0 cross attention function. " )
2024-12-18 01:56:10 -05:00
attn_group . add_argument ( " --use-sage-attention " , action = " store_true " , help = " Use sage attention. " )
2025-03-14 08:22:41 +01:00
attn_group . add_argument ( " --use-flash-attention " , action = " store_true " , help = " Use FlashAttention. " )
2023-04-05 23:41:23 -04:00
parser . add_argument ( " --disable-xformers " , action = " store_true " , help = " Disable xformers. " )
2024-05-16 04:09:41 -04:00
upcast = parser . add_mutually_exclusive_group ( )
upcast . add_argument ( " --force-upcast-attention " , action = " store_true " , help = " Force enable attention upcasting, please report if it fixes black images. " )
upcast . add_argument ( " --dont-upcast-attention " , action = " store_true " , help = " Disable all upcasting of attention. Should be unnecessary except for debugging. " )
2023-04-05 23:41:23 -04:00
vram_group = parser . add_mutually_exclusive_group ( )
2023-06-15 15:21:37 -04:00
vram_group . add_argument ( " --gpu-only " , action = " store_true " , help = " Store and run everything (text encoders/CLIP models, etc... on the GPU). " )
2023-04-05 23:41:23 -04:00
vram_group . add_argument ( " --highvram " , action = " store_true " , help = " By default models will be unloaded to CPU memory after being used. This option keeps them in GPU memory. " )
vram_group . add_argument ( " --normalvram " , action = " store_true " , help = " Used to force normal vram use if lowvram gets automatically enabled. " )
vram_group . add_argument ( " --lowvram " , action = " store_true " , help = " Split the unet in parts to use less vram. " )
vram_group . add_argument ( " --novram " , action = " store_true " , help = " When lowvram isn ' t enough. " )
vram_group . add_argument ( " --cpu " , action = " store_true " , help = " To use the CPU for everything (slow). " )
2024-12-28 06:40:05 +11:00
parser . add_argument ( " --reserve-vram " , type = float , default = None , help = " Set the amount of vram in GB you want to reserve for use by your OS/other software. By default some amount is reserved depending on your OS. " )
2024-08-19 17:16:18 -04:00
2025-04-26 13:11:21 -07:00
parser . add_argument ( " --async-offload " , action = " store_true " , help = " Use async weight offloading. " )
2024-08-19 17:16:18 -04:00
2024-07-16 18:27:09 -04:00
parser . add_argument ( " --default-hashing-function " , type = str , choices = [ ' md5 ' , ' sha1 ' , ' sha256 ' , ' sha512 ' ] , default = ' sha256 ' , help = " Allows you to choose the hash function to use for duplicate filename / contents comparison. Default is sha256. " )
2023-06-15 15:21:37 -04:00
2023-08-17 03:12:37 -04:00
parser . add_argument ( " --disable-smart-memory " , action = " store_true " , help = " Force ComfyUI to agressively offload to regular ram instead of keeping models in vram when it can. " )
2023-12-17 16:59:21 -05:00
parser . add_argument ( " --deterministic " , action = " store_true " , help = " Make pytorch use slower deterministic algorithms when it can. Note that this might not make images deterministic in all cases. " )
2025-03-01 02:37:35 -05:00
class PerformanceFeature ( enum . Enum ) :
Fp16Accumulation = " fp16_accumulation "
2025-03-01 02:43:49 -05:00
Fp8MatrixMultiplication = " fp8_matrix_mult "
2025-04-12 18:29:15 -04:00
CublasOps = " cublas_ops "
2025-03-01 02:37:35 -05:00
2025-04-12 18:29:15 -04:00
parser . add_argument ( " --fast " , nargs = " * " , type = PerformanceFeature , help = " Enable some untested and potentially quality deteriorating optimizations. --fast with no arguments enables everything. You can pass a list specific optimizations if you only want to enable specific ones. Current valid optimizations: fp16_accumulation fp8_matrix_mult cublas_ops " )
2023-08-17 03:12:37 -04:00
2025-05-09 01:52:47 -07:00
parser . add_argument ( " --mmap-torch-files " , action = " store_true " , help = " Use mmap when loading ckpt/pt files. " )
2023-04-05 23:41:23 -04:00
parser . add_argument ( " --dont-print-server " , action = " store_true " , help = " Don ' t print server output. " )
parser . add_argument ( " --quick-test-for-ci " , action = " store_true " , help = " Quick test for CI. " )
2023-04-07 15:52:56 -04:00
parser . add_argument ( " --windows-standalone-build " , action = " store_true " , help = " Windows standalone build: Enable convenient things that most people using the standalone windows build will probably enjoy (like auto opening the page on startup). " )
2023-04-05 23:41:23 -04:00
2023-07-28 12:31:41 -04:00
parser . add_argument ( " --disable-metadata " , action = " store_true " , help = " Disable saving prompt metadata in files. " )
2024-07-01 17:54:03 -04:00
parser . add_argument ( " --disable-all-custom-nodes " , action = " store_true " , help = " Disable loading all custom nodes. " )
2025-05-06 01:53:53 -07:00
parser . add_argument ( " --disable-api-nodes " , action = " store_true " , help = " Disable loading all api nodes. " )
2023-07-28 12:31:41 -04:00
2024-01-11 17:21:40 -05:00
parser . add_argument ( " --multi-user " , action = " store_true " , help = " Enables per-user storage. " )
2024-01-08 22:06:44 +00:00
2024-10-04 10:05:34 -04:00
parser . add_argument ( " --verbose " , default = ' INFO ' , const = ' DEBUG ' , nargs = " ? " , choices = [ ' DEBUG ' , ' INFO ' , ' WARNING ' , ' ERROR ' , ' CRITICAL ' ] , help = ' Set the logging level ' )
2024-12-28 06:40:05 +11:00
parser . add_argument ( " --log-stdout " , action = " store_true " , help = " Send normal process output to stdout instead of stderr (default). " )
2024-03-10 11:37:08 -04:00
2024-07-16 11:26:11 -04:00
# The default built-in provider hosted under web/
DEFAULT_VERSION_STRING = " comfyanonymous/ComfyUI@latest "
parser . add_argument (
" --front-end-version " ,
type = str ,
default = DEFAULT_VERSION_STRING ,
help = """
Specifies the version of the frontend to be used . This command needs internet connectivity to query and
download available frontend implementations from GitHub releases .
The version string should be in the format of :
[ repoOwner ] / [ repoName ] @ [ version ]
where version is one of : " latest " or a valid version number ( e . g . " 1.0.0 " )
""" ,
)
2025-03-05 21:34:22 +01:00
def is_valid_directory ( path : str ) - > str :
""" Validate if the given path is a directory, and check permissions. """
if not os . path . exists ( path ) :
raise argparse . ArgumentTypeError ( f " The path ' { path } ' does not exist. " )
2024-07-16 11:26:11 -04:00
if not os . path . isdir ( path ) :
2025-03-05 21:34:22 +01:00
raise argparse . ArgumentTypeError ( f " ' { path } ' is not a directory. " )
if not os . access ( path , os . R_OK ) :
raise argparse . ArgumentTypeError ( f " You do not have read permissions for ' { path } ' . " )
2024-07-16 11:26:11 -04:00
return path
parser . add_argument (
" --front-end-root " ,
type = is_valid_directory ,
default = None ,
help = " The local filesystem path to the directory where the frontend is located. Overrides --front-end-version. " ,
)
2024-03-10 11:37:08 -04:00
2025-01-30 00:06:28 +11:00
parser . add_argument ( " --user-directory " , type = is_valid_directory , default = None , help = " Set the ComfyUI user directory with an absolute path. Overrides --base-directory. " )
2024-09-12 21:10:27 +09:00
2025-02-07 03:29:12 -05:00
parser . add_argument ( " --enable-compress-response-body " , action = " store_true " , help = " Enable compressing response body. " )
2025-02-02 22:24:55 +08:00
More API Nodes (#7956)
* Add Ideogram generate node.
* Add staging api.
* Add API_NODE and common error for missing auth token (#5)
* Add Minimax Video Generation + Async Task queue polling example (#6)
* [Minimax] Show video preview and embed workflow in ouput (#7)
* Remove uv.lock
* Remove polling operations.
* Revert "Remove polling operations."
* Update stubs.
* Added Ideogram and Minimax back in.
* Added initial BFL Flux 1.1 [pro] Ultra node (#11)
* Add --comfy-api-base launch arg (#13)
* Add instructions for staging development. (#14)
* remove validation to make it easier to run against LAN copies of the API
* Manually add BFL polling status response schema (#15)
* Add function for uploading files. (#18)
* Add Luma nodes (#16)
* Refactor util functions (#20)
* Add VIDEO type (#21)
* Add rest of Luma node functionality (#19)
* Fix image_luma_ref not working (#28)
* [Bug] Remove duplicated option T2V-01 in MinimaxTextToVideoNode (#31)
* Add utils to map from pydantic model fields to comfy node inputs (#30)
* add veo2, bump av req (#32)
* Add Recraft nodes (#29)
* Add Kling Nodes (#12)
* Add Camera Concepts (luma_concepts) to Luma Video nodes (#33)
* Add Runway nodes (#17)
* Convert Minimax node to use VIDEO output type (#34)
* Standard `CATEGORY` system for api nodes (#35)
* Set `Content-Type` header when uploading files (#36)
* add better error propagation to veo2 (#37)
* Add Realistic Image and Logo Raster styles for Recraft v3 (#38)
* Fix runway image upload and progress polling (#39)
* Fix image upload for Luma: only include `Content-Type` header field if it's set explicitly (#40)
* Moved Luma nodes to nodes_luma.py (#47)
* Moved Recraft nodes to nodes_recraft.py (#48)
* Add Pixverse nodes (#46)
* Move and fix BFL nodes to node_bfl.py (#49)
* Move and edit Minimax node to nodes_minimax.py (#50)
* Add Minimax Image to Video node + Cleanup (#51)
* Add Recraft Text to Vector node, add Save SVG node to handle its output (#53)
* Added pixverse_template support to Pixverse Text to Video node (#54)
* Added Recraft Controls + Recraft Color RGB nodes (#57)
* split remaining nodes out of nodes_api, make utility lib, refactor ideogram (#61)
* Add types and doctstrings to utils file (#64)
* Fix: `PollingOperation` progress bar update progress by absolute value (#65)
* Use common download function in kling nodes module (#67)
* Fix: Luma video nodes in `api nodes/image` category (#68)
* Set request type explicitly (#66)
* Add `control_after_generate` to all seed inputs (#69)
* Fix bug: deleting `Content-Type` when property does not exist (#73)
* Add preview to Save SVG node (#74)
* change default poll interval (#76), rework veo2
* Add Pixverse and updated Kling types (#75)
* Added Pixverse Image to VIdeo node (#77)
* Add Pixverse Transition Video node (#79)
* Proper ray-1-6 support as fix has been applied in backend (#80)
* Added Recraft Style - Infinite Style Library node (#82)
* add ideogram v3 (#83)
* [Kling] Split Camera Control config to its own node (#81)
* Add Pika i2v and t2v nodes (#52)
* Temporary Fix for Runway (#87)
* Added Stability Stable Image Ultra node (#86)
* Remove Runway nodes (#88)
* Fix: Prompt text can't be validated in Kling nodes when using primitive nodes (#90)
* Fix: typo in node name "Stabiliy" => "Stability" (#91)
* Add String (Multiline) node (#93)
* Update Pika Duration and Resolution options (#94)
* Change base branch to master. Not main. (#95)
* Fix UploadRequest file_name param (#98)
* Removed Infinite Style Library until later (#99)
* fix ideogram style types (#100)
* fix multi image return (#101)
* add metadata saving to SVG (#102)
* Bump templates version to include API node template workflows (#104)
* Fix: `download_url_to_video_output` return type (#103)
* fix 4o generation bug (#106)
* Serve SVG files directly (#107)
* Add a bunch of nodes, 3 ready to use, the rest waiting for endpoint support (#108)
* Revert "Serve SVG files directly" (#111)
* Expose 4 remaining Recraft nodes (#112)
* [Kling] Add `Duration` and `Video ID` outputs (#105)
* Fix: datamodel-codegen sets string#binary type to non-existent `bytes_aliased` variable (#114)
* Fix: Dall-e 2 not setting request content-type dynamically (#113)
* Default request timeout: one hour. (#116)
* Add Kling nodes: camera control, start-end frame, lip-sync, video extend (#115)
* Add 8 nodes - 4 BFL, 4 Stability (#117)
* Fix error for Recraft ImageToImage error for nonexistent random_seed param (#118)
* Add remaining Pika nodes (#119)
* Make controls input work for Recraft Image to Image node (#120)
* Use upstream PR: Support saving Comfy VIDEO type to buffer (#123)
* Use Upstream PR: "Fix: Error creating video when sliced audio tensor chunks are non-c-contiguous" (#127)
* Improve audio upload utils (#128)
* Fix: Nested `AnyUrl` in request model cannot be serialized (Kling, Runway) (#129)
* Show errors and API output URLs to the user (change log levels) (#131)
* Fix: Luma I2I fails when weight is <=0.01 (#132)
* Change category of `LumaConcepts` node from image to video (#133)
* Fix: `image.shape` accessed before `image` is null-checked (#134)
* Apply small fixes and most prompt validation (if needed to avoid API error) (#135)
* Node name/category modifications (#140)
* Add back Recraft Style - Infinite Style Library node (#141)
* Fixed Kling: Check attributes of pydantic types. (#144)
* Bump `comfyui-workflow-templates` version (#142)
* [Kling] Print response data when error validating response (#146)
* Fix: error validating Kling image response, trying to use `"key" in` on Pydantic class instance (#147)
* [Kling] Fix: Correct/verify supported subset of input combos in Kling nodes (#149)
* [Kling] Fix typo in node description (#150)
* [Kling] Fix: CFG min/max not being enforced (#151)
* Rebase launch-rebase (private) on prep-branch (public copy of master) (#153)
* Bump templates version (#154)
* Fix: Kling image gen nodes don't return entire batch when `n` > 1 (#152)
* Remove pixverse_template from PixVerse Transition Video node (#155)
* Invert image_weight value on Luma Image to Image node (#156)
* Invert and resize mask for Ideogram V3 node to match masking conventions (#158)
* [Kling] Fix: image generation nodes not returning Tuple (#159)
* [Bug] [Kling] Fix Kling camera control (#161)
* Kling Image Gen v2 + improve node descriptions for Flux/OpenAI (#160)
* [Kling] Don't return video_id from dual effect video (#162)
* Bump frontend to 1.18.8 (#163)
* Use 3.9 compat syntax (#164)
* Use Python 3.10
* add example env var
* Update templates to 0.1.11
* Bump frontend to 1.18.9
---------
Co-authored-by: Robin Huang <robin.j.huang@gmail.com>
Co-authored-by: Christian Byrne <cbyrne@comfy.org>
Co-authored-by: thot experiment <94414189+thot-experiment@users.noreply.github.com>
2025-05-06 03:23:00 -05:00
parser . add_argument (
" --comfy-api-base " ,
type = str ,
default = " https://api.comfy.org " ,
help = " Set the base URL for the ComfyUI API. (default: https://api.comfy.org) " ,
)
2023-09-13 11:38:20 -04:00
if comfy . options . args_parsing :
args = parser . parse_args ( )
else :
args = parser . parse_args ( [ ] )
2023-05-06 16:59:40 -04:00
if args . windows_standalone_build :
args . auto_launch = True
2023-08-07 02:22:26 -04:00
if args . disable_auto_launch :
args . auto_launch = False
2025-02-11 08:31:46 -05:00
if args . force_fp16 :
args . fp16_unet = True
2025-03-01 02:37:35 -05:00
# '--fast' is not provided, use an empty set
if args . fast is None :
args . fast = set ( )
# '--fast' is provided with an empty list, enable all optimizations
elif args . fast == [ ] :
args . fast = set ( PerformanceFeature )
# '--fast' is provided with a list of performance features, use that list
else :
args . fast = set ( args . fast )