Qihoo-T2X 1.0 使用指南

这里是 Qihoo-T2X 官方开源代码仓库

QIHOO-T2X: AN EFFICIENT PROXY-TOKENIZED DIFFUSION TRANSFORMER FOR TEXT-TO-ANY-TASK Jing Wang*, Ao Ma*†, Jiasong Feng*, Dawei Leng‡, Yuhui Yin, Xiaodan Liang‡(*Equal Contribution, †Project Lead, ‡Corresponding Authors)

目录

Prompt: Close-up of a man's face wearing glasses against a colorful background.

Prompt: A dog wearing virtual reality goggles in sunset, 4k, high resolution.


环境安装

1. 仓库拉取

    git clone --branch 26.0.0 https://gitcode.com/Ascend/MindSpeed-MM.git 
    git clone https://github.com/NVIDIA/Megatron-LM.git
    cd Megatron-LM
    git checkout core_r0.8.0
    cp -r megatron ../MindSpeed-MM/
    cd ..
    cd MindSpeed-MM
    mkdir pretrain_models

2. 环境搭建

请参考安装指南

    # python3.10
    conda create -n qihoot2x python=3.10
    conda activate qihoot2x

    # 安装 torch 和 torch_npu,注意要选择对应python版本、x86或arm的torch、torch_npu及apex包
    pip install torch-2.7.1-cp310-cp310-manylinux_2_28_aarch64.whl
    pip install torch_npu-2.7.1*-cp310-cp310-manylinux_2_28_aarch64.whl
    
    # apex for Ascend 参考 https://gitcode.com/Ascend/apex
    # 建议从原仓编译安装

    # 安装加速库
    git clone https://gitcode.com/Ascend/MindSpeed.git
    cd MindSpeed
    git checkout 3f09d6736571cf1e30f8ac97de77982d0ab32cc5
    pip install -r requirements.txt 
    pip3 install -e .
    cd ..

    # 安装其余依赖库
    pip install -e .

3. 权重下载

从Hugging Face库下载对应的模型权重:

将下载的模型权重保存到本地的pretrain_models/qihoo_t2i/XXX.pt目录下。(XXX表示对应的名字)

将下载的模型权重保存到本地的pretrain_models/opensoraplan_vae1_2/目录下。

  • 文本编码器模型地址: T5-XXL (fp16); 将下载的模型权重保存到本地的pretrain_models/text_encoder目录下。

  • tokenizer地址; 将下载的模型权重保存到本地的pretrain_models/tokenizer目录下。

推理

1. 配置参数

  • 将准备好的权重传入到examples/qihoo_t2x/inference_model_image.json中,更改其中的路径,包括from_pretrained。

  • 自定义的prompt可以在examples/qihoo_t2x/demo.txt中修改和添加。

2. 启动推理

i2v 启动推理脚本

sh examples/qihoo_t2x/inference_qihoo.sh

环境变量声明

ASCEND_RT_VISIBLE_DEVICES: 指定NPU设备的索引值
NPUS_PER_NODE: 配置一个计算节点上使用的NPU数量

文献引用

@article{wang2024qihoo,
  title={Qihoo-T2X: An Efficient Proxy-Tokenized Diffusion Transformer for Text-to-Any-Task},
  author={Wang, Jing and Ma, Ao and Feng, Jiasong and Leng, Dawei and Yin, Yuhui and Liang, Xiaodan},
  journal={arXiv preprint arXiv:2409.04005},
  year={2024}
}

许可证

本项目许可遵从以下协议 Apache License (Version 2.0).