def setup(self) -> None:
        """Load the model into memory to make running multiple predictions efficient"""
        cache_dir = "model_cache"
        local_files_only = True  # set to True if the models are saved in cache_dir

        self.m1_model_path = "JingyeChen22/textdiffuser2_layout_planner"
        self.m1_tokenizer = AutoTokenizer.from_pretrained(
            self.m1_model_path,
            use_fast=False,
            cache_dir=cache_dir,
            local_files_only=local_files_only,
        )
        self.m1_model = AutoModelForCausalLM.from_pretrained(
            self.m1_model_path,
            torch_dtype=torch.float16,
            low_cpu_mem_usage=True,
            cache_dir=cache_dir,
            local_files_only=local_files_only,
        ).cuda()

        self.text_encoder = (
            CLIPTextModel.from_pretrained(
                "JingyeChen22/textdiffuser2-full-ft",
                subfolder="text_encoder",
                cache_dir=cache_dir,
                local_files_only=local_files_only,
            )
            .cuda()
            .half()
        )
        self.tokenizer = CLIPTokenizer.from_pretrained(
            "runwayml/stable-diffusion-v1-5",
            subfolder="tokenizer",
            cache_dir=cache_dir,
            local_files_only=local_files_only,
        )

        #### additional tokens are introduced, including coordinate tokens and character tokens
        print("***************")
        print(f"tokenizer size: {len(self.tokenizer)}")
        for i in range(520):
            self.tokenizer.add_tokens(["l" + str(i)])  # left
            self.tokenizer.add_tokens(["t" + str(i)])  # top
            self.tokenizer.add_tokens(["r" + str(i)])  # width
            self.tokenizer.add_tokens(["b" + str(i)])  # height
        for c in alphabet:
            self.tokenizer.add_tokens([f"[{c}]"])
        print(f"new tokenizer size: {len(self.tokenizer)}")
        print("***************")

        self.vae = (
            AutoencoderKL.from_pretrained(
                "runwayml/stable-diffusion-v1-5",
                subfolder="vae",
                cache_dir=cache_dir,
                local_files_only=local_files_only,
            )
            .half()
            .cuda()
        )
        self.unet = (
            UNet2DConditionModel.from_pretrained(
                "JingyeChen22/textdiffuser2-full-ft",
                subfolder="unet",
                cache_dir=cache_dir,
                local_files_only=local_files_only,
            )
            .half()
            .cuda()
        )
        self.text_encoder.resize_token_embeddings(len(self.tokenizer))
        self.scheduler = DDPMScheduler.from_pretrained(
            "runwayml/stable-diffusion-v1-5",
            subfolder="scheduler",
            cache_dir=cache_dir,
            local_files_only=local_files_only,
        )

        #### load lcm components
        self.pipe = DiffusionPipeline.from_pretrained(
            "lambdalabs/sd-pokemon-diffusers",
            unet=copy.deepcopy(self.unet),
            tokenizer=self.tokenizer,
            text_encoder=copy.deepcopy(self.text_encoder),
            torch_dtype=torch.float16,
            cache_dir=cache_dir,
            local_files_only=local_files_only,
        )
        self.pipe.scheduler = LCMScheduler.from_config(self.pipe.scheduler.config)
        self.pipe.load_lora_weights("latent-consistency/lcm-lora-sdv1-5")
        self.pipe.to(device="cuda")
Load the model into memory to make running multiple predictions efficient
textdiffuser-2/predict.py