I've added a script to execute a default pipeline and updated the README.

This update introduces a new Python script, `script_examples/execute_default_pipeline.py`, that allows you to execute a predefined ComfyUI pipeline.

The script:
- Defines a default pipeline structure in JSON format.
- Sends the pipeline to a running ComfyUI server instance for execution.
- Prints a success message upon queuing the prompt.

The `README.md` has been updated to include:
- A new section "Running a Default Pipeline".
- Step-by-step instructions on how to run the new script.
- Information on where to find the generated output images.
- A note about the required checkpoint file (`v1-5-pruned-emaonly.safetensors`).
This commit is contained in:
google-labs-jules[bot] 2025-06-21 06:51:22 +00:00
parent 9dc31cd71e
commit 467bc66bfd
2 changed files with 133 additions and 0 deletions

View File

@ -34,6 +34,24 @@
This ui will let you design and execute advanced stable diffusion pipelines using a graph/nodes/flowchart based interface. For some workflow examples and see what ComfyUI can do you can check out:
### [ComfyUI Examples](https://comfyanonymous.github.io/ComfyUI_examples/)
## Running a Default Pipeline
A script to execute a default pipeline is available in `script_examples/execute_default_pipeline.py`.
To run this script:
1. **Ensure ComfyUI Server is Running:**
Start the ComfyUI server by running `python main.py` in your terminal from the root directory of this project. By default, the server runs at `http://127.0.0.1:8188`.
2. **Execute the Script:**
Open another terminal, navigate to the `script_examples/` directory, and run the script:
```bash
python execute_default_pipeline.py
```
3. **Find the Output:**
If the execution is successful, the script will print "Prompt queued successfully!". The generated image will be saved in the `output/` directory with a filename starting with `ComfyUI` (e.g., `ComfyUI_00001_.png`).
**Note:** The default pipeline uses the `v1-5-pruned-emaonly.safetensors` checkpoint. Make sure this checkpoint is available in your `models/checkpoints/` directory. If not, you can either download it or modify the `ckpt_name` in the `execute_default_pipeline.py` script to use a checkpoint you have.
### [Installing ComfyUI](#installing)
## Features

View File

@ -0,0 +1,115 @@
import json
from urllib import request
# This is the ComfyUI api prompt format.
# If you want it for a specific workflow you can "enable dev mode options"
# in the settings of the UI (gear beside the "Queue Size: ") this will enable
# a button on the UI to save workflows in api format.
# keep in mind ComfyUI is pre alpha software so this format will change a bit.
# this is the one for the default workflow
prompt_text = """
{
"3": {
"class_type": "KSampler",
"inputs": {
"cfg": 8,
"denoise": 1,
"latent_image": [
"5",
0
],
"model": [
"4",
0
],
"negative": [
"7",
0
],
"positive": [
"6",
0
],
"sampler_name": "euler",
"scheduler": "normal",
"seed": 8566257,
"steps": 20
}
},
"4": {
"class_type": "CheckpointLoaderSimple",
"inputs": {
"ckpt_name": "v1-5-pruned-emaonly.safetensors"
}
},
"5": {
"class_type": "EmptyLatentImage",
"inputs": {
"batch_size": 1,
"height": 512,
"width": 512
}
},
"6": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"4",
1
],
"text": "masterpiece best quality girl"
}
},
"7": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"4",
1
],
"text": "bad hands"
}
},
"8": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"3",
0
],
"vae": [
"4",
2
]
}
},
"9": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI",
"images": [
"8",
0
]
}
}
}
"""
def queue_prompt(prompt):
p = {"prompt": prompt}
data = json.dumps(p).encode('utf-8')
req = request.Request("http://127.0.0.1:8188/prompt", data=data)
request.urlopen(req)
print("Prompt queued successfully!")
if __name__ == "__main__":
prompt = json.loads(prompt_text)
# You can modify the prompt here if needed, for example:
# prompt["6"]["inputs"]["text"] = "masterpiece best quality man"
# prompt["3"]["inputs"]["seed"] = 5
queue_prompt(prompt)