ComfyUI Node: Sample Tags

Class Name

PromptUtilitiesSampleTags

Category
PromptUtilities
Author
nkchocoai (Account age: 825days)
Extension
ComfyUI-PromptUtilities
Latest Updated
2025-03-30
Github Stars
0.03K

How to Install ComfyUI-PromptUtilities

Install this extension via the ComfyUI Manager by searching for ComfyUI-PromptUtilities
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter ComfyUI-PromptUtilities in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • 16GB VRAM to 80GB VRAM GPU machines
  • 400+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 200+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

Sample Tags Description

Facilitates random tag sampling from a list for creative AI, ensuring reproducibility and variability.

Sample Tags:

The PromptUtilitiesSampleTags node is designed to facilitate the random sampling of tags from a given list, which can be particularly useful in creative AI applications where variability and randomness are desired. This node allows you to input a list of tags and specify how many of these tags should be randomly selected, providing a dynamic way to generate varied outputs. By leveraging a random seed, the node ensures that the sampling process can be both reproducible and varied, depending on the user's needs. This functionality is essential for AI artists who want to introduce controlled randomness into their workflows, enabling them to explore different creative possibilities without manually altering tag lists.

Sample Tags Input Parameters:

tags

This parameter accepts a string of tags that you want to sample from. The tags can be inputted as a multiline string or separated by a delimiter, allowing flexibility in how you organize your tag list. The default value is an empty string, and it supports multiline input to accommodate extensive lists.

tags_delimiter

The tags_delimiter parameter specifies how the tags are separated in the input string. You can choose between "new line" or a comma (,), which allows the node to correctly parse and split the tags for sampling. This ensures that the tags are accurately identified and processed.

seed

The seed parameter is an integer that initializes the random number generator. By setting a specific seed, you can ensure that the random sampling process is reproducible, meaning the same seed will always produce the same sampled tags. The default value is 0, with a range from 0 to 18,446,744,073,709,551,615.

max_k

This integer parameter defines the maximum number of tags to sample. It allows you to control the upper limit of how many tags can be randomly selected from the list. The default value is 1, with a minimum of 1 and a maximum of 18,446,744,073,709,551,615.

min_k

The min_k parameter sets the minimum number of tags to sample. It ensures that at least this number of tags will be selected, providing a lower bound for the sampling process. The default value is 1, with a minimum of 0 and a maximum of 18,446,744,073,709,551,615.

Sample Tags Output Parameters:

STRING

The output is a single string that contains the randomly sampled tags, joined by a comma. This output provides a concise and easily usable format for the sampled tags, which can be directly integrated into other processes or used for further creative exploration. The output string reflects the randomness and constraints specified by the input parameters, offering a flexible tool for generating varied tag combinations.

Sample Tags Usage Tips:

  • To ensure reproducibility in your creative projects, use a fixed seed value. This will allow you to generate the same set of sampled tags consistently across different runs.
  • Experiment with different max_k and min_k values to explore a range of tag combinations. This can help you discover new creative directions by varying the number of tags sampled.

Sample Tags Common Errors and Solutions:

AssertionError: max_k must be greater than or equal to min_k.

  • Explanation: This error occurs when the max_k value is set lower than the min_k value, which violates the logical requirement that the maximum number of tags to sample should be greater than or equal to the minimum.
  • Solution: Ensure that the max_k parameter is always set to a value greater than or equal to min_k. Adjust the values accordingly to resolve this error.

ValueError: Invalid tags_delimiter

  • Explanation: This error might occur if an unsupported delimiter is provided for the tags_delimiter parameter.
  • Solution: Use only the supported delimiters, which are "new line" or a comma (,), to separate your tags in the input string.

Sample Tags Related Nodes

Go back to the extension to check out more related nodes.
ComfyUI-PromptUtilities
RunComfy
Copyright 2025 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Models, enabling artists to harness the latest AI tools to create incredible art.