o
    ivF                     @   s  d dl Z d dlZd dlZd dlZG dd de jZe  Zej	de
ddddd	d
 ej	deddd ej	de
dd ej	de
dd ej	de
dddddd
 ej	deddd ej	de
ddd ej	de
dddd d!d" ej	d#e
dd$d ej	d%e
dd&d ej	d'e
dd(d ej	d)d*d+d, ej	d-d*d.d, ej	d/edd0d1d2 ej	d3edd4d5d2 e Zej	d6d*d7d, ej	d8d*d9d, e Zej	d:d*d;d, ej	d<d*d=d, e Zej	d>d*d?d, ej	d@d*dAd, ej	dBd*dCd, ej	dDd*dEd, ej	dFd*dGd, ej	dHd*dId, ej	dJd*dKd, e Zej	dLd*dMd, ej	dNd*dOd, ej	dPd*dQd, ej	dRd*dSd, e Zej	dTd*dUd, ej	dVd*dWd, ej	dXd*dYd, ej	dZd*d[d, ej	d\d*d]d, ej	d^d*d_d, ej	d`d*dad, ej	dbeddcdddedf ej	dge
ddhdid2 ej	djd*dkd, ej	dld*dmd, G dndo doejZej	dpeejdqedr ej	dsedtdud dvZe Zej	dwd*dxd, ej	dyed dzd ej	d{d*d|d, ej	d}deed d~d e Zej	dd*dd, ej	dd*dd, ej	dd*dd, ej	dd*dd, ej	dd*dd, ej	dd*dd, e Zej	dd*dd, ej	dd*dd, ej	dd*dd, e Zej	dd*dd, ej	dd*dd, e Zej	dd*dd, ej	dd*dd, ej	dd*dd, ej	dd*dd, ej	dd*dd, ej	dd*dd, ej	deddd ej	dddedddd ej	dd*dd, ej	dd*dd, ej	dd*dd, ej	dd*dd, ej	de
g dddd ej	dd*dd, ej	dd*dd, G dd dejZej	ddeddedd ed ej	dd*dd, ej	dd*dd, ej	dd*dd, ej	dd*dd, ej	dd*dd, ej	dd*dd, ej	dd*dd, ej	dd*dd, ej	de
dg ddԍ ej	dd*dd, ej	dd*dd, ej	ddddg dܢddލ ej	dd*dd, dZ ej	de
e dd de
de
fddZ!ej	de!ddd ej	de!ddd ej	dd*dd, ej	de
ddd ej"#ej"ej"$e%dddZ&ej	de
de& dd ej	dd*dd, ej'j(re) Z*ne)g Z*e*j+rde*_,e*j-rde*_,e*j.rde*_/e*j0du re1 e*_0ne*j0g kre1ee*_0ne1e*j0e*_0dd Z2dS )    Nc                       s*   e Zd ZdZ fddZdddZ  ZS )
EnumActionz,
    Argparse action for handling Enums
    c                    s   | dd }|d u rtdt|tjstdtdd |D }|d| |ddd	t	| d
 t
t| jdi | || _d S )Ntypez3type must be assigned an Enum when using EnumActionz*type must be an Enum when using EnumActionc                 s   s    | ]}|j V  qd S Nvalue).0e r	   ,/mnt/c/Users/fbmor/ComfyUI/comfy/cli_args.py	<genexpr>   s    z&EnumAction.__init__.<locals>.<genexpr>choicesmetavar[,]r	   )pop
ValueError
issubclassenumEnum	TypeErrortuple
setdefaultjoinlistsuperr   __init___enum)selfkwargs	enum_typer   	__class__r	   r
   r      s   
zEnumAction.__init__Nc                 C   s   |  |}t|| j| d S r   )r   setattrdest)r   parser	namespacevaluesoption_stringr   r	   r	   r
   __call__   s   
zEnumAction.__call__r   )__name__
__module____qualname____doc__r   r)   __classcell__r	   r	   r!   r
   r      s    r   z--listenz	127.0.0.1IP?z
0.0.0.0,::zSpecify 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))r   defaultr   nargsconsthelpz--porti  zSet the listen port.)r   r1   r4   z--tls-keyfilezpPath to TLS (SSL) key file. Enables TLS, makes app accessible at https://... requires --tls-certfile to function)r   r4   z--tls-certfilezwPath to TLS (SSL) certificate file. Enables TLS, makes app accessible at https://... requires --tls-keyfile to functionz--enable-cors-headerORIGIN*z_Enable CORS (Cross-Origin Resource Sharing) with optional origin or allow all with default '*'.z--max-upload-sized   z"Set the maximum upload size in MB.z--base-directoryzcSet the ComfyUI base directory for models, custom_nodes, input, output, temp, and user directories.z--extra-model-paths-configPATH+appendz.Load one or more extra_model_paths.yaml files.)r   r1   r   r2   actionr4   z--output-directoryz=Set the ComfyUI output directory. Overrides --base-directory.z--temp-directoryzaSet the ComfyUI temp directory (default is in the ComfyUI directory). Overrides --base-directory.z--input-directoryz<Set the ComfyUI input directory. Overrides --base-directory.z--auto-launch
store_truez4Automatically launch ComfyUI in the default browser.)r;   r4   z--disable-auto-launchz#Disable auto launching the browser.z--cuda-device	DEVICE_IDz\Set the id of the cuda device this instance will use. All other devices will not be visible.)r   r1   r   r4   z--default-deviceDEFAULT_DEVICE_IDzFSet the id of the default device, all other devices will stay visible.z--cuda-malloczAEnable cudaMallocAsync (enabled by default for torch 2.0 and up).z--disable-cuda-malloczDisable cudaMallocAsync.z--force-fp32zAForce fp32 (If this makes your GPU work better please report it).z--force-fp16zForce fp16.z--fp32-unetz Run the diffusion model in fp32.z--fp64-unetz Run the diffusion model in fp64.z--bf16-unetz Run the diffusion model in bf16.z--fp16-unetzRun the diffusion model in fp16z--fp8_e4m3fn-unetz!Store unet weights in fp8_e4m3fn.z--fp8_e5m2-unetzStore unet weights in fp8_e5m2.z--fp8_e8m0fnu-unetz"Store unet weights in fp8_e8m0fnu.z
--fp16-vaez.Run the VAE in fp16, might cause black images.z
--fp32-vaez#Run the VAE in full precision fp32.z
--bf16-vaezRun the VAE in bf16.z	--cpu-vaezRun the VAE on the CPU.z--fp8_e4m3fn-text-encz3Store text encoder weights in fp8 (e4m3fn variant).z--fp8_e5m2-text-encz1Store text encoder weights in fp8 (e5m2 variant).z--fp16-text-encz#Store text encoder weights in fp16.z--fp32-text-encz#Store text encoder weights in fp32.z--bf16-text-encz#Store text encoder weights in bf16.z--fp16-intermediateszNExperimental: Use fp16 for intermediate tensors between nodes instead of fp32.z--force-channels-lastz7Force channels last format when inferencing the models.z
--directmlDIRECTML_DEVICEzUse torch-directml.)r   r2   r   r3   r4   z--oneapi-device-selectorSELECTOR_STRINGz1Sets the oneAPI device(s) this instance will use.z--disable-ipex-optimizezVDisables ipex.optimize default when loading models with Intel's Extension for Pytorch.z--supports-fp8-computez9ComfyUI will act like if the device supports fp8 compute.c                   @   s.   e Zd ZdZdZdZdZedefddZ	dS )	LatentPreviewMethodnoneauto
latent2rgbtaesdr   c                 C   s    | D ]}|j |kr|  S qd S r   r   )clsr   memberr	   r	   r
   from_stringf   s
   
zLatentPreviewMethod.from_stringN)
r*   r+   r,   
NoPreviewsAuto
Latent2RGBTAESDclassmethodstrrI   r	   r	   r	   r
   rB   `   s    rB   z--preview-methodz)Default preview method for sampler nodes.)r   r1   r4   r;   z--preview-sizei   z0Sets the maximum preview size for sampler nodes.g      z--cache-classicz'Use the old style (aggressive) caching.z--cache-lruzOUse LRU caching with a maximum of N node results cached. May use more RAM/VRAM.z--cache-nonezKReduced RAM/VRAM usage at the expense of executing every node for each run.z--cache-ramzUse RAM pressure caching with the specified headroom threshold. If available RAM drops below the threshold the cache removes large items to free RAM. Default (when no value is provided): 25%% of system RAM (min 4GB, max 32GB).)r2   r3   r   r1   r4   z--use-split-cross-attentionzJUse the split cross attention optimization. Ignored when xformers is used.z--use-quad-cross-attentionzSUse the sub-quadratic cross attention optimization . Ignored when xformers is used.z--use-pytorch-cross-attentionz1Use the new pytorch 2.0 cross attention function.z--use-sage-attentionzUse sage attention.z--use-flash-attentionzUse FlashAttention.z--disable-xformerszDisable xformers.z--force-upcast-attentionzIForce enable attention upcasting, please report if it fixes black images.z--dont-upcast-attentionzODisable all upcasting of attention. Should be unnecessary except for debugging.z--enable-managerz#Enable the ComfyUI-Manager feature.z--disable-manager-uiz|Disables only the ComfyUI-Manager UI and endpoints. Scheduled installations and similar background tasks will still operate.z--enable-manager-legacy-uiz(Enables the legacy UI of ComfyUI-Managerz
--gpu-onlyzHStore and run everything (text encoders/CLIP models, etc... on the GPU).z
--highvramzhBy default models will be unloaded to CPU memory after being used. This option keeps them in GPU memory.z--normalvramzDUsed to force normal vram use if lowvram gets automatically enabled.z	--lowvramz)Split the unet in parts to use less vram.z--novramzWhen lowvram isn't enough.z--cpuz%To use the CPU for everything (slow).z--reserve-vramzSet 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.z--async-offload   NUM_STREAMSzUse async weight offloading. An optional argument controls the amount of offload streams. Default is 2. Enabled by default on Nvidia.)r2   r3   r   r1   r   r4   z--disable-async-offloadz Disable async weight offloading.z--disable-dynamic-vramz:Disable dynamic VRAM and use estimate based model loading.z--enable-dynamic-vramzAEnable dynamic VRAM on systems where it's not enabled by default.z--force-non-blockingzForce ComfyUI to use non-blocking operations for all applicable tensors. This may improve performance on some non-Nvidia systems but can cause issues with some workflows.z--default-hashing-function)md5sha1sha256sha512rT   znAllows you to choose the hash function to use for duplicate filename / contents comparison. Default is sha256.)r   r   r1   r4   z--disable-smart-memoryzbForce ComfyUI to agressively offload to regular ram instead of keeping models in vram when it can.z--deterministicz~Make pytorch use slower deterministic algorithms when it can. Note that this might not make images deterministic in all cases.c                   @   s   e Zd ZdZdZdZdZdS )PerformanceFeaturefp16_accumulationfp8_matrix_mult
cublas_opsautotuneN)r*   r+   r,   Fp16AccumulationFp8MatrixMultiplication	CublasOpsAutoTuner	   r	   r	   r
   rV      s
    rV   z--fasta3  Enable some untested and potentially quality deteriorating optimizations. This is used to test new features so using it might crash your comfyui. --fast with no arguments enables everything. You can pass a list specific optimizations if you only want to enable specific ones. Current valid optimizations: {} c                 C   s   | j S r   r   )cr	   r	   r
   <lambda>   s    ra   )r2   r   r4   z--disable-pinned-memoryzDisable pinned memory use.z--mmap-torch-filesz$Use mmap when loading ckpt/pt files.z--disable-mmapz(Don't use mmap when loading safetensors.z--dont-print-serverzDon't print server output.z--quick-test-for-cizQuick test for CI.z--windows-standalone-buildzWindows standalone build: Enable convenient things that most people using the standalone windows build will probably enjoy (like auto opening the page on startup).z--disable-metadataz(Disable saving prompt metadata in files.z--disable-all-custom-nodesz!Disable loading all custom nodes.z--whitelist-custom-nodeszTSpecify custom node folders to load even when --disable-all-custom-nodes is enabled.)r   r2   r1   r4   z--disable-api-nodesz_Disable loading all api nodes. Also prevents the frontend from communicating with the internet.z--multi-userzEnables per-user storage.z	--verboseINFODEBUG)rc   rb   WARNINGERRORCRITICALzSet the logging level)r1   r3   r2   r   r4   z--log-stdoutzASend normal process output to stdout instead of stderr (default).zcomfyanonymous/ComfyUI@latestz--front-end-versiona_  
    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")
    pathreturnc                 C   s`   t j| std|  dt j| std|  dt | t js.td|  d| S )zAValidate if the given path is a directory, and check permissions.z
The path 'z' does not exist.'z' is not a directory.z&You do not have read permissions for 'z'.)osrg   existsargparseArgumentTypeErrorisdiraccessR_OK)rg   r	   r	   r
   is_valid_directory   s   rq   z--front-end-rootzhThe local filesystem path to the directory where the frontend is located. Overrides --front-end-version.z--user-directoryzQSet the ComfyUI user directory with an absolute path. Overrides --base-directory.z--enable-compress-response-bodyz!Enable compressing response body.z--comfy-api-basezhttps://api.comfy.orgzGSet the base URL for the ComfyUI API.  (default: https://api.comfy.org)z..userz
comfyui.dbz--database-urlz
sqlite:///zZSpecify the database URL, e.g. for an in-memory database you can use 'sqlite:///:memory:'.z--enable-assetszYEnable the assets system (API routes, database synchronization, and background scanning).TFc                   C   s2   t jrdS t j ot j ot j ot j ot j S )NT)argsenable_dynamic_vramdisable_dynamic_vramhighvramgpu_onlynovramcpur	   r	   r	   r
   enables_dynamic_vram  s   (rz   )3rl   r   rj   comfy.optionscomfyActionr   ArgumentParserr%   add_argumentrO   intfloatadd_mutually_exclusive_groupcm_groupfp_groupfpunet_groupfpvae_group
fpte_groupr   rB   rJ   CACHE_RAM_AUTO_GBcache_group
attn_groupupcastmanager_group
vram_grouprV   formatr   mapDEFAULT_VERSION_STRINGrq   rg   abspathdirname__file__database_default_pathoptionsargs_parsing
parse_argsrs   windows_standalone_buildauto_launchdisable_auto_launch
force_fp16	fp16_unetfastsetrz   r	   r	   r	   r
   <module>   s(   (




