MCPcopy Create free account
hub / github.com/DenOfEquity/ersatzForge / create_infotext

Function create_infotext

modules/processing.py:600–793  ·  view source on GitHub ↗

this function is used to generate the infotext that is stored in the generated images, it contains the parameters that are required to generate the image Args: p: StableDiffusionProcessing all_prompts: list[str] all_seeds: list[int] all_subseeds: list[i

(p, all_prompts, all_seeds, all_subseeds, iteration=0, position_in_batch=0, use_main_prompt=False, index=None, all_negative_prompts=None)

Source from the content-addressed store, hash-verified

598 iteration: int
599 position_in_batch: int
600 use_main_prompt: bool
601 index: int
602 all_negative_prompts: list[str]
603
604 Returns: str
605
606 Extra generation params
607 p.extra_generation_params dictionary allows for additional parameters to be added to the infotext
608 this can be use by the base webui or extensions.
609 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
610 the value generation_params can be defined as:
611 - str | None
612 - List[str|None]
613 - callable func(**kwargs) -> str | None
614
615 When defined as a string, it will be used as without extra processing; this is this most common use case.
616
617 Defining as a list allows for parameter that changes across images in the job, for example, the 'Seed' parameter.
618 The list should have the same length as the total number of images in the entire job.
619
620 Defining as a callable function allows parameter cannot be generated earlier or when extra logic is required.
621 For example 'HiRes prompt', due to reasons the hr_prompt might be changed by process in the pipeline or extensions
622 and may vary across different images, defining as a static string or list would not work.
623
624 The function takes locals() as **kwargs, as such will have access to variables like 'p' and 'index'.
625 the base signature of the function should be:
626 func(**kwargs) -> str | None
627 optionally it can have additional arguments that will be used in the function:
628 func(p, index, **kwargs) -> str | None
629 note: for better future compatibility even though this function will have access to all variables in the locals(),
630 it is recommended to only use the arguments present in the function signature of create_infotext.
631 For actual implementation examples, see StableDiffusionProcessingTxt2Img.init > get_hr_prompt.
632 """
633
634 if use_main_prompt:
635 index = 0
636 elif index is None:
637 index = position_in_batch + iteration * p.batch_size
638
639 if all_negative_prompts is None:
640 all_negative_prompts = p.all_negative_prompts
641
642 clip_skip = int(getattr(p, 'clip_skip', opts.CLIP_stop_at_last_layers))
643 enable_hr = getattr(p, 'enable_hr', False)
644 token_merging_ratio = p.get_token_merging_ratio()
645 token_merging_ratio_hr = p.get_token_merging_ratio(for_hr=True)
646
647 prompt_text = p.main_prompt if use_main_prompt else all_prompts[index]
648 negative_prompt = p.main_negative_prompt if use_main_prompt else all_negative_prompts[index]
649
650 uses_ensd = opts.eta_noise_seed_delta != 0
651 if uses_ensd:
652 uses_ensd = sd_samplers_common.is_sampler_using_eta_noise_seed_delta(p)
653
654 timesteps_samplers = ["DDIM", "DDIM CFG++", "PLMS", "UniPC"]
655
656 generation_params = {
657 "Steps": p.steps,

Callers 3

infotextMethod · 0.85
infotextFunction · 0.85
save_intermediateMethod · 0.85

Calls 4

getMethod · 0.80
joinMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected