examples/research_projects/vqgan-clip/loaders.py/load_vqgan
def load_vqgan(device, conf_path=None, ckpt_path=None):
    if conf_path is None:
        conf_path = "./model_checkpoints/vqgan_only.yaml"
    config = load_config(conf_path, display=False)
    model = VQModel(**config.model.params)
    if ckpt_path is None:
        ckpt_path = "./model_checkpoints/vqgan_only.pt"
    sd = torch.load(ckpt_path, map_location=device)
    if ".ckpt" in ckpt_path:
        sd = sd["state_dict"]
    model.load_state_dict(sd, strict=True)
    model.to(device)
    del sd
    return model