mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-01-24 05:10:18 +08:00
Merge 5b1bbaff08 into f17251bec6
This commit is contained in:
commit
6df7ad22a5
@ -44,9 +44,10 @@ parser.add_argument("--max-upload-size", type=float, default=100, help="Set the
|
|||||||
|
|
||||||
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.")
|
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.")
|
||||||
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.")
|
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.")
|
||||||
|
parser.add_argument("--input-directory", type=str, default=None, help="Set the ComfyUI input directory. Overrides --base-directory.")
|
||||||
parser.add_argument("--output-directory", type=str, default=None, help="Set the ComfyUI output directory. Overrides --base-directory.")
|
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("--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.")
|
parser.add_argument("--user-directory", type=is_valid_directory, default=None, help="Set the ComfyUI user directory with an absolute path. Overrides --base-directory.")
|
||||||
parser.add_argument("--auto-launch", action="store_true", help="Automatically launch ComfyUI in the default browser.")
|
parser.add_argument("--auto-launch", action="store_true", help="Automatically launch ComfyUI in the default browser.")
|
||||||
parser.add_argument("--disable-auto-launch", action="store_true", help="Disable auto launching the browser.")
|
parser.add_argument("--disable-auto-launch", action="store_true", help="Disable auto launching the browser.")
|
||||||
parser.add_argument("--cuda-device", type=int, default=None, metavar="DEVICE_ID", help="Set the id of the cuda device this instance will use. All other devices will not be visible.")
|
parser.add_argument("--cuda-device", type=int, default=None, metavar="DEVICE_ID", help="Set the id of the cuda device this instance will use. All other devices will not be visible.")
|
||||||
@ -201,8 +202,6 @@ parser.add_argument(
|
|||||||
help="The local filesystem path to the directory where the frontend is located. Overrides --front-end-version.",
|
help="The local filesystem path to the directory where the frontend is located. Overrides --front-end-version.",
|
||||||
)
|
)
|
||||||
|
|
||||||
parser.add_argument("--user-directory", type=is_valid_directory, default=None, help="Set the ComfyUI user directory with an absolute path. Overrides --base-directory.")
|
|
||||||
|
|
||||||
parser.add_argument("--enable-compress-response-body", action="store_true", help="Enable compressing response body.")
|
parser.add_argument("--enable-compress-response-body", action="store_true", help="Enable compressing response body.")
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
|||||||
@ -99,12 +99,6 @@ def map_legacy(folder_name: str) -> str:
|
|||||||
"clip": "text_encoders"}
|
"clip": "text_encoders"}
|
||||||
return legacy.get(folder_name, folder_name)
|
return legacy.get(folder_name, folder_name)
|
||||||
|
|
||||||
if not os.path.exists(input_directory):
|
|
||||||
try:
|
|
||||||
os.makedirs(input_directory)
|
|
||||||
except:
|
|
||||||
logging.error("Failed to create input directory")
|
|
||||||
|
|
||||||
def set_output_directory(output_dir: str) -> None:
|
def set_output_directory(output_dir: str) -> None:
|
||||||
global output_directory
|
global output_directory
|
||||||
output_directory = output_dir
|
output_directory = output_dir
|
||||||
|
|||||||
51
main.py
51
main.py
@ -32,7 +32,22 @@ def apply_custom_paths():
|
|||||||
for config_path in itertools.chain(*args.extra_model_paths_config):
|
for config_path in itertools.chain(*args.extra_model_paths_config):
|
||||||
utils.extra_config.load_extra_path_config(config_path)
|
utils.extra_config.load_extra_path_config(config_path)
|
||||||
|
|
||||||
# --output-directory, --input-directory, --user-directory
|
# --temp-directory, --user-directory, --input-directory, --output-directory
|
||||||
|
if args.temp_directory:
|
||||||
|
temp_dir = os.path.join(os.path.abspath(args.temp_directory), "temp")
|
||||||
|
logging.info(f"Setting temp directory to: {temp_dir}")
|
||||||
|
folder_paths.set_temp_directory(temp_dir)
|
||||||
|
|
||||||
|
if args.user_directory:
|
||||||
|
user_dir = os.path.abspath(args.user_directory)
|
||||||
|
logging.info(f"Setting user directory to: {user_dir}")
|
||||||
|
folder_paths.set_user_directory(user_dir)
|
||||||
|
|
||||||
|
if args.input_directory:
|
||||||
|
input_dir = os.path.abspath(args.input_directory)
|
||||||
|
logging.info(f"Setting input directory to: {input_dir}")
|
||||||
|
folder_paths.set_input_directory(input_dir)
|
||||||
|
|
||||||
if args.output_directory:
|
if args.output_directory:
|
||||||
output_dir = os.path.abspath(args.output_directory)
|
output_dir = os.path.abspath(args.output_directory)
|
||||||
logging.info(f"Setting output directory to: {output_dir}")
|
logging.info(f"Setting output directory to: {output_dir}")
|
||||||
@ -46,15 +61,20 @@ def apply_custom_paths():
|
|||||||
os.path.join(folder_paths.get_output_directory(), "diffusion_models"))
|
os.path.join(folder_paths.get_output_directory(), "diffusion_models"))
|
||||||
folder_paths.add_model_folder_path("loras", os.path.join(folder_paths.get_output_directory(), "loras"))
|
folder_paths.add_model_folder_path("loras", os.path.join(folder_paths.get_output_directory(), "loras"))
|
||||||
|
|
||||||
if args.input_directory:
|
|
||||||
input_dir = os.path.abspath(args.input_directory)
|
|
||||||
logging.info(f"Setting input directory to: {input_dir}")
|
|
||||||
folder_paths.set_input_directory(input_dir)
|
|
||||||
|
|
||||||
if args.user_directory:
|
# These are created at startup if missing. Other data directories are created on-demand when needed.
|
||||||
user_dir = os.path.abspath(args.user_directory)
|
def create_data_folders():
|
||||||
logging.info(f"Setting user directory to: {user_dir}")
|
data_dirs = [
|
||||||
folder_paths.set_user_directory(user_dir)
|
folder_paths.get_input_directory(),
|
||||||
|
folder_paths.get_temp_directory()
|
||||||
|
]
|
||||||
|
|
||||||
|
for dir_path in data_dirs:
|
||||||
|
if not os.path.exists(dir_path):
|
||||||
|
try:
|
||||||
|
os.makedirs(dir_path)
|
||||||
|
except:
|
||||||
|
logging.error(f"Failed to create directory: {dir_path}")
|
||||||
|
|
||||||
|
|
||||||
def execute_prestartup_script():
|
def execute_prestartup_script():
|
||||||
@ -74,7 +94,11 @@ def execute_prestartup_script():
|
|||||||
|
|
||||||
node_paths = folder_paths.get_folder_paths("custom_nodes")
|
node_paths = folder_paths.get_folder_paths("custom_nodes")
|
||||||
for custom_node_path in node_paths:
|
for custom_node_path in node_paths:
|
||||||
possible_modules = os.listdir(custom_node_path)
|
if not os.path.exists(custom_node_path):
|
||||||
|
logging.warning(f"Directory {custom_node_path} for custom nodes does not exist, skipping")
|
||||||
|
continue
|
||||||
|
|
||||||
|
possible_modules = os.listdir(os.path.realpath(custom_node_path))
|
||||||
node_prestartup_times = []
|
node_prestartup_times = []
|
||||||
|
|
||||||
for possible_module in possible_modules:
|
for possible_module in possible_modules:
|
||||||
@ -100,7 +124,9 @@ def execute_prestartup_script():
|
|||||||
logging.info("{:6.1f} seconds{}: {}".format(n[0], import_message, n[1]))
|
logging.info("{:6.1f} seconds{}: {}".format(n[0], import_message, n[1]))
|
||||||
logging.info("")
|
logging.info("")
|
||||||
|
|
||||||
|
|
||||||
apply_custom_paths()
|
apply_custom_paths()
|
||||||
|
create_data_folders()
|
||||||
execute_prestartup_script()
|
execute_prestartup_script()
|
||||||
|
|
||||||
|
|
||||||
@ -305,10 +331,6 @@ def start_comfyui(asyncio_loop=None):
|
|||||||
Starts the ComfyUI server using the provided asyncio event loop or creates a new one.
|
Starts the ComfyUI server using the provided asyncio event loop or creates a new one.
|
||||||
Returns the event loop, server instance, and a function to start the server asynchronously.
|
Returns the event loop, server instance, and a function to start the server asynchronously.
|
||||||
"""
|
"""
|
||||||
if args.temp_directory:
|
|
||||||
temp_dir = os.path.join(os.path.abspath(args.temp_directory), "temp")
|
|
||||||
logging.info(f"Setting temp directory to: {temp_dir}")
|
|
||||||
folder_paths.set_temp_directory(temp_dir)
|
|
||||||
cleanup_temp()
|
cleanup_temp()
|
||||||
|
|
||||||
if args.windows_standalone_build:
|
if args.windows_standalone_build:
|
||||||
@ -341,7 +363,6 @@ def start_comfyui(asyncio_loop=None):
|
|||||||
if args.quick_test_for_ci:
|
if args.quick_test_for_ci:
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
os.makedirs(folder_paths.get_temp_directory(), exist_ok=True)
|
|
||||||
call_on_start = None
|
call_on_start = None
|
||||||
if args.auto_launch:
|
if args.auto_launch:
|
||||||
def startup_server(scheme, address, port):
|
def startup_server(scheme, address, port):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user