由 Ostris 开发的终极扩散模型微调训练工具包。
系统要求:Python 3.10+, Nvidia GPU (建议至少 8GB VRAM), Python 虚拟环境, Git。
git clone https://github.com/ostris/ai-toolkit.git
cd ai-toolkit
git submodule update --init --recursive
python3 -m venv venv
source venv/bin/activate
# install torch first
pip3 install --no-cache-dir torch==2.6.0 torchvision==0.21.0 --index-url https://download.pytorch.org/whl/cu126
pip3 install -r requirements.txt
git clone https://github.com/ostris/ai-toolkit.git
cd ai-toolkit
git submodule update --init --recursive
python -m venv venv
.\\venv\\Scripts\\activate
pip install --no-cache-dir torch==2.6.0 torchvision==0.21.0 --index-url https://download.pytorch.org/whl/cu126
pip install -r requirements.txt
提供直观的网页操作界面,让您轻松启动、监控和管理AI模型训练任务,无需编写复杂指令。
cd ui
npm run build_and_start
启动后访问 http://localhost:8675 即可使用完整功能
设置环境变量 AI_TOOLKIT_AUTH
可增加密码保护,防止未授权访问。
提供更简易的Gradio图形界面,特别适合初学者快速上手模型训练、数据处理和LoRA发布。
# 安装 ai-toolkit 后
cd ai-toolkit
huggingface-cli login # 登录 HF
python flux_train_ui.py
支持最新的FLUX.1扩散模型训练,提供业界领先的图像生成质量。硬件要求:至少24GB VRAM的NVIDIA GPU。
config/examples/
),根据需求修改参数。python run.py config/your_config_name.yml
高级提示:调整学习率、训练步数和批次大小可显著影响训练结果,建议参考官方文档获取最佳实践。
高质量的训练数据是成功训练模型的关键,AI Toolkit支持多种数据格式:
AI Toolkit提供多种云端训练选项,适合没有高端GPU的用户或需要大规模训练的项目。
提供完整的RunPod模板和部署脚本,支持一键部署:
提供Modal平台的无服务器训练方案:
云端训练是大型模型和长时间训练的理想选择,详细配置请参考官方文档。
AI Toolkit提供精细的层级控制,可针对特定网络层进行优化训练:
network:
type: "lora"
# ... other params
network_kwargs:
only_if_contains: ["layer_name_suffix"]
# or
ignore_if_contains: ["layer_name_suffix"]
通过精确控制训练层,可以显著提高特定类型内容的生成质量,如人脸细节、材质或特定风格。
支持LoKr (Low-Rank Kronecker product)训练方法,提供更高效的参数利用率:
network:
type: "lokr"
lokr_full_rank: true
lokr_factor: 8
# ... other params
LoKr技术能在较小的参数量下实现更好的训练效果,特别适合复杂风格和细节丰富的概念。
支持混合精度训练,在保持模型质量的同时显著降低VRAM需求:
更多高级训练技术和优化方法请参考 高级训练文档。
需要更详细的使用指南或遇到问题?请访问 AI Toolkit GitHub 官方仓库 或加入 Discord 社区 获取帮助。