@@ -359,13 +359,6 @@ def process(
359
359
rpr : list [str ] = getattr (p , "all_prompts" , None )
360
360
rnr : list [str ] = getattr (p , "all_negative_prompts" , None )
361
361
if rpr is not None and rnr is not None :
362
- if add_prompts :
363
- extra_params .update (
364
- {
365
- "PPP original prompts" : rpr .copy (),
366
- "PPP original negative prompts" : rnr .copy (),
367
- }
368
- )
369
362
prompts_list += [
370
363
("regular" , seed , prompt , negative_prompt )
371
364
for seed , prompt , negative_prompt in zip (calculated_seeds , rpr , rnr )
@@ -375,24 +368,12 @@ def process(
375
368
rph : list [str ] = getattr (p , "all_hr_prompts" , None )
376
369
rnh : list [str ] = getattr (p , "all_hr_negative_prompts" , None )
377
370
if rph is not None and rnh is not None :
378
- if add_prompts :
379
- extra_params .update (
380
- {
381
- "PPP original HR prompts" : rph .copy (),
382
- "PPP original HR negative prompts" : rnh .copy (),
383
- }
384
- )
385
371
prompts_list += [
386
372
("hiresfix" , seed , prompt , negative_prompt )
387
373
for seed , prompt , negative_prompt in zip (calculated_seeds , rph , rnh )
388
374
if (seed , prompt , negative_prompt ) not in prompts_list
389
375
]
390
376
391
- # fill extra generation parameters only if not already present
392
- for k , v in extra_params .items ():
393
- if p .extra_generation_params .get (k ) is None :
394
- p .extra_generation_params [k ] = v
395
-
396
377
# processes prompts
397
378
for i , (prompttype , seed , prompt , negative_prompt ) in enumerate (prompts_list ):
398
379
if self .ppp_debug_level != DEBUG_LEVEL .none :
@@ -407,17 +388,48 @@ def process(
407
388
408
389
# updates the prompts
409
390
if rpr is not None and rnr is not None :
391
+ rpr_changes = False
392
+ rnr_changes = False
393
+ rpr_copy = rpr .copy ()
394
+ rnr_copy = rnr .copy ()
410
395
for i , (seed , prompt , negative_prompt ) in enumerate (zip (calculated_seeds , rpr , rnr )):
411
396
found = self .lru_cache .get ((seed , hash (self .wildcards_obj ), prompt , negative_prompt ))
412
397
if found is not None :
398
+ if rpr [i ].strip () != found [0 ].strip ():
399
+ rpr_changes = True
400
+ if rnr [i ].strip () != found [1 ].strip ():
401
+ rnr_changes = True
413
402
rpr [i ] = found [0 ]
414
403
rnr [i ] = found [1 ]
404
+ if add_prompts :
405
+ if rpr_changes :
406
+ extra_params ["PPP original prompts" ] = rpr_copy
407
+ if rnr_changes :
408
+ extra_params ["PPP original negative prompts" ] = rnr_copy
415
409
if rph is not None and rnh is not None :
410
+ rph_changes = False
411
+ rnh_changes = False
412
+ rph_copy = rph .copy ()
413
+ rnh_copy = rnh .copy ()
416
414
for i , (seed , prompt , negative_prompt ) in enumerate (zip (calculated_seeds , rph , rnh )):
417
415
found = self .lru_cache .get ((seed , hash (self .wildcards_obj ), prompt , negative_prompt ))
418
416
if found is not None :
417
+ if rph [i ].strip () != found [0 ].strip ():
418
+ rph_changes = True
419
+ if rnh [i ].strip () != found [1 ].strip ():
420
+ rnh_changes = True
419
421
rph [i ] = found [0 ]
420
422
rnh [i ] = found [1 ]
423
+ if add_prompts :
424
+ if rph_changes :
425
+ extra_params ["PPP original HR prompts" ] = rph_copy
426
+ if rnh_changes :
427
+ extra_params ["PPP original HR negative prompts" ] = rnh_copy
428
+
429
+ # fill extra generation parameters only if not already present
430
+ for k , v in extra_params .items ():
431
+ if p .extra_generation_params .get (k ) is None :
432
+ p .extra_generation_params [k ] = v
421
433
422
434
t2 = time .time ()
423
435
if self .ppp_debug_level != DEBUG_LEVEL .none :
@@ -516,7 +528,7 @@ def new_html_title(title):
516
528
key = "ppp_gen_addpromptstometadata" ,
517
529
info = shared .OptionInfo (
518
530
True ,
519
- label = "Add original prompts to metadata" ,
531
+ label = "Add original prompts to metadata (if they change) " ,
520
532
section = section ,
521
533
),
522
534
)
0 commit comments