EvolveDirector:阿里联合南洋理工推出文本到图像生成模型的高效训练技术

83 阅读5分钟

❤️ 如果你也关注 AI 的发展现状,且对 AI 应用开发非常感兴趣,我会每日跟你分享最新的 AI 资讯和开源应用,也会不定期分享自己的想法和开源实例,欢迎关注我哦!

🥦 微信公众号|搜一搜:蚝油菜花 🥦


🚀 快速阅读

创新框架:阿里巴巴和南洋理工大学联合推出的文本到图像生成模型训练技术。
高效训练:通过API交互和预训练VLMs动态优化数据集,减少数据量和训练成本。
性能提升:从多个高级模型中选择最佳样本,提升生成图像的质量和多样性。

正文(附运行示例)

EvolveDirector 是什么

公众号: 蚝油菜花 - EvolveDirector

EvolveDirector是由阿里巴巴和南洋理工大学联合推出的创新框架,旨在通过公开资源和高级模型的API接口训练一个高性能的文本到图像生成模型。该框架的核心在于通过与现有高级模型的API交互获取数据对,并利用预训练的大型视觉语言模型(VLMs)动态优化训练数据集,从而显著减少所需的数据量和训练成本。

EvolveDirector能够从多个高级模型中选择最佳样本进行学习,使最终训练出的模型在多个方面超越现有的高级模型。这种创新的方法不仅提高了模型的生成质量,还大大降低了训练成本和时间。

EvolveDirector 的主要功能

  • 文本到图像生成:将文本描述转换成高质量的图像。
  • API交互:基于与高级文本到图像模型的API交互,获取文本-图像数据对,训练基础模型。
  • 数据集优化:利用预训练的大型视觉语言模型(VLMs)动态优化训练数据集,基于智能选择、扩展、删除和变异操作。
  • 模型进化:指导基础模型的进化,模拟、超越高级模型的生成能力。
  • 多模型学习:从多个高级模型中选择最佳样本进行学习,提升生成图像的质量和多样性。
  • 在线训练:基于在线训练策略,让基础模型持续不间断地训练,同时动态更新训练数据集。

EvolveDirector 的技术原理

  • API数据获取:基于与高级模型的公共API交互,获取大量的文本-图像数据对。
  • VLM评估与指导:利用预训练的VLMs对生成的图像进行评估,选择与文本描述最匹配的图像,指导数据集的构建。
  • 动态数据集维护:在训练过程中,VLM持续评估基础模型的性能,根据评估结果动态更新训练数据集。
  • 智能选择:VLM选择与文本提示最匹配的图像,保留高质量数据,删除低质量或冗余数据。

如何运行 EvolveDirector

环境配置

  1. 首先克隆本仓库。
  2. 为EvolveDirector构建虚拟环境:
conda create -n evolvedirector python=3.9
conda activate evolvedirector
pip install --upgrade pip
pip install torch==2.1.1 torchvision==0.16.1 torchaudio==2.1.1 --index-url https://download.pytorch.org/whl/cu121
pip install -r requirements.txt
pip install -U transformers accelerate diffusers SentencePiece ftfy beautifulsoup4
  1. 为LLava构建虚拟环境:
git clone https://github.com/haotian-liu/LLaVA.git
cd LLaVA
conda create -n llava python=3.10 -y
conda activate llava
pip install --upgrade pip
pip install -e .

模型权重

  1. 下载Edgen模型权重、VAE和T5权重:huggingface.co/ruizhaocv/E…。在脚本"AdGenerator/base_img_gen.py"、"AdGenerator/extract_features.py"和训练配置中更改权重路径。
  2. 下载LLava权重:huggingface.co/liuhaotian/…。在脚本"VLM/vlm_script.py"中更改权重路径。下载clip:huggingface.co/openai/clip…,并将其放在与LLava权重相同的父文件夹下。
  3. 下载高级模型权重,例如Playground 1.5:huggingface.co/playgrounda…。在脚本"AdGenerator/advanced_gen_scripts/img_gen_playground.py"中更改权重路径。

使用示例

  1. 512px单尺度训练:
CUDA_VISIBLE_DEVICES=0 python Synchronizer/server.py --task_stamp dynamic_0000
CUDA_VISIBLE_DEVICES=0 python AdGenerator/base_img_gen.py --task_stamp dynamic_0000
CUDA_VISIBLE_DEVICES=1 python AdGenerator/advanced_img_gen.py --task_stamp dynamic_0000
CUDA_VISIBLE_DEVICES=1 python AdGenerator/advanced_gen_scripts/img_gen_playground.py --task_stamp dynamic_0000 --rank 0
CUDA_VISIBLE_DEVICES=2 python VLM/vlm_server.py --task_stamp dynamic_0000
CUDA_VISIBLE_DEVICES=2 python VLM/vlm_script.py --task_stamp dynamic_0000 --rank 0
CUDA_VISIBLE_DEVICES=3 python /mnt/data/ruizhao/code/EvolveDirector/AdGenerator/extract_features.py --task_stamp dynamic_0000
CUDA_VISIBLE_DEVICES=4 python Train/train.py configs/evolve_director_512.py --work-dir output/evolve_director_512 --task_stamp dynamic_0000
CUDA_VISIBLE_DEVICES=4,5,6,7 python -m torch.distributed.launch --nproc_per_node=4 Train/train.py configs/evolve_director_512.py --work-dir output/EvolveDirector_512 --task_stamp dynamic_0000
  1. 1024px多尺度训练:
CUDA_VISIBLE_DEVICES=2 python VLM/vlm_script.py --task_stamp dynamic_0000 --rank 0 --multi_scale
CUDA_VISIBLE_DEVICES=3 python /mnt/data/ruizhao/code/EvolveDirector/AdGenerator/extract_features.py --task_stamp dynamic_0000 --img_size 1024 --multi_scale
CUDA_VISIBLE_DEVICES=4 python Train/train.py configs/evolve_director_1024.py --work-dir output/evolve_director_1024 --task_stamp dynamic_0000
CUDA_VISIBLE_DEVICES=4,5,6,7 python -m torch.distributed.launch --nproc_per_node=4 Train/train.py configs/evolve_director_1024.py --work-dir output/evolve_director_1024 --task_stamp dynamic_0000
  1. 推理:
python Inference/inference.py --image_size=1024 \
    --t5_path "/path/to/Edgen" \
    --tokenizer_path "/path/to/Edgen/sd-vae-ft-ema" \
    --txt_file "Inference/text_prompts.txt" \
    --model_path "/path/to/Edgen/ckpt.pth" \
    --save_folder "output/test_model"

资源


❤️ 如果你也关注 AI 的发展现状,且对 AI 应用开发非常感兴趣,我会每日跟你分享最新的 AI 资讯和开源应用,也会不定期分享自己的想法和开源实例,欢迎关注我哦!

🥦 微信公众号|搜一搜:蚝油菜花 🥦