Skip to content

Commit e3aabe6

Browse files
committed
add documentation for create_infotext
1 parent 1e1176b commit e3aabe6

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

modules/processing.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,50 @@ def program_version():
704704

705705

706706
def create_infotext(p, all_prompts, all_seeds, all_subseeds, comments=None, iteration=0, position_in_batch=0, use_main_prompt=False, index=None, all_negative_prompts=None):
707+
"""
708+
this function is used to generate the infotext that is stored in the generated images, it's contains the parameters that are required to generate the imagee
709+
Args:
710+
p: StableDiffusionProcessing
711+
all_prompts: list[str]
712+
all_seeds: list[int]
713+
all_subseeds: list[int]
714+
comments: list[str]
715+
iteration: int
716+
position_in_batch: int
717+
use_main_prompt: bool
718+
index: int
719+
all_negative_prompts: list[str]
720+
721+
Returns: str
722+
723+
Extra generation params
724+
p.extra_generation_params dictionary allows for additional parameters to be added to the infotext
725+
this can be use by the base webui or extensions.
726+
To add a new entry, add a new key value pair, the dictionary key will be used as the key of the parameter in the infotext
727+
the value generation_params can be defined as:
728+
- str | None
729+
- List[str|None]
730+
- callable func(**kwargs) -> str | None
731+
732+
When defined as a string, it will be used as without extra processing; this is this most common use case.
733+
734+
Defining as a list allows for parameter that changes across images in the job, for example, the 'Seed' parameter.
735+
The list should have the same length as the total number of images in the entire job.
736+
737+
Defining as a callable function allows parameter cannot be generated earlier or when extra logic is required.
738+
For example 'Hires prompt', due to reasons the hr_prompt might be changed by process in the pipeline or extensions
739+
and may vary across different images, defining as a static string or list would not work.
740+
741+
The function takes locals() as **kwargs, as such will have access to variables like 'p' and 'index'.
742+
the base signature of the function should be:
743+
func(**kwargs) -> str | None
744+
optionally it can have additional arguments that will be used in the function:
745+
func(p, index, **kwargs) -> str | None
746+
note: for better future compatibility even though this function will have access to all variables in the locals(),
747+
it is recommended to only use the arguments present in the function signature of create_infotext.
748+
For actual implementation examples, see StableDiffusionProcessingTxt2Img.init > get_hr_prompt.
749+
"""
750+
707751
if use_main_prompt:
708752
index = 0
709753
elif index is None:

0 commit comments

Comments
 (0)