comfyanonymous / ComfyUI

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface.
https://www.comfy.org/
GNU General Public License v3.0
57.18k stars 6.05k forks source link

External folder handling for files #1664

Open Void2258 opened 1 year ago

Void2258 commented 1 year ago

Models, Vaes, nodes setups, inputs, outputs, etc. are currently stored in the ComfyUI folder in predetermined locations. Any files not part of the install itself should be able to be moved another location, separate from the install folder. This has 2 key advantages:

jn-jairo commented 1 year ago

Quoting the README file.

Config file to set the search paths for models.

Void2258 commented 1 year ago

I have tried to use this, but nothing I try entering into this file will work. Comfy fails to load with errors if the file is not inactivated (extension changed from .yaml). I also meant this to suggest this be something you can set in options.

jn-jairo commented 1 year ago

I have tried to use this, but nothing I try entering into this file will work. Comfy fails to load with errors if the file is not inactivated (extension changed from .yaml). I also meant this to suggest this be something you can set in options.

If you provide the yaml file and errors we can try to help you.

Void2258 commented 1 year ago

Yaml file can't be posted to github comments.

File contents:

#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
#         models/LyCORIS
#    upscale_models: |
#                  models/ESRGAN
#                  models/RealESRGAN
#                  models/SwinIR
#    embeddings: embeddings
#    hypernetworks: models/hypernetworks
#    controlnet: models/ControlNet

#other_ui:
#    base_path: path/to/ui
    checkpoints: H:\Stable_diffusion_files\Stable_diffusion_models
    vae: H:\Stable_diffusion_files\VAE
    loras: H:\Stable_diffusion_files\loras
    embeddings: H:\Stable_diffusion_files\embeddings
    controlnet: H:\Stable_diffusion_files\controlnet
#    gligen: models/gligen
#    custom_nodes: path/custom_nodes

Error:

Traceback (most recent call last):
  File "H:\ComfyUI_windows_portable\ComfyUI\main.py", line 158, in <module>
    load_extra_path_config(extra_model_paths_config_path)
  File "H:\ComfyUI_windows_portable\ComfyUI\main.py", line 134, in load_extra_path_config
    for y in conf[x].split("\n"):
TypeError: string indices must be integers

H:\ComfyUI_windows_portable>pause

Note that I don't see anything here for moving input and output folders. I probably also need to make a custom nodes folder at some point but just trying to make it not crash and actually register things right now.

jn-jairo commented 1 year ago

You need to uncomment the other_ui line:

other_ui:
    checkpoints: H:\Stable_diffusion_files\Stable_diffusion_models
    vae: H:\Stable_diffusion_files\VAE
    loras: H:\Stable_diffusion_files\loras
    embeddings: H:\Stable_diffusion_files\embeddings
    controlnet: H:\Stable_diffusion_files\controlnet

About the output folder there is the option --output-directory to set it, but the option to set the input directory is missing so I made a PR #1666 to add it.

Void2258 commented 1 year ago

Wow suddenly works. It is not clear that line is a command and not an actual comment.

Tried changing the output but it didn't work.

It would be nice if the path for output was a variable on the node, since it's not guaranteed you want everything to go to the same place the entire time you are working. Having to exit, edit a text file, and restart in order to change folders is a bit awkward. The text file could hold the default for that field.

jn-jairo commented 1 year ago

The output directory is not added to the yaml file, it is a command option when you start like python main.py --output-directory "/path/to/output_directory"

Void2258 commented 1 year ago

I am using the windows portable version so I just click run_nvidia_gpu. And in any case having control of the output location is something that is mostly useful if it has some level of persistence, so a command option is not ideal.

jn-jairo commented 1 year ago

I am using the windows portable version so I just click run_nvidia_gpu. And in any case having control of the output location is something that is mostly useful if it has some level of persistence, so a command option is not ideal.

I didn't even know there was a portable version, now your feature requests makes more sense.

Void2258 commented 1 year ago

I got it from this github repo. It's the only windows version I even see.