{"id":25845298,"url":"https://github.com/replicate/cog-comfyui","last_synced_at":"2025-05-15T06:05:51.343Z","repository":{"id":216812884,"uuid":"742379611","full_name":"replicate/cog-comfyui","owner":"replicate","description":"Run ComfyUI with an API","archived":false,"fork":false,"pushed_at":"2025-05-12T17:06:39.000Z","size":658,"stargazers_count":670,"open_issues_count":52,"forks_count":181,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-05-13T10:53:32.574Z","etag":null,"topics":["ai","comfy","comfyui"],"latest_commit_sha":null,"homepage":"https://replicate.com/fofr/any-comfyui-workflow","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/replicate.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":"supported_weights.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-01-12T10:47:54.000Z","updated_at":"2025-05-13T02:02:13.000Z","dependencies_parsed_at":"2024-03-17T11:26:36.121Z","dependency_job_id":"ed494c9b-218f-4091-8895-b521e93c79d1","html_url":"https://github.com/replicate/cog-comfyui","commit_stats":{"total_commits":530,"total_committers":9,"mean_commits":"58.888888888888886","dds":0.02075471698113207,"last_synced_commit":"83c3a3f7286cab8e1834d956e20514f56eb965f0"},"previous_names":["fofr/cog-comfyui","replicate/cog-comfyui"],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/replicate%2Fcog-comfyui","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/replicate%2Fcog-comfyui/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/replicate%2Fcog-comfyui/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/replicate%2Fcog-comfyui/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/replicate","download_url":"https://codeload.github.com/replicate/cog-comfyui/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254283339,"owners_count":22045140,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","comfy","comfyui"],"created_at":"2025-03-01T08:05:04.495Z","updated_at":"2025-05-15T06:05:51.324Z","avatar_url":"https://github.com/replicate.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cog-comfyui\n\nRun ComfyUI workflows on Replicate:\n\n- https://replicate.com/fofr/any-comfyui-workflow\n- https://replicate.com/fofr/any-comfyui-workflow-a100\n\nWe recommend:\n\n- trying it on the website with your favorite workflow and making sure it works\n- using your own instance to run your workflow quickly and efficiently on Replicate (see the guide below)\n- using the production ready Replicate API to integrate your workflow into your own app or website\n\n## What’s included\n\nWe've tried to include many of the most popular model weights and custom nodes:\n\n- [View list of supported weights](https://github.com/replicate/cog-comfyui/blob/main/supported_weights.md)\n- [View list of supported custom nodes](https://github.com/replicate/cog-comfyui/blob/main/custom_nodes.json)\n\nRaise an issue to request more custom nodes or models, or use the `train` tab on Replicate to use your own weights (see below).\n\n## How to use\n\n### 1. Get your API JSON\n\nYou’ll need the API version of your ComfyUI workflow. This is different to the commonly shared JSON version, it does not included visual information about nodes, etc.\n\nTo get your API JSON:\n\n1. Turn on the \"Enable Dev mode Options\" from the ComfyUI settings (via the settings icon)\n2. Load your workflow into ComfyUI\n3. Export your API JSON using the \"Save (API format)\" button\n\nhttps://private-user-images.githubusercontent.com/319055/298630636-e3af1b59-ddd8-426c-a833-808e7f199fac.mp4\n\n### 2. Gather your input files\n\nIf your model takes inputs, like images for img2img or controlnet, you have 3 options:\n\n#### Use a URL\n\nModify your API JSON file to point at a URL:\n\n```diff\n- \"image\": \"/your-path-to/image.jpg\",\n+ \"image\": \"https://example.com/image.jpg\",\n```\n\n#### Upload a single input\n\nYou can also upload a single input file when running the model.\n\nThis file will be saved as `input.[extension]` – for example `input.jpg`. It'll be placed in the ComfyUI `input` directory, so you can reference in your workflow with:\n\n```diff\n- \"image\": \"/your-path-to/image.jpg\",\n+ \"image\": \"image.jpg\",\n```\n\n#### Upload a zip file or tar file of your inputs\n\nThese will be downloaded and extracted to the `input` directory. You can then reference them in your workflow based on their relative paths.\n\nSo a zip file containing:\n\n```\n- my_img.png\n- references/my_reference_01.jpg\n- references/my_reference_02.jpg\n```\n\nMight be used in the workflow like:\n\n```\n\"image\": \"my_img.png\",\n...\n\"directory\": \"references\",\n```\n\n### 3. Using custom LoRAs from CivitAI or HuggingFace\n\nYou can use LoRAs directly from CivitAI, HuggingFace, or any other URL in two ways:\n\n#### Option 1: Use the LoraLoader node with a URL\n\nUse the direct download URL as the `lora_name`:\n\n```\n{\n    \"inputs\": {\n      \"lora_name\": \"https://huggingface.co/username/model/resolve/main/lora.safetensors\",\n      ...\n    },\n    \"class_type\": \"LoraLoader\"\n}\n```\n\n#### Option 2: Use the LoraLoaderFromURL node\n\nAlternatively, use the dedicated LoraLoaderFromURL node from [ComfyUI-GlifNodes](https://github.com/glifxyz/ComfyUI-GlifNodes):\n\n```\n{\n    \"inputs\": {\n      \"url\": \"https://civitai.com/api/download/models/1163532\",\n      // ...\n    },\n    \"class_type\": \"LoraLoaderFromURL\"\n}\n```\n\nBoth methods work the same way - the standard LoraLoader will automatically switch to use LoraLoaderFromURL when it detects a URL in the `lora_name` field.\n\n### Run your workflow\n\nWith all your inputs updated, you can now run your workflow.\n\nSome workflows save temporary files, for example pre-processed controlnet images. You can also return these by enabling the `return_temp_files` option.\n\n## How to use your own dedicated instance\n\nThe `any-comfyui-workflow` model on Replicate is a shared public model. This means many users will be sending workflows to it that might be quite different to yours. The effect of this will be that the internal ComfyUI server may need to swap models in and out of memory, this can slow down your prediction time.\n\nComfyUI and it's custom nodes are also continually being updated. While this means the newest versions are usually running, if there are breaking changes to custom nodes then your workflow may stop working.\n\nIf you have your own dedicated instance you will:\n\n- fix the code and custom nodes to a known working version\n- have a faster prediction time by keeping just your models in memory\n- benefit from ComfyUI’s own internal optimisations when running the same workflow repeatedly\n\n### Options for using your own instance\n\nTo get the best performance from the model you should run a dedicated instance. You have 3 choices:\n\n1. Create a private deployment (simplest, but you'll need to pay for setup and idle time)\n2. Create and deploy a fork using Cog (most powerful but most complex)\n3. Create a new model from the train tab (simple, your model can be public or private and you can bring your own weights)\n\n### 1. Create a private deployment\n\nGo to:\n\nhttps://replicate.com/deployments/create\n\nSelect `fofr/any-comfyui-workflow` as the model you'd like to deploy. Pick your hardware and min and max instances, and you're ready to go. You'll be pinned to the version you deploy from. When `any-comfyui-workflow` is updated, you can test your workflow with it, and then deploy again using the new version.\n\nYou can read more about deployments in the Replicate docs:\n\nhttps://replicate.com/docs/deployments\n\n### 2. Create and deploy a fork using Cog\n\nYou can use this repository as a template to create your own model. This gives you complete control over the ComfyUI version, custom nodes, and the API you'll use to run the model.\n\nYou'll need to be familiar with Python, and you'll also need a GPU to push your model using [Cog](https://cog.run). Replicate has a good getting started guide: https://replicate.com/docs/guides/push-a-model\n\n#### Example\n\nThe `kolors` model on Replicate is a good example to follow:\n\n- https://replicate.com/fofr/kolors (The model with it’s customised API)\n- https://github.com/replicate/cog-comfyui-kolors (The new repo)\n\nIt was created from this repo, and then deployed using Cog. You can step through the commits of that repo to see what was changed and how, but broadly:\n\n- this repository is used as a template\n- the script [`scripts/prepare_template.py`](https://github.com/replicate/cog-comfyui/blob/main/scripts/prepare_template.py) is run first, to remove examples and unnecessary boilerplate\n- `custom_nodes.json` is modified to add or remove custom nodes you need, making sure to also add or remove their dependencies from `cog.yaml`\n- run `./scripts/install_custom_nodes.py` to install the custom nodes (or `./scripts/reset.py` to reinstall ComfyUI and all custom nodes)\n- the workflow is added as `workflow_api.json`\n- `predict.py` is updated with a new API and the `update_workflow` method is changed so that it modifies the right parts of the JSON\n- the model is tested using `cog predict -i option_name=option_value -i another_option_name=another_option_value` on a GPU\n- the model is pushed to Replicate using `cog push r8.im/your-username/your-model-name`\n\n### 3. Create a new model from the train tab\n\nVisit the train tab on Replicate:\n\nhttps://replicate.com/fofr/any-comfyui-workflow/train\n\nHere you can give public or private URLs to weights on HuggingFace and CivitAI. If URLs are private or need authentication, make sure to include an API key or access token.\n\nCheck the training logs to see what filenames to use in your workflow JSON. For example:\n\n```\nDownloading from HuggingFace:\n...\nSize of the tar file: 217.88 MB\n====================================\nWhen using your new model, use these filenames in your JSON workflow:\naraminta_k_midsommar_cartoon.safetensors\n```\n\nAfter running the training, you'll have your own ComfyUI model with your customised weights loaded during model setup. To prevent others from using it, you can make it private. Private models are billed differently to public models on Replicate.\n\n## Developing locally\n\nClone this repository:\n\n```sh\ngit clone --recurse-submodules https://github.com/replicate/cog-comfyui.git\n```\n\nRun the [following script](https://github.com/replicate/cog-comfyui/blob/main/scripts/install_custom_nodes.py) to install all the custom nodes:\n\n```sh\n./scripts/install_custom_nodes.py\n```\n\nYou can view the list of nodes in [custom_nodes.json](https://github.com/replicate/cog-comfyui/blob/main/custom_nodes.json)\n\n### Running the Web UI from your Cog container\n\n1. **GPU Machine**: Start the Cog container and expose port 8188:\n```sh\nsudo cog run -p 8188 bash\n```\nRunning this command starts up the Cog container and let's you access it\n\n2. **Inside Cog Container**: Now that we have access to the Cog container, we start the server, binding to all network interfaces:\n```sh\ncd ComfyUI/\npython main.py --listen 0.0.0.0\n```\n\n3. **Local Machine**: Access the server using the GPU machine's IP and the exposed port (8188):\n`http://\u003cgpu-machines-ip\u003e:8188`\n\nWhen you goto `http://\u003cgpu-machines-ip\u003e:8188` you'll see the classic ComfyUI web form!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freplicate%2Fcog-comfyui","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freplicate%2Fcog-comfyui","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freplicate%2Fcog-comfyui/lists"}