code: def run(
      self,
      p,
      loops,
      final_denoising_strength,
      denoising_curve,
      append_interrogation,
  ):
      processing.fix_seed(p)
      batch_count = p.n_iter
      p.extra_generation_params = {
          "Final denoising strength": final_denoising_strength,
          "Denoising curve": denoising_curve,
      }
  
      p.batch_size = 1
      p.n_iter = 1
  
      info = None
      initial_seed = None
      initial_info = None
      initial_denoising_strength = p.denoising_strength
  
      grids = []
      all_images = []
      original_init_image = p.init_images
      original_prompt = p.prompt
      original_inpainting_fill = p.inpainting_fill
      state.job_count = loops * batch_count
  
      initial_color_corrections = [
          processing.setup_color_correction(p.init_images[0])
      ]
  
      def calculate_denoising_strength(loop):
          strength = initial_denoising_strength
  
          if loops == 1:
              return strength
  
          progress = loop / (loops - 1)
          if denoising_curve == "Aggressive":
              strength = math.sin((progress) * math.pi * 0.5)
          elif denoising_curve == "Lazy":
              strength = 1 - math.cos((progress) * math.pi * 0.5)
          else:
              strength = progress
  
          change = (
              final_denoising_strength - initial_denoising_strength
          ) * strength
          return initial_denoising_strength + change
  
      history = []
  
      for n in range(batch_count):
          # Reset to original init image at the start of each batch
          p.init_images = original_init_image
  
          # Reset to original denoising strength
          p.denoising_strength = initial_denoising_strength
  
          last_image = None
  
          for i in range(loops):
              p.n_iter = 1
              p.batch_size = 1
              p.do_not_save_grid = True
  
              if opts.img2img_color_correction:
                  p.color_corrections = initial_color_corrections
  
              if append_interrogation != "None":
                  p.prompt = (
                      f"{original_prompt}, " if original_prompt else ""
                  )
                  if append_interrogation == "CLIP":
                      p.prompt += shared.interrogator.interrogate(
                          p.init_images[0]
                      )
                  elif append_interrogation == "DeepBooru":
                      p.prompt += deepbooru.model.tag(p.init_images[0])
  
              state.job = f"Iteration {i + 1}/{loops}, batch {n + 1}/{batch_count}"
  
              processed = processing.process_images(p)
  
              # Generation cancelled.
              if state.interrupted:
                  break
  
              if initial_seed is None:
                  initial_seed = processed.seed
                  initial_info = processed.info
  
              p.seed = processed.seed + 1
              p.denoising_strength = calculate_denoising_strength(i + 1)
  
              if state.skipped:
                  break
  
              last_image = processed.images[0]
              p.init_images = [last_image]
              p.inpainting_fill = (
                  1  # Set "masked content" to "original" for next loop.
              )
  
              if batch_count == 1:
                  history.append(last_image)
                  all_images.append(last_image)
  
          if (
              batch_count > 1
              and not state.skipped
              and not state.interrupted
          ):
              history.append(last_image)
              all_images.append(last_image)
  
          p.inpainting_fill = original_inpainting_fill
  
          if state.interrupted:
              break
  
      if len(history) > 1:
          grid = images.image_grid(history, rows=1)
          if opts.grid_save:
              images.save_image(
                  grid,
                  p.outpath_grids,
                  "grid",
                  initial_seed,
                  p.prompt,
                  opts.grid_format,
                  info=info,
                  short_filename=not opts.grid_extended_filename,
                  grid=True,
                  p=p,
              )
  
          if opts.return_grid:
              grids.append(grid)
  
      all_images = grids + all_images
  
      processed = Processed(p, all_images, initial_seed, initial_info)
  
      return processed
  
file_path: stable-diffusion-webui/scripts/loopback.py
imports: import math
  import gradio
  import modules.scripts
  from modules import deepbooru, images, processing, shared
  from modules.processing import Processed
  from modules.shared import opts, state
label_desc: Use image node_id 4 for calling the Script obj's underlying member method code with example usage: obj.run(p, loops, final_denoising_strength, denoising_curve, append_interrogation) and returns: processed, unknown, strength