| 23 | return [loops, final_denoising_strength, denoising_curve, append_interrogation] |
| 24 | |
| 25 | def run(self, p, loops, final_denoising_strength, denoising_curve, append_interrogation): |
| 26 | processing.fix_seed(p) |
| 27 | batch_count = p.n_iter |
| 28 | p.extra_generation_params = { |
| 29 | "Final denoising strength": final_denoising_strength, |
| 30 | "Denoising curve": denoising_curve |
| 31 | } |
| 32 | |
| 33 | p.batch_size = 1 |
| 34 | p.n_iter = 1 |
| 35 | |
| 36 | info = None |
| 37 | initial_seed = None |
| 38 | initial_info = None |
| 39 | initial_denoising_strength = p.denoising_strength |
| 40 | |
| 41 | grids = [] |
| 42 | all_images = [] |
| 43 | original_init_image = p.init_images |
| 44 | original_prompt = p.prompt |
| 45 | original_inpainting_fill = p.inpainting_fill |
| 46 | state.job_count = loops * batch_count |
| 47 | |
| 48 | initial_color_corrections = [processing.setup_color_correction(p.init_images[0])] |
| 49 | |
| 50 | def calculate_denoising_strength(loop): |
| 51 | strength = initial_denoising_strength |
| 52 | |
| 53 | if loops == 1: |
| 54 | return strength |
| 55 | |
| 56 | progress = loop / (loops - 1) |
| 57 | if denoising_curve == "Aggressive": |
| 58 | strength = math.sin((progress) * math.pi * 0.5) |
| 59 | elif denoising_curve == "Lazy": |
| 60 | strength = 1 - math.cos((progress) * math.pi * 0.5) |
| 61 | else: |
| 62 | strength = progress |
| 63 | |
| 64 | change = (final_denoising_strength - initial_denoising_strength) * strength |
| 65 | return initial_denoising_strength + change |
| 66 | |
| 67 | history = [] |
| 68 | |
| 69 | for n in range(batch_count): |
| 70 | # Reset to original init image at the start of each batch |
| 71 | p.init_images = original_init_image |
| 72 | |
| 73 | # Reset to original denoising strength |
| 74 | p.denoising_strength = initial_denoising_strength |
| 75 | |
| 76 | last_image = None |
| 77 | |
| 78 | for i in range(loops): |
| 79 | p.n_iter = 1 |
| 80 | p.batch_size = 1 |
| 81 | p.do_not_save_grid = True |
| 82 | |