Update README.md

Update CHANGELOG.md
Update example workflow
This commit is contained in:
receyuki
2024-01-22 03:07:45 +08:00
parent e32a514adc
commit 2321ce5ae4
20 changed files with 6305 additions and 718 deletions
+1
View File
@@ -153,3 +153,4 @@ dmypy.json
cython_debug/
.idea/
preview/
+22
View File
@@ -1,4 +1,26 @@
# Change Log
## v1.3.0
> Starting from this version, to support auto-detection on Civitai, `calculate_model_hash` will be renamed as
> `calculate_hash` and it will be enabled by default. Due to the addition of temporary storage of the model hash values,
> the first image generated after switching to the new model will take more time to calculate the hash value,
> but it will not affect the generation speed afterwards until the server is restarted.
- Add `Lora Loader` node and `Lora Selector` node
- Add `VAE_NAME` output to the `Parameter Generator` node and add `vae_name` input to the `Prompt Saver` node #39
- Add `lora_name` input to the `Prompt Saver` node
- Add `resource_hash` switch to the `Prompt Saver` node
- Add resources hashes to metadata for auto-detection on Civitai #35
- Add temporary storage for model hashes
- Add `WEB_DIRECTORY` and remove old js directory
- Fix adding the `Parameter Generator` node to a workflow disables the queue button #45
- Fix the `Parameter Generator` node doesn't load seed value from generated images #44
- Fix the input validation of the `Batch Loader` node #37 #38
- Fix the parsing error caused by the loss of model data #43
- Fix the error message caused by aspect_ratio
- Rename `calculate_model_hash` as `calculate_hash`
- Update seedGen.js to rgthree's latest code
- Update core to cc3c8b2
## v1.2.1
- Fix the input validation of the `Prompt Reader` node #37
- Fix the `Batch Loader` node not working when not connected to any node
+175 -64
View File
@@ -23,7 +23,7 @@ additional metadata to ensure compatibility with metadata detection on websites
<a href="./CHANGELOG.md">Change Log</a> •
<a href="#credits">Credits</a>
</p>
<img src="./images/screenshot_v120.png">
<img src="./images/screenshot_v130.png">
</div>
@@ -66,6 +66,10 @@ git pull --recurse-submodules
## Usage
### Prompt Reader Node
<div align="center">
<img src="./images/reader.png" width="25%" height="25%" alt="reader node">
</div>
- The `Prompt Reader` Node works exactly the same as the
[standalone SD Prompt Reader](https://github.com/receyuki/stable-diffusion-prompt-reader).
It uses the Image Data Reader from the
@@ -74,13 +78,30 @@ allowing it to support the same formats and receive updates along with the
[SD Prompt Reader](https://github.com/receyuki/stable-diffusion-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.
to ensure maximum compatibility.
<details>
<summary><b>More Information</b></summary>
#### `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
- For batch processing, please use the `Batch Loader` node.
#### 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.
<div align="center">
<img src="./images/loader2reader.png" width="50%" height="50%" alt="connect batch loader to prompt reader">
</div>
#### Additional Parameters
- To read parameters other than the existing output, please connect the `settings` to the `Parameter Extractor` node.
<div align="center">
<img src="./images/reader2extractor.png" width="50%" height="50%" alt="connect prompt reader to parameter extractor">
</div>
#### `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.
@@ -90,108 +111,198 @@ e.g. `sd_xl_base.safetensors` will be matched with `SDXL\sd_xl_base.safetensors`
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.
<div align="center">
<img src="./images/reader.png" width="25%" height="25%" alt="reader node">
</div>
</details>
### 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](https://strftime.org/) or [www.strfti.me](https://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.
<div align="center">
<img src="./images/saver.png" width="25%" height="25%" alt="saver node">
</div>
## 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](https://perilli.com/ai/comfyui/).
- 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` 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.
- 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's recommended to embed this node within the workflow
to ensure maximum compatibility.
- Since it's not possible to directly extract metadata from `KSampler`, it's necessary to
use the `Parameter Generator` Node to generate parameters and simultaneously output them to
the `Prompt Saver` Node and `KSampler` Node.
<details>
<summary><b>More Information</b></summary>
#### 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 | |
</details>
### Parameter Generator Node
<div align="center">
<img src="./images/generator.png" width="25%" height="25%" alt="generator node">
</div>
- Since it's not possible to directly extract metadata from `KSampler`, it's necessary to
use the `Parameter Generator` Node to generate parameters and simultaneously output them to both
the `Prompt Saver` Node and `KSampler` Node.
- The `Parameter Generator` Node can also be used as a control panel for complex ComfyUI workflows, just like the [AP workflow](https://perilli.com/ai/comfyui/).
<details>
<summary><b>More Information</b></summary>
#### 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.
</details>
### Batch Loader Node
<div align="center">
<img src="./images/loader.png" width="25%" height="25%" alt="loader node">
</div>
- 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.
<details>
<summary><b>More Information</b></summary>
- For batch processing, please connect the `IMAGE` output of the `Batch Loader` Node to the `image` input of
the `Prompt Reader` Node.
<div align="center">
<img src="./images/loader2reader.png" width="50%" height="50%" alt="connect prompt reader to parameter extractor">
</div>
#### `path`
- 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.
<div align="center">
<img src="./images/loader.png" width="25%" height="25%" alt="loader node">
</div>
</details>
### 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.
<div align="center">
<img src="./images/extractor.png" width="25%" height="25%" alt="extractor node">
</div>
- 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`
<details>
<summary><b>More Information</b></summary>
- 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.
<div align="center">
<img src="./images/reader2extractor.png" width="50%" height="50%" alt="connect prompt reader to parameter extractor">
</div>
</details>
### Prompt Merger Node & Type Converter Node
<div align="center">
<img src="./images/merger_converter.png" width="25%" height="25%" alt="merger and converter node">
</div>
- 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.
### Lora Loader Node & Lora Selector Node
<div align="center">
<img src="./images/merger_converter.png" width="25%" height="25%" alt="merger and converter node">
<img src="./images/lora.png" width="50%" height="50%" alt="lora loader and selector node">
</div>
### [Example Workflow](https://raw.githubusercontent.com/receyuki/comfyui-prompt-reader-node/main/workflows/example_workflow.json)
- The `Lora Loader` Node and `Lora Selector` Node are used to write Lora data into metadata and support auto-detection
on Civitai.
<details>
<summary><b>More Information</b></summary>
- Replace the original loader with the `Lora Loader` Node, or connect the `LORA_NAME` output of the `Lora Selector` Node
to the `lora_name` input of other lora loaders (built-in or custom), and link the `NEXT_LORA` output to the `lora_name`
input of the `Prompt Saver` Node. Both of these nodes have the same function, please choose according to your needs.
#### Multiple Loras
- If you need to load multiple Loras, please connect the `Lora Loader` Node or `Lora Selector` Node head to tail
through `last_lora` and `NEXT_LORA`, and connect the `NEXT_LORA` at the end of the Lora chain to the `lora_name` input
of the `Prompt Saver` Node.
1. Lora Loader chain
<div align="center">
<img src="./images/example_workflow.png" width="100%" height="100%" alt="example workflow">
<img src="./images/lora_loader_chain.png" width="100%" height="100%" alt="lora loader chain">
</div>
2. Lora Selector chain
<div align="center">
<img src="./images/lora_selector_chain.png" width="100%" height="100%" alt="lora loader chain">
</div>
</details>
### Example Workflow
<details>
<summary><b>Simple Example</b></summary>
<div align="center">
<img src="./workflows/simple_example.png" width="100%" height="100%" alt="example workflow">
</div>
</details>
<details>
<summary><b>Lora Example</b></summary>
<div align="center">
<img src="./workflows/lora_example.png" width="100%" height="100%" alt="example workflow">
</div>
</details>
<details>
<summary><b>Hires-fix Example</b></summary>
<div align="center">
<img src="./workflows/hires_fix_example.png" width="100%" height="100%" alt="example workflow">
</div>
</details>
<details>
<summary><b>SDXL Example</b></summary>
<div align="center">
<img src="./workflows/sdxl_example.png" width="100%" height="100%" alt="example workflow">
</div>
</details>
## Credits
- The SD Prompt Reader node is based on [ComfyUI Load Image With Metadata](https://github.com/tkoenig89/ComfyUI_Load_Image_With_Metadata)
- The SD Prompt Saver node is based on [Comfy Image Saver](https://github.com/giriss/comfy-image-saver) & [Stable Diffusion Webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui)
Binary file not shown.

Before

Width:  |  Height:  |  Size: 420 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 112 KiB

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 421 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 512 KiB

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 978 KiB

File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 719 KiB

File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 655 KiB

File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 632 KiB