receyuki / comfyui-prompt-reader-node

The ultimate solution for managing image metadata and multi-tool compatibility. ComfyUI node version of the SD Prompt Reader
MIT License
289 stars 22 forks source link
comfyui comfyui-workflow prompt-engineering prompt-toolkit stable-diffusion stable-diffusion-webui
icon

SD Prompt Reader Node

GitHub GitHub tag (with filter) GitHub tag (with filter) Code style: black
This is a subproject of the SD Prompt Reader. It helps you extract metadata from images in any format supported by the SD Prompt Reader and saves the images with additional metadata to ensure compatibility with metadata detection on websites such as Civitai.

Supported FormatsInstallationUsageChange LogCredits

Supported Formats

PNG JPEG WEBP TXT*
A1111's webUI
Easy Diffusion
StableSwarmUI*
StableSwarmUI (prior to 0.5.8-alpha)*
Fooocus-MRE*
NovelAI (stealth pnginfo)
NovelAI (legacy)
InvokeAI
InvokeAI (prior to 2.3.5-post.2)
InvokeAI (prior to 1.15)
ComfyUI*
Draw Things
Naifu(4chan)

See SD Prompt Reader for details

Installation

[!NOTE] While ZIP package is available, it is strongly recommended not to use it for installation.

Install and update via ComfyUI Manager (Recommended)

Search for SD Prompt Reader in the ComfyUI Manager and install it.

Install manually

Please make sure to install the submodules along with the main repository.

  1. cd to the custom_node folder
  2. Clone this repo
    git clone --recursive https://github.com/receyuki/comfyui-prompt-reader-node.git
  3. Install dependencies
    cd comfyui-prompt-reader-node
    pip install -r requirements.txt

    Update

    When updating, don't forget to include the submodules along with the main repository.

    git pull --recurse-submodules

Usage

Prompt Reader Node

reader node
More Information #### `parameter_index` - For images containing multiple sets of parameters, such as those processed through `hires-fix` or `refiner`, you will need to modify the `parameter_index` to select the parameters you need #### SDXL - For images generated by SDXL and containing multiple sets of prompts, the `text_g` will be combined with `text_l` into a single prompt #### Batch Read - For batch processing, please use the `Batch Loader` node. When using the `Batch Loader` node for bulk reading, the preview image will not update, and the text box will only display the metadata of the last image.
connect batch loader to prompt reader
#### Additional Parameters - To read parameters other than the existing output, please connect the `settings` to the `Parameter Extractor` node.
connect prompt reader to parameter extractor
#### `MODEL_NAME` - `MODEL_NAME` is a special output that matches the model name in the metadata with the existing models on the server according to the following priority: 1. Identical path, filename, and extension. 2. Identical filename, and extension. e.g. `sd_xl_base.safetensors` will be matched with `SDXL\sd_xl_base.safetensors`, and vice versa. 3. Identical filename. e.g. `sd_xl_base` will be matched with `SDXL\sd_xl_base.safetensors`, and vice versa. 4. If a matching model cannot be found, the original name will be outputted.

Prompt Saver Node

saver node
More Information #### Image Format - Only PNG format supports embedding both metadata and workflow at the same time. Other formats can only embed metadata. #### Duplicate Filename - When the filename already exists, an index will be added at the end of the filename, e.g. `file.png, file_1.png, file_2.png`. #### Hashes & Auto-Detection on Civitai - When `calculate_hash` is enabled, the node will compute the hash values of checkpoint, VAE, Lora, and embedding/Textual Inversion, and write them into the metadata. After the server restarts, or a new checkpoint, VAE, Lora, or embedding/Textual Inversion is loaded, the first image generation may take a longer time for hash calculation. The hash value will be stored in temporary storage without the need for repeated calculation, until the server is restarted. - When `resource_hash` is enabled, the resource hashes will be written into the metadata to support auto-detection on Civitai. This function will only run when `calculate_hash` is enabled. - If you need to calculate the hash of Lora, please use the `Lora Loader` Node or the `Lora Selector` Node. The hash value of the embedding/Textual Inversion will be automatically detected from the prompt. #### `save_metadata_file` - When the `save_metadata_file` is turned on, the metadata will be saved as a TXT file with the same name alongside the image. #### `date_format` & `time_format` - For the `date_format` and `time_format`, please refer to [strftime.org](https://strftime.org/) or [www.strfti.me](https://www.strfti.me/). #### `filename` & `path` - `%counter` cannot be used for `path`, it can only be used for `filename`. This `%counter` is slightly different from the `%counter` in the built-in `Saver` node, it will count all image files in the `path`. - Please refer to the following table for placeholders supported by the `filename` and `path`. | | | |------------|------------| | %seed | %date | | %steps | %time | | %cfg | %counter | | %model | %extension | | %sampler | %quality | | %scheduler | |

Parameter Generator Node

generator node
More Information #### Optimal Resolution - The `model_version` and `aspect_ratio` are used only for calculating the optimal resolution of the selected model version under the chosen aspect ratio. The calculation method is based on the [Stability AI development documentation](https://platform.stability.ai/docs/features/api-parameters#about-dimensions) and the [StableSwarmUI source code](https://github.com/Stability-AI/StableSwarmUI) (developed by Stability AI). #### `refiner_start` - `refiner_start` refers to the proportion of steps completed when the refiner starts running, i.e., the proportion of base steps to total steps. This is used to calculate the `start_at_step` (`REFINER_START_STEP`) required by the refiner `KSampler` under the selected step ratio.

Batch Loader Node

loader node

path

Parameter Extractor Node

extractor node

Prompt Merger Node & Type Converter Node

merger and converter node

Lora Loader Node & Lora Selector Node

lora loader and selector node
  1. Lora Selector chain
    lora loader chain

Example Workflow

Simple Example
example workflow
Lora Example
example workflow
Hires-fix Example
example workflow
SDXL Example
example workflow

Credits