code: def upscale(
      self,
      image,
      info,
      upscaler,
      upscale_mode,
      upscale_by,
      upscale_to_width,
      upscale_to_height,
      upscale_crop,
  ):
      if upscale_mode == 1:
          upscale_by = max(
              upscale_to_width / image.width,
              upscale_to_height / image.height,
          )
          info[
              "Postprocess upscale to"
          ] = f"{upscale_to_width}x{upscale_to_height}"
      else:
          info["Postprocess upscale by"] = upscale_by
  
      cache_key = (
          hash(np.array(image.getdata()).tobytes()),
          upscaler.name,
          upscale_mode,
          upscale_by,
          upscale_to_width,
          upscale_to_height,
          upscale_crop,
      )
      cached_image = upscale_cache.pop(cache_key, None)
  
      if cached_image is not None:
          image = cached_image
      else:
          image = upscaler.scaler.upscale(
              image, upscale_by, upscaler.data_path
          )
  
      upscale_cache[cache_key] = image
      if len(upscale_cache) > shared.opts.upscaling_max_images_in_cache:
          upscale_cache.pop(next(iter(upscale_cache), None), None)
  
      if upscale_mode == 1 and upscale_crop:
          cropped = Image.new(
              "RGB", (upscale_to_width, upscale_to_height)
          )
          cropped.paste(
              image,
              box=(
                  upscale_to_width // 2 - image.width // 2,
                  upscale_to_height // 2 - image.height // 2,
              ),
          )
          image = cropped
          info["Postprocess crop to"] = f"{image.width}x{image.height}"
  
      return image
  
file_path: stable-diffusion-webui/scripts/postprocessing_upscale.py
imports: from PIL import Image
  import numpy
  from modules import scripts_postprocessing, shared
  import gradio
  from modules.ui_components import FormRow, ToolButton
  from modules.ui import switch_values_symbol
label_desc: Use image node_id 2 for calling the ScriptPostprocessingUpscale obj's underlying member method code with example usage: obj.upscale(image, info, upscaler, upscale_mode, upscale_by, upscale_to_width, upscale_to_height, upscale_crop) and returns: image