ghostsquad / comfyui-prompt-reader-node

ComfyUI node version of the SD Prompt Reader

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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*
Fooocus-MRE*
InvokeAI
ComfyUI*
NovelAI
Draw Things
Naifu(4chan)

See SD Prompt Reader for details

Installation

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

  • The Prompt Reader Node works exactly the same as the standalone SD Prompt Reader. It uses the Image Data Reader from the standalone SD Prompt Reader, allowing it to support the same formats and receive updates along with the SD Prompt Reader.
  • Due to custom nodes and complex workflows potentially causing issues with SD Prompt Reader's ability to read image metadata correctly, it is recommended to embed the Prompt Saver Node within the workflow to ensure maximum compatibility.
  • 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
  • For images generated by SDXL and containing multiple sets of prompts, the text_g will be combined with text_l into a single prompt
  • For batch processing, please use the Batch Loader node.
  • To read parameters other than the existing output, please connect the settings to the Parameter Extractor node.
  • 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.
reader node

Prompt Saver Node

  • The Prompt Saver Node and The Parameter Generator Node are designed to be used together.

  • The Prompt Saver Node will write additional metadata in the A1111 format to the output images to be compatible with any tools that support the A1111 format, including SD Prompt Reader and Civitai. Due to custom nodes and complex workflows potentially causing issues with SD Prompt Reader's ability to read image metadata correctly, it is recommended to embed this node within the workflow to ensure maximum compatibility.

  • Since it's not possible to directly extract metadata from KSampler, it is necessary to use the Parameter Generator Node to generate parameters and simultaneously output them to both the Prompt Saver Node and KSampler.

  • Please refer to the following table for placeholders supported by the filename and path.

    Placeholder
    %date
    %time
    %counter
    %seed
    %steps
    %cfg
    %extension
    %model
    %sampler
    %scheduler
    %quality
  • %counter cannot be used for the path. This %counter is slightly different from the %counter in the built-in Saver node, it will count all image files in the path.

  • 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.

  • For the date_format and time_format, please refer to strftime.org or www.strfti.me.

  • When the save_metadata_file is turned on, the metadata will be saved as a TXT file with the same name alongside the image.

saver node

Parameter Generator Node

  • Since it's not possible to directly extract metadata from KSampler, it is necessary to use the Parameter Generator Node to generate parameters and simultaneously output them to both the Prompt Saver Node and KSampler.
  • The Parameter Generator Node can also be used as a control panel for complex ComfyUI workflows, just like the AP workflow.
  • 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 and the StableSwarmUI source code (developed by Stability AI).
  • 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.
generator node

Batch Loader Node

  • The Batch Loader Node is specifically designed for the Prompt Reader Node to batch-read image files in a directory and cannot be used with other custom nodes.
  • For batch processing, please connect the IMAGE output of the Batch Loader Node to the image input of the Prompt Reader Node.
  • The path supports relative paths such as ./input/ or absolute paths like C:/Users/receyuki/Pictures.
  • Both \ and / are acceptable.
  • You can also input a single file or a list of files into the path, in which case the image_load_limit and start_index will not function.
loader node

Parameter Extractor Node

  • The Parameter Extractor Node is an extension of the Prompt Reader Node, designed to retrieve the values of all parameters in the settings (including those parameters that the Prompt Reader Node cannot output). e.g. Hires upscaler
  • Connect the SETTINGS of the Prompt Reader Node to the settings of the Parameter Extractor Node. After the first run, the parameter list will be loaded.
extractor node

Prompt Merger Node & Type Converter Node

  • Since the A1111 format cannot store text_g and text_l separately, SDXL users need to use the Prompt Merger Node to combine text_g and text_l into a single prompt.
  • Since model_name, sampler_name, and scheduler are special types that cannot be directly used by some other nodes, You can use the Type Converter Node to convert them into STRING type.
merger and converter node
example workflow

Credits

About

ComfyUI node version of the SD Prompt Reader

License:MIT License


Languages

Language:Python 68.7%Language:JavaScript 31.3%