Open-Sora icon indicating copy to clipboard operation
Open-Sora copied to clipboard

指定T5路径

Open fenglincong opened this issue 1 year ago • 7 comments

T5模型是手动下载的,如何指定所在路径?

fenglincong avatar Mar 25 '24 13:03 fenglincong

可以看看这个回答issue209

Yanjia0 avatar Mar 26 '24 01:03 Yanjia0

https://github.com/hpcaitech/Open-Sora/blob/a37a189482a4cd1c7892aa06881e539cbf8078ce/configs/opensora/inference/16x256x256.py#L19-L23 改成

text_encoder = dict(
    type="t5",
    from_pretrained="path/to/your/model",
    model_max_length=120,
    local_cache=True,
)

注意,如果你的模型下载路径为/home/xxx/model/t5-v1_1-xxl, 在这里应该传入:from_pretrained="/home/xxx/model"

yusijin02 avatar Mar 27 '24 06:03 yusijin02

https://github.com/hpcaitech/Open-Sora/blob/a37a189482a4cd1c7892aa06881e539cbf8078ce/configs/opensora/inference/16x256x256.py#L19-L23

改成

text_encoder = dict(
    type="t5",
    from_pretrained="path/to/your/model",
    model_max_length=120,
    local_cache=True,
)

注意,如果你的模型下载路径为, 在这里应该传入:/home/xxx/model/t5-v1_1-xxl``from_pretrained="/home/xxx/model"

我遇到了同样的问题,但是我下载好以后路径变为 (base) david@ai-gpu:/data/huggingface/t5-v1_1-xxl/snapshots/c9c62f81d37$ ls config.json pytorch_model-00002-of-00002.bin special_tokens_map.json tokenizer_config.json pytorch_model-00001-of-00002.bin pytorch_model.bin.index.json spiece.model 模型文件上一级一定是t5-v1_1-xxl这种命名吗?

Get-David avatar Apr 01 '24 03:04 Get-David

https://github.com/hpcaitech/Open-Sora/blob/a37a189482a4cd1c7892aa06881e539cbf8078ce/configs/opensora/inference/16x256x256.py#L19-L23

改成

text_encoder = dict(
    type="t5",
    from_pretrained="path/to/your/model",
    model_max_length=120,
    local_cache=True,
)

注意,如果你的模型下载路径为, 在这里应该传入: /home/xxx/model/t5-v1_1-xxlfrom_pretrained="/home/xxx/model" ``

我遇到了同样的问题,但是我下载好以后路径变为 (base) david@ai-gpu:/data/huggingface/t5-v1_1-xxl/snapshots/c9c62f81d37$ ls config.json pytorch_model-00002-of-00002.bin special_tokens_map.json tokenizer_config.json pytorch_model-00001-of-00002.bin pytorch_model.bin.index.json spiece.model 模型文件上一级一定是t5-v1_1-xxl这种命名吗?

我觉得应该是的, 你可以手动将 /data/huggingface/t5-v1_1-xxl/snapshots/c9c62f81d37 移动到 /data/huggingface/t5-v1_1-xxl 目录下, 并删除 /data/huggingface/t5-v1_1-xxl/snapshots 目录, 或者将 /data/huggingface/t5-v1_1-xxl/snapshots/c9c62f81d37 目录重命名为 t5-v1_1-xxl.

总之, 代码中传入参数 from_pretrained 的目录下应当存在一个 t5-v1_1-xxl 子目录, 它会在 t5-v1_1-xxl 子目录中加载模型参数.

yusijin02 avatar Apr 01 '24 03:04 yusijin02

https://github.com/hpcaitech/Open-Sora/blob/a37a189482a4cd1c7892aa06881e539cbf8078ce/configs/opensora/inference/16x256x256.py#L19-L23

改成

text_encoder = dict(
    type="t5",
    from_pretrained="path/to/your/model",
    model_max_length=120,
    local_cache=True,
)

注意,如果你的模型下载路径为, 在这里应该传入: /home/xxx/model/t5-v1_1-xxlfrom_pretrained="/home/xxx/model" ``

我遇到了同样的问题,但是我下载好以后路径变为 (base) david@ai-gpu:/data/huggingface/t5-v1_1-xxl/snapshots/c9c62f81d37$ ls config.json pytorch_model-00002-of-00002.bin special_tokens_map.json tokenizer_config.json pytorch_model-00001-of-00002.bin pytorch_model.bin.index.json spiece.model 模型文件上一级一定是t5-v1_1-xxl这种命名吗?

我觉得应该是的, 你可以手动将 /data/huggingface/t5-v1_1-xxl/snapshots/c9c62f81d37 移动到 /data/huggingface/t5-v1_1-xxl 目录下, 并删除 /data/huggingface/t5-v1_1-xxl/snapshots 目录, 或者将 /data/huggingface/t5-v1_1-xxl/snapshots/c9c62f81d37 目录重命名为 t5-v1_1-xxl.

总之, 代码中传入参数 from_pretrained 的目录下应当存在一个 t5-v1_1-xxl 子目录, 它会在 t5-v1_1-xxl 子目录中加载模型参数.

这是我的模型文件路径 /home/xxx/Open-Sora/pre_training/t5-v1_1-xxl 例如 /home/xxx/Open-Sora/pre_training/t5-v1_1-xxl/pytorch_model-00001-of-00002.bin 配置文件是改成

text_encoder = dict(
    type="t5",
    from_pretrained="/home/xxx/Open-Sora/pre_training",
    model_max_length=120,
)

依旧提示我 OSError: Error no file named config.json found in directory /home/xxx/Open-Sora/pre_training. 我将路径改为/home/xxx/Open-Sora/pre_training/t5-v1_1-xxl提示我 AssertionError: assert from_pretrained in self.available_models

Get-David avatar Apr 01 '24 05:04 Get-David

https://github.com/hpcaitech/Open-Sora/blob/a37a189482a4cd1c7892aa06881e539cbf8078ce/configs/opensora/inference/16x256x256.py#L19-L23

改成

text_encoder = dict(
    type="t5",
    from_pretrained="path/to/your/model",
    model_max_length=120,
    local_cache=True,
)

注意,如果你的模型下载路径为, 在这里应该传入: /home/xxx/model/t5-v1_1-xxlfrom_pretrained="/home/xxx/model" ``

我遇到了同样的问题,但是我下载好以后路径变为 (base) david@ai-gpu:/data/huggingface/t5-v1_1-xxl/snapshots/c9c62f81d37$ ls config.json pytorch_model-00002-of-00002.bin special_tokens_map.json tokenizer_config.json pytorch_model-00001-of-00002.bin pytorch_model.bin.index.json spiece.model 模型文件上一级一定是t5-v1_1-xxl这种命名吗?

我觉得应该是的, 你可以手动将 /data/huggingface/t5-v1_1-xxl/snapshots/c9c62f81d37 移动到 /data/huggingface/t5-v1_1-xxl 目录下, 并删除 /data/huggingface/t5-v1_1-xxl/snapshots 目录, 或者将 /data/huggingface/t5-v1_1-xxl/snapshots/c9c62f81d37 目录重命名为 t5-v1_1-xxl. 总之, 代码中传入参数 from_pretrained 的目录下应当存在一个 t5-v1_1-xxl 子目录, 它会在 t5-v1_1-xxl 子目录中加载模型参数.

这是我的模型文件路径 /home/xxx/Open-Sora/pre_training/t5-v1_1-xxl 例如 /home/xxx/Open-Sora/pre_training/t5-v1_1-xxl/pytorch_model-00001-of-00002.bin 配置文件是改成

text_encoder = dict(
    type="t5",
    from_pretrained="/home/xxx/Open-Sora/pre_training",
    model_max_length=120,
)

依旧提示我 OSError: Error no file named config.json found in directory /home/xxx/Open-Sora/pre_training. 我将路径改为/home/xxx/Open-Sora/pre_training/t5-v1_1-xxl提示我 AssertionError: assert from_pretrained in self.available_models

我解决了这个问题,我注释了报错信息中的两个assert,并成功跑出了视频,这感觉很棒。谢谢你

Get-David avatar Apr 01 '24 09:04 Get-David

This issue is stale because it has been open for 7 days with no activity.

github-actions[bot] avatar Apr 20 '24 01:04 github-actions[bot]

This issue was closed because it has been inactive for 7 days since being marked as stale.

github-actions[bot] avatar Apr 27 '24 01:04 github-actions[bot]