code: def load_checkpoint_from_dir(self, checkpoint_dir_or_url):
      # if checkpoint_dir is a url, download it and untar it
      if is_url(checkpoint_dir_or_url):
          checkpoint_dir_or_url = download_and_untar(
              checkpoint_dir_or_url
          )
  
      logging.info(
          f"Loading pretrained model from {checkpoint_dir_or_url}"
      )
  
      def load_state_dict(module, filename):
          try:
              state_dict = torch.load(
                  os.path.join(checkpoint_dir_or_url, filename),
                  map_location="cpu",
              )
              msg = module.load_state_dict(state_dict, strict=False)
          except FileNotFoundError:
              logging.info(
                  "File not found, skip loading: {}".format(filename)
              )
  
      load_state_dict(self.proj_layer, "proj_layer/proj_weight.pt")
      load_state_dict(self.blip, "blip_model/blip_weight.pt")
      load_state_dict(self.unet, "unet/diffusion_pytorch_model.bin")
      load_state_dict(self.vae, "vae/diffusion_pytorch_model.bin")
      load_state_dict(
          self.text_encoder, "text_encoder/pytorch_model.bin"
      )
  
      try:
          self.ctx_embeddings_cache.data = torch.load(
              os.path.join(
                  checkpoint_dir_or_url,
                  "ctx_embeddings_cache/ctx_embeddings_cache.pt",
              ),
              map_location=self.device,
          )
          self._use_embeddings_cache = True
          print(
              "Loaded ctx_embeddings_cache from {}".format(
                  checkpoint_dir_or_url
              )
          )
      except FileNotFoundError:
          self._use_embeddings_cache = False
          print(
              "No ctx_embeddings_cache found in {}".format(
                  checkpoint_dir_or_url
              )
          )
  
imports: import logging
  import os
  import torch
  import torch.nn.functional
  import tqdm
  from diffusers import AutoencoderKL, ControlNetModel, DDPMScheduler, DDIMScheduler, PNDMScheduler, UNet2DConditionModel
  from torch import nn
  from transformers import CLIPTokenizer
  from transformers.activations import QuickGELUActivation
  from lavis.common.registry import registry
  from lavis.common.utils import download_and_untar, is_url
  from lavis.models.base_model import BaseModel
  from lavis.models.blip2_models.blip2_qformer import Blip2Qformer
  from lavis.models.blip_diffusion_models.modeling_ctx_clip import CtxCLIPTextModel
  from lavis.models.blip_diffusion_models.utils import numpy_to_pil, prepare_cond_image
  from lavis.models.blip_diffusion_models.ptp_utils import LocalBlend, P2PCrossAttnProcessor, AttentionRefine
label_desc: Use image node_id 27 for calling the BlipDiffusion obj's underlying member method code with example usage: obj.load_checkpoint_from_dir(checkpoint_dir_or_url) without return types