code: def test_canny(self):
      controlnet = ControlNetModel.from_pretrained(
          "lllyasviel/sd-controlnet-canny"
      )
  
      pipe = StableDiffusionControlNetImg2ImgPipeline.from_pretrained(
          "runwayml/stable-diffusion-v1-5",
          safety_checker=None,
          controlnet=controlnet,
      )
      pipe.enable_model_cpu_offload()
      pipe.set_progress_bar_config(disable=None)
  
      generator = torch.Generator(device="cpu").manual_seed(0)
      prompt = "evil space-punk bird"
      control_image = load_image(
          "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd_controlnet/bird_canny.png"
      ).resize((512, 512))
      image = load_image(
          "https://huggingface.co/lllyasviel/sd-controlnet-canny/resolve/main/images/bird.png"
      ).resize((512, 512))
  
      output = pipe(
          prompt,
          image,
          control_image=control_image,
          generator=generator,
          output_type="np",
          num_inference_steps=50,
          strength=0.6,
      )
  
      image = output.images[0]
  
      assert image.shape == (512, 512, 3)
  
      expected_image = load_numpy(
          "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd_controlnet/img2img.npy"
      )
  
      assert np.abs(expected_image - image).max() < 9e-2
  
imports: import gc
  import random
  import tempfile
  import unittest
  import numpy
  import torch
  from PIL import Image
  from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer
  from diffusers import AutoencoderKL, ControlNetModel, DDIMScheduler, StableDiffusionControlNetImg2ImgPipeline, UNet2DConditionModel
  from diffusers.pipelines.controlnet.pipeline_controlnet import MultiControlNetModel
  from diffusers.utils import load_image
  from diffusers.utils.import_utils import is_xformers_available
  from diffusers.utils.testing_utils import enable_full_determinism, floats_tensor, load_numpy, require_torch_gpu, slow, torch_device
  from diffusers.utils.torch_utils import randn_tensor
  from ..pipeline_params import IMAGE_TO_IMAGE_IMAGE_PARAMS, TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS, TEXT_GUIDED_IMAGE_VARIATION_PARAMS
  from ..test_pipelines_common import PipelineKarrasSchedulerTesterMixin, PipelineLatentTesterMixin, PipelineTesterMixin
label_desc: Use image node_id 2 for calling the ControlNetImg2ImgPipelineSlowTests obj's underlying member method code with example usage: obj.test_canny() without return types