Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

Add support for loading extra paths from yaml file.

comfyanonymous51d6427ddfb4
diff --git a/extra_model_paths.yaml.example b/extra_model_paths.yaml.example
new file mode 100644
index 000000000..af784fd69
--- /dev/null
+++ b/extra_model_paths.yaml.example
@@ -0,0 +1,23 @@
+#Rename this to extra_model_paths.yaml and ComfyUI will load it
+
+#config for a1111 ui
+#all you have to do is change the base_path to where yours is installed
+a111:
+ 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
+ controlnet: models/ControlNet
+
+#other_ui:
+# base_path: path/to/ui
+# checkpoints: models/checkpoints
+
+
+
diff --git a/folder_paths.py b/folder_paths.py
index f04efc0d3..ba506744e 100644
--- a/folder_paths.py
+++ b/folder_paths.py
@@ -28,8 +28,10 @@ folder_names_and_paths["controlnet"] = ([os.path.join(models_dir, "controlnet"),
folder_names_and_paths["upscale_models"] = ([os.path.join(models_dir, "upscale_models")], supported_pt_extensions)
-def add_model_folder(folder_name, full_folder_path):
+def add_model_folder_path(folder_name, full_folder_path):
global folder_names_and_paths
+ if folder_name in folder_names_and_paths:
+ folder_names_and_paths[folder_name][0].append(full_folder_path)
def recursive_search(directory):
diff --git a/main.py b/main.py
index 3c03381d6..26bad1b8b 100644
--- a/main.py
+++ b/main.py
@@ -33,6 +33,8 @@ if __name__ == "__main__":
import execution
import server
+import folder_paths
+import yaml
def prompt_worker(q, server):
e = execution.PromptExecutor(server)
@@ -59,6 +61,26 @@ def cleanup_temp():
if os.path.exists(temp_dir):
shutil.rmtree(temp_dir, ignore_errors=True)
+def load_extra_path_config(yaml_path):
+ with open(yaml_path, 'r') as stream:
+ config = yaml.safe_load(stream)
+ for c in config:
+ conf = config[c]
+ if conf is None:
+ continue
+ base_path = None
+ if "base_path" in conf:
+ base_path = conf.pop("base_path")
+ for x in conf:
+ for y in conf[x].split("\n"):
+ if len(y) == 0:
+ continue
+ full_path = y
+ if base_path is not None:
+ full_path = os.path.join(base_path, full_path)
+ print("Adding extra search path", x, full_path)
+ folder_paths.add_model_folder_path(x, full_path)
+
if __name__ == "__main__":
cleanup_temp()
@@ -79,6 +101,15 @@ if __name__ == "__main__":
if '--dont-print-server' in sys.argv:
dont_print = True
+ extra_model_paths_config_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "extra_model_paths.yaml")
+ if os.path.isfile(extra_model_paths_config_path):
+ load_extra_path_config(extra_model_paths_config_path)
+
+ if '--extra-model-paths-config' in sys.argv:
+ indices = [(i + 1) for i in range(len(sys.argv) - 1) if sys.argv[i] == '--extra-model-paths-config']
+ for i in indices:
+ load_extra_path_config(sys.argv[i])
+
port = 8188
try:
p_index = sys.argv.index('--port')