def get_checkpoint_type(sd_model_checkpoint: str) -> int:
    """Get the type of the stable diffusion model given the checkpoint name.

    Args:
        sd_model_checkpoint (str): the checkpoint name.

    Returns:
        An integer representing the model type (1 means SD1; 2 means SD2; 3 means SDXL).
    """
    ckpt_path = os.path.join(models_path, "Stable-diffusion", sd_model_checkpoint)
    timer = Timer()
    checkpoint_info = sd_models.CheckpointInfo(ckpt_path)
    state_dict = sd_models.get_checkpoint_state_dict(checkpoint_info, timer)
    for k in state_dict.keys():
        # SD web UI uses `hasattr(model, conditioner)` to check the SDXL model.
        if k.startswith("conditioner"):
            return 3
        # SD web UI uses `hasattr(model, model.cond_stage_model)` to check the SD2 model.
        if k.startswith("cond_stage_model.model"):
            return 2
    return 1
Get the type of the stable diffusion model given the checkpoint name.

    Args:
        sd_model_checkpoint (str): the checkpoint name.

    Returns:
        An integer representing the model type (1 means SD1; 2 means SD2; 3 means SDXL).
    
scripts/sdwebui.py