Sharing models and custom nodes in ComfyUI
Introduction
The ability to create content in response to image or text-based prompts using Generative AI is a burgeoning interest in the sphere of Artificial Intelligence. Stable Diffusion models are a family of Generative AI models which was spearheaded by Stability AI in 2022 and are gaining in popularity. Stable Diffusion models are open-source and allow you to train new models on your own datasets. While all diffusion models enable generating images from prompts, the technology used for Stable Diffusion requires less processing power and is more readily utilized on consumer-grade graphics cards. ComfyUI is a popular node-based Stable Diffusion graphical user interface (GUI) that generates images in response to positive and negative prompts.
The Stable Diffusion process requires a model checkpoint as a basis for generating images. CivitAI and Hugging Face are popular sites for downloading models.
While ComfyUI’s default nodes provide basic capabilities for generating images, it’s likely that you will need to install additional nodes for more advanced processing. Additional nodes are available from a variety of sources. ComfyUI Nodes Info has links to more than 700 Github repositories.
Our need
By default, ComfyUI accesses models and nodes via ‘models’ and ‘custom_nodes’ folders that are part of its individual installation folder hierarchy. Here at Magnopus, we wanted to benefit from an installation that would be shared among project team members.
A shared installation addresses some downsides of working with ComfyUI. The files for the models and nodes take a lot of storage space. With individual installs, new users need to put the necessary models and nodes in place, which is time-consuming. Also, versions used across the team can easily get out of sync.
Our solution
We filled this need with ComfyUI’s ‘--extra-model-paths-config’ command-line argument and pointed it to a shared network drive. At first glance, one might think that this argument is used to specify paths for models only. In fact, its value is a yaml file that points to additional locations for models as well as custom nodes.
Using a centralized drive created several efficiencies in our use of ComfyUI. We saved disk space by avoiding multiple installs of large files. Onboarding was faster because the models and custom nodes were immediately available for new users. By using one copy of the files, versioning was easily managed. Updates were instantly available to everyone. Cloud-based resources became an option, providing flexibility, scalability, and accessibility for team members working remotely or in distributed environments.
Sample configuration
In this example, ‘extra_model_paths.yaml’ is in ‘X:\comfyui_models` which has subfolders ‘models’ and ‘custom_nodes’. The X drive in this example is mapped to a networked folder which allows for easy sharing of the models and nodes. The contents of the yaml file are shown below.
#config for comfyui #your base path should be either an existing comfy install or a central folder where you store all of your models, loras, etc. comfyui: base_path: X:\\comfyui_models checkpoints: models\checkpoints\ controlnet: models\controlnet\ custom_nodes: custom_nodes\ loras: models\loras\
The ‘extra_models_paths.yaml’ is supplied when ComfyUI is started from the command line as shown here:
python main.py --extra-model-paths-config X:\comfyui_models\extra_model_paths.yaml
Upon startup from the command line, the console output includes the information below, which shows that the paths specified in the yaml file are used in addition to the default locations.
Import times for custom nodes: 0.3 seconds: X:\\comfyui_models\custom_nodes\ComfyUI_UltimateSDUpscale 0.3 seconds: X:\\comfyui_models\custom_nodes\ComfyUI-Manager 0.7 seconds: X:\\comfyui_models\custom_nodes\comfyui_controlnet_aux 0.8 seconds: X:\\comfyui_models\custom_nodes\ComfyUI_Comfyroll_CustomNodes 1.9 seconds: X:\\comfyui_models\custom_nodes\ComfyUI-Inference-Core-Nodes 3.6 seconds: X:\\comfyui_models\custom_nodes\ComfyUI-Impact-Pack 3.8 seconds:C:\comfyui\ComfyUI\custom_nodes\was-node-suite-comfyui
Sample ComfyUI workflow
In this ComfyUI workflow, the ‘Image Save’ custom node is from ‘was-node-suite-comfyui’ on the C-drive and the ‘Image Luminance’ node is from ‘comfyui_controlnet_aux’ on the X-drive. Both nodes are found and the image is generated as desired.
Conclusion
At Magnopus we found that this process improved productivity on our projects, both by saving setup time when adding team members and by reducing the need to debug errors for missing components. By not requiring hands-on installs for each user, this solution fosters automation of our workflow.
We hope that you see the same benefits when leveraging this tip.
It was brought to our attention after publishing this article that while ComfyUI itself remains secure, a malicious custom node called "ComfyUI_LLMVISION" was uploaded by a user and contained code designed to steal sensitive user information, including browser passwords, credit card details, and browsing history. Though this particular custom node is unrelated to this article, we wanted to remind you to remain vigilant when integrating third-party components into your workflows. Read more about this particular incident here.