mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-01-22 12:20:16 +08:00
Default for extra model paths
This commit is contained in:
parent
143efb5900
commit
643797bca9
@ -4,6 +4,7 @@ import pprint
|
|||||||
import argparse
|
import argparse
|
||||||
import ruamel.yaml
|
import ruamel.yaml
|
||||||
import folder_paths
|
import folder_paths
|
||||||
|
import copy
|
||||||
|
|
||||||
yaml = ruamel.yaml.YAML()
|
yaml = ruamel.yaml.YAML()
|
||||||
yaml.default_flow_style = False
|
yaml.default_flow_style = False
|
||||||
@ -225,9 +226,10 @@ class OptionInfoRaw:
|
|||||||
Raw YAML input and output, ignores argparse entirely
|
Raw YAML input and output, ignores argparse entirely
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, name, help=None):
|
def __init__(self, name, help=None, default=None):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.help = help
|
self.help = help
|
||||||
|
self.default = default or {}
|
||||||
self.parser_args = {}
|
self.parser_args = {}
|
||||||
self.raw_output = True
|
self.raw_output = True
|
||||||
|
|
||||||
@ -238,13 +240,13 @@ class OptionInfoRaw:
|
|||||||
return self.help
|
return self.help
|
||||||
|
|
||||||
def get_arg_defaults(self, parser):
|
def get_arg_defaults(self, parser):
|
||||||
return { self.name: {} }
|
return { self.name: copy.copy(self.default) }
|
||||||
|
|
||||||
def convert_to_args_array(self, value):
|
def convert_to_args_array(self, value):
|
||||||
return { self.name: value }
|
return { self.name: value }
|
||||||
|
|
||||||
def convert_to_file_option(self, parser, args):
|
def convert_to_file_option(self, parser, args):
|
||||||
return args.get(self.name.replace("-", "_"), {})
|
return args.get(self.name.replace("-", "_"), copy.copy(self.default))
|
||||||
|
|
||||||
def validate(self, config_options, cli_args):
|
def validate(self, config_options, cli_args):
|
||||||
pass
|
pass
|
||||||
@ -253,6 +255,21 @@ class OptionInfoRaw:
|
|||||||
# Config options
|
# Config options
|
||||||
#
|
#
|
||||||
|
|
||||||
|
DEFAULT_EXTRA_MODEL_PATHS_CONFIG = yaml.load("""
|
||||||
|
a1111:
|
||||||
|
base_path: path/to/stable-diffusion-webui/
|
||||||
|
checkpoints: models/Stable-diffusion
|
||||||
|
configs: models/Stable-diffusion
|
||||||
|
vae: models/VAE
|
||||||
|
loras: models/Lora
|
||||||
|
upscale_models: |
|
||||||
|
models/ESRGAN
|
||||||
|
models/SwinIR
|
||||||
|
embeddings: embeddings
|
||||||
|
hypernetworks: models/hypernetworks
|
||||||
|
controlnet: models/ControlNet
|
||||||
|
""")
|
||||||
|
|
||||||
CONFIG_OPTIONS = [
|
CONFIG_OPTIONS = [
|
||||||
("network", [
|
("network", [
|
||||||
OptionInfo("listen", type=str, default="127.0.0.1", metavar="IP", nargs="?", const="0.0.0.0",
|
OptionInfo("listen", type=str, default="127.0.0.1", metavar="IP", nargs="?", const="0.0.0.0",
|
||||||
@ -262,7 +279,7 @@ CONFIG_OPTIONS = [
|
|||||||
help="Enable CORS (Cross-Origin Resource Sharing) with optional origin or allow all with default '*'."),
|
help="Enable CORS (Cross-Origin Resource Sharing) with optional origin or allow all with default '*'."),
|
||||||
]),
|
]),
|
||||||
("files", [
|
("files", [
|
||||||
OptionInfoRaw("extra-model-paths", help="Extra paths to scan for model files."),
|
OptionInfoRaw("extra-model-paths", help="Extra paths to scan for model files.", default=DEFAULT_EXTRA_MODEL_PATHS_CONFIG),
|
||||||
OptionInfo("output-directory", type=str, default=None, help="Set the ComfyUI output directory. Leave empty to use the default."),
|
OptionInfo("output-directory", type=str, default=None, help="Set the ComfyUI output directory. Leave empty to use the default."),
|
||||||
]),
|
]),
|
||||||
("behavior", [
|
("behavior", [
|
||||||
@ -362,7 +379,7 @@ class ComfyConfigLoader:
|
|||||||
return defaults
|
return defaults
|
||||||
|
|
||||||
def load_from_string(self, raw_config):
|
def load_from_string(self, raw_config):
|
||||||
raw_config = yaml.load(raw_config)
|
raw_config = yaml.load(raw_config) or {}
|
||||||
|
|
||||||
config = {}
|
config = {}
|
||||||
root = raw_config.get("config", {})
|
root = raw_config.get("config", {})
|
||||||
|
|||||||
@ -16,7 +16,7 @@ config:
|
|||||||
|
|
||||||
# Extra paths to scan for model files.
|
# Extra paths to scan for model files.
|
||||||
extra_model_paths:
|
extra_model_paths:
|
||||||
a111:
|
a1111:
|
||||||
base_path: path/to/stable-diffusion-webui/
|
base_path: path/to/stable-diffusion-webui/
|
||||||
checkpoints: models/Stable-diffusion
|
checkpoints: models/Stable-diffusion
|
||||||
configs: models/Stable-diffusion
|
configs: models/Stable-diffusion
|
||||||
|
|||||||
@ -10,6 +10,10 @@ def test_defaults():
|
|||||||
assert args.listen == "127.0.0.1"
|
assert args.listen == "127.0.0.1"
|
||||||
assert args.novram == False
|
assert args.novram == False
|
||||||
|
|
||||||
|
extra_paths = args.extra_model_paths.get("a1111")
|
||||||
|
assert extra_paths is not None
|
||||||
|
assert extra_paths.get("base_path") == "path/to/stable-diffusion-webui/"
|
||||||
|
|
||||||
|
|
||||||
def test_config():
|
def test_config():
|
||||||
config = """
|
config = """
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user