hpcaitech / Open-Sora

Open-Sora: Democratizing Efficient Video Production for All
https://hpcaitech.github.io/Open-Sora/
Apache License 2.0
20.23k stars 1.91k forks source link

Cannot load VAE from the hpcai-tech/OpenSora-VAE-v1.2 #479

Closed langmanbusi closed 2 weeks ago

langmanbusi commented 2 weeks ago

I modify the config and run with the following error. OSError: PixArt-alpha/pixart_sigma_sdxlvae_T5_diffusers does not appear to have a file named config.json.

In the code,

def OpenSoraVAE_V1_2(
    micro_batch_size=4,
    micro_frame_size=17,
    from_pretrained=None,
    local_files_only=False,
    freeze_vae_2d=False,
    cal_loss=False,
):
    vae_2d = dict(
        type="VideoAutoencoderKL",
        from_pretrained="PixArt-alpha/pixart_sigma_sdxlvae_T5_diffusers",
        subfolder="vae",
        micro_batch_size=micro_batch_size,
        local_files_only=local_files_only,
    )
    vae_temporal = dict(
        type="VAE_Temporal_SD",
        from_pretrained=None,
    )
    shift = (-0.10, 0.34, 0.27, 0.98)
    scale = (3.85, 2.32, 2.33, 3.06)
    kwargs = dict(
        vae_2d=vae_2d,
        vae_temporal=vae_temporal,
        freeze_vae_2d=freeze_vae_2d,
        cal_loss=cal_loss,
        micro_frame_size=micro_frame_size,
        shift=shift,
        scale=scale,
    )

    if from_pretrained is not None and not os.path.isdir(from_pretrained):
        model = VideoAutoencoderPipeline.from_pretrained(from_pretrained, **kwargs)
    else:
        config = VideoAutoencoderPipelineConfig(**kwargs)
        model = VideoAutoencoderPipeline(config)

        if from_pretrained:
            load_checkpoint(model, from_pretrained)
    return model

The from_pretrained path of vae_2d and vae_temporal are given, and the path of vae_temporal is None. How can I load the whole VAE from the checkpoint download from hpcai-tech/OpenSora-VAE-v1.2 ?

Thank you!

zhengzangw commented 2 weeks ago

After testing, in our case, we find this problem only happens when you can no access to huggingface.com (e.g., mainland China). A quick fix is:

export HF_ENDPOINT=https://hf-mirror.com

Then you can successfully download from huggingface.

zhengzangw commented 2 weeks ago

Moved to #525