@@ -600,8 +600,12 @@ def program_version():
600600 return res
601601
602602
603- def create_infotext (p , all_prompts , all_seeds , all_subseeds , comments = None , iteration = 0 , position_in_batch = 0 , use_main_prompt = False ):
604- index = position_in_batch + iteration * p .batch_size
603+ 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 ):
604+ if index is None :
605+ index = position_in_batch + iteration * p .batch_size
606+
607+ if all_negative_prompts is None :
608+ all_negative_prompts = p .all_negative_prompts
605609
606610 clip_skip = getattr (p , 'clip_skip' , opts .CLIP_stop_at_last_layers )
607611 enable_hr = getattr (p , 'enable_hr' , False )
@@ -617,12 +621,12 @@ def create_infotext(p, all_prompts, all_seeds, all_subseeds, comments=None, iter
617621 "Sampler" : p .sampler_name ,
618622 "CFG scale" : p .cfg_scale ,
619623 "Image CFG scale" : getattr (p , 'image_cfg_scale' , None ),
620- "Seed" : all_seeds [index ],
624+ "Seed" : p . all_seeds [ 0 ] if use_main_prompt else all_seeds [index ],
621625 "Face restoration" : (opts .face_restoration_model if p .restore_faces else None ),
622626 "Size" : f"{ p .width } x{ p .height } " ,
623627 "Model hash" : getattr (p , 'sd_model_hash' , None if not opts .add_model_hash_to_info or not shared .sd_model .sd_model_hash else shared .sd_model .sd_model_hash ),
624628 "Model" : (None if not opts .add_model_name_to_info else shared .sd_model .sd_checkpoint_info .name_for_extra ),
625- "Variation seed" : (None if p .subseed_strength == 0 else all_subseeds [index ]),
629+ "Variation seed" : (None if p .subseed_strength == 0 else ( p . all_subseeds [0 ] if use_main_prompt else all_subseeds [ index ]) ),
626630 "Variation seed strength" : (None if p .subseed_strength == 0 else p .subseed_strength ),
627631 "Seed resize from" : (None if p .seed_resize_from_w <= 0 or p .seed_resize_from_h <= 0 else f"{ p .seed_resize_from_w } x{ p .seed_resize_from_h } " ),
628632 "Denoising strength" : getattr (p , 'denoising_strength' , None ),
@@ -642,7 +646,7 @@ def create_infotext(p, all_prompts, all_seeds, all_subseeds, comments=None, iter
642646 generation_params_text = ", " .join ([k if k == v else f'{ k } : { generation_parameters_copypaste .quote (v )} ' for k , v in generation_params .items () if v is not None ])
643647
644648 prompt_text = p .prompt if use_main_prompt else all_prompts [index ]
645- negative_prompt_text = f"\n Negative prompt: { p . all_negative_prompts [index ]} " if p . all_negative_prompts [index ] else ""
649+ negative_prompt_text = f"\n Negative prompt: { all_negative_prompts [index ]} " if all_negative_prompts [index ] else ""
646650
647651 return f"{ prompt_text } { negative_prompt_text } \n { generation_params_text } " .strip ()
648652
@@ -716,9 +720,6 @@ def process_images_inner(p: StableDiffusionProcessing) -> Processed:
716720 else :
717721 p .all_subseeds = [int (subseed ) + x for x in range (len (p .all_prompts ))]
718722
719- def infotext (iteration = 0 , position_in_batch = 0 , use_main_prompt = False ):
720- return create_infotext (p , p .all_prompts , p .all_seeds , p .all_subseeds , comments , iteration , position_in_batch , use_main_prompt )
721-
722723 if os .path .exists (cmd_opts .embeddings_dir ) and not p .do_not_reload_embeddings :
723724 model_hijack .embedding_db .load_textual_inversion_embeddings ()
724725
@@ -806,6 +807,16 @@ def infotext(iteration=0, position_in_batch=0, use_main_prompt=False):
806807 if p .scripts is not None :
807808 p .scripts .postprocess_batch (p , x_samples_ddim , batch_number = n )
808809
810+ p .prompts = p .all_prompts [n * p .batch_size :(n + 1 ) * p .batch_size ]
811+ p .negative_prompts = p .all_negative_prompts [n * p .batch_size :(n + 1 ) * p .batch_size ]
812+
813+ batch_params = scripts .PostprocessBatchListArgs (list (x_samples_ddim ))
814+ p .scripts .postprocess_batch_list (p , batch_params , batch_number = n )
815+ x_samples_ddim = batch_params .images
816+
817+ def infotext (index = 0 , use_main_prompt = False ):
818+ return create_infotext (p , p .prompts , p .seeds , p .subseeds , use_main_prompt = use_main_prompt , index = index , all_negative_prompts = p .negative_prompts )
819+
809820 for i , x_sample in enumerate (x_samples_ddim ):
810821 p .batch_index = i
811822
@@ -814,7 +825,7 @@ def infotext(iteration=0, position_in_batch=0, use_main_prompt=False):
814825
815826 if p .restore_faces :
816827 if opts .save and not p .do_not_save_samples and opts .save_images_before_face_restoration :
817- images .save_image (Image .fromarray (x_sample ), p .outpath_samples , "" , p .seeds [i ], p .prompts [i ], opts .samples_format , info = infotext (n , i ), p = p , suffix = "-before-face-restoration" )
828+ images .save_image (Image .fromarray (x_sample ), p .outpath_samples , "" , p .seeds [i ], p .prompts [i ], opts .samples_format , info = infotext (i ), p = p , suffix = "-before-face-restoration" )
818829
819830 devices .torch_gc ()
820831
@@ -831,15 +842,15 @@ def infotext(iteration=0, position_in_batch=0, use_main_prompt=False):
831842 if p .color_corrections is not None and i < len (p .color_corrections ):
832843 if opts .save and not p .do_not_save_samples and opts .save_images_before_color_correction :
833844 image_without_cc = apply_overlay (image , p .paste_to , i , p .overlay_images )
834- images .save_image (image_without_cc , p .outpath_samples , "" , p .seeds [i ], p .prompts [i ], opts .samples_format , info = infotext (n , i ), p = p , suffix = "-before-color-correction" )
845+ images .save_image (image_without_cc , p .outpath_samples , "" , p .seeds [i ], p .prompts [i ], opts .samples_format , info = infotext (i ), p = p , suffix = "-before-color-correction" )
835846 image = apply_color_correction (p .color_corrections [i ], image )
836847
837848 image = apply_overlay (image , p .paste_to , i , p .overlay_images )
838849
839850 if opts .samples_save and not p .do_not_save_samples :
840- images .save_image (image , p .outpath_samples , "" , p .seeds [i ], p .prompts [i ], opts .samples_format , info = infotext (n , i ), p = p )
851+ images .save_image (image , p .outpath_samples , "" , p .seeds [i ], p .prompts [i ], opts .samples_format , info = infotext (i ), p = p )
841852
842- text = infotext (n , i )
853+ text = infotext (i )
843854 infotexts .append (text )
844855 if opts .enable_pnginfo :
845856 image .info ["parameters" ] = text
@@ -850,10 +861,10 @@ def infotext(iteration=0, position_in_batch=0, use_main_prompt=False):
850861 image_mask_composite = Image .composite (image .convert ('RGBA' ).convert ('RGBa' ), Image .new ('RGBa' , image .size ), images .resize_image (2 , p .mask_for_overlay , image .width , image .height ).convert ('L' )).convert ('RGBA' )
851862
852863 if opts .save_mask :
853- images .save_image (image_mask , p .outpath_samples , "" , p .seeds [i ], p .prompts [i ], opts .samples_format , info = infotext (n , i ), p = p , suffix = "-mask" )
864+ images .save_image (image_mask , p .outpath_samples , "" , p .seeds [i ], p .prompts [i ], opts .samples_format , info = infotext (i ), p = p , suffix = "-mask" )
854865
855866 if opts .save_mask_composite :
856- images .save_image (image_mask_composite , p .outpath_samples , "" , p .seeds [i ], p .prompts [i ], opts .samples_format , info = infotext (n , i ), p = p , suffix = "-mask-composite" )
867+ images .save_image (image_mask_composite , p .outpath_samples , "" , p .seeds [i ], p .prompts [i ], opts .samples_format , info = infotext (i ), p = p , suffix = "-mask-composite" )
857868
858869 if opts .return_mask :
859870 output_images .append (image_mask )
@@ -894,7 +905,7 @@ def infotext(iteration=0, position_in_batch=0, use_main_prompt=False):
894905 p ,
895906 images_list = output_images ,
896907 seed = p .all_seeds [0 ],
897- info = infotext () ,
908+ info = infotexts [ 0 ] ,
898909 comments = "" .join (f"{ comment } \n " for comment in comments ),
899910 subseed = p .all_subseeds [0 ],
900911 index_of_first_image = index_of_first_image ,
0 commit comments