DiffSynth-Engine:基于 diffusion models 的高性能推理引擎项目

可用于构建高效的扩散模型推理流水线,支持多种模型格式和 LoRA 模型,具备模型量化、资源管理优化,能在有限硬件上运行大模型,跨平台且性能高效。【此简介由AI生成】

Branch12Tags26
This repository is empty

DiffSynth-Engine

PyPI license open issues GitHub pull-requests GitHub latest commit

DiffSynth-Engine 是一款高性能引擎,专为构建高效的扩散模型推理流水线而设计。

核心特性:

  • 精心设计的实现方案:我们对扩散流水线中的关键组件(如采样器和调度器)进行了精心的重新实现,未引入对 k-diffusion、ldm 或 sgm 等库的外部依赖。

  • 广泛的模型支持:兼容主流格式(如 CivitAI)的基础模型和 LoRA 模型,满足多样化的使用场景。

  • 灵活的资源管理:全面支持多种模型量化方法(如 FP8、INT8)和卸载策略,能够在有限的 GPU 内存硬件预算下加载更大的扩散模型(如 Flux.1 Dev)。

  • 优化的性能表现:精心打造的推理流水线,可在各种硬件环境下实现快速生成。

  • 跨平台支持:可在 Windows、macOS(Apple Silicon)和 Linux 系统上运行,确保在不同操作系统下的流畅体验。

最新动态

  • v0.6.0 | 2025年9月9日Image 支持 Wan2.2-S2V,这是一款专为音频驱动电影级视频生成设计的视频生成模型
  • v0.5.0 | 2025年8月27日Image 支持 Qwen-Image-Edit,即 Qwen-Image 的图像编辑版本,可实现语义/外观视觉编辑以及精确的文本编辑
  • v0.4.1 | 2025年8月4日Image 支持 Qwen-Image,这是一款擅长复杂文本渲染和创作多种艺术风格图像的图像生成模型
  • v0.4.0 | 2025年8月1日
    • Image 支持 Wan2.2 视频生成模型
    • ⚠️[重大变更] 改进了 from_pretrained 方法的流水线初始化

快速开始

环境要求

  • Python 3.10 及以上版本
  • 具备 8.6+ 计算能力的 NVIDIA GPU(例如 RTX 50 系列、RTX 40 系列、RTX 30 系列。有关您的 GPU 的更多详细信息,请参见此处)或 Apple Silicon M 系列芯片。

安装

安装发布版本(来自 PyPI):

pip3 install diffsynth-engine

从源代码安装:

git clone https://github.com/modelscope/diffsynth-engine.git && cd diffsynth-engine
pip3 install -e .

使用方法

文本生成图像

from diffsynth_engine import fetch_model, FluxImagePipeline, FluxPipelineConfig

model_path = fetch_model("muse/flux-with-vae", path="flux1-dev-with-vae.safetensors")

config = FluxPipelineConfig.basic_config(model_path=model_path, device="cuda:0")
pipe = FluxImagePipeline.from_pretrained(config)
image = pipe(prompt="a cat")
image.save("image.png")

使用 LoRA 的文本转图像

from diffsynth_engine import fetch_model, FluxImagePipeline, FluxPipelineConfig

model_path = fetch_model("muse/flux-with-vae", path="flux1-dev-with-vae.safetensors")
lora_path = fetch_model("DonRat/MAJICFLUS_SuperChinesestyleheongsam", path="麦橘超国风旗袍.safetensors")

config = FluxPipelineConfig.basic_config(model_path=model_path, device="cuda:0")
pipe = FluxImagePipeline.from_pretrained(config)
pipe.load_lora(path=lora_path, scale=1.0)
image = pipe(prompt="a girl, qipao")
image.save("image.png")

如需了解更多详情,请参阅我们的教程(English中文)。

展示

联系方式

如有任何问题或反馈,请扫描下方二维码,或发送邮件至 muse@alibaba-inc.com

dingtalk

贡献指南

我们欢迎对 DiffSynth-Engine 进行贡献。从源代码安装后,建议开发人员使用以下命令安装此项目以设置开发环境。

pip install -e '.[dev]'
pre-commit install

TODO: 详情请参考 CONTRIBUTING.md

许可证

本项目采用 Apache License 2.0 许可证。详情请参见 LICENSE 文件。

引用

如果您使用了本代码库,或发现我们的工作对您有所帮助,请引用:

@misc{diffsynth-engine2025,
      title={DiffSynth-Engine: a high-performance diffusion inference engine},
      author={Zhipeng Di, Guoxuan Zhu, Zhongjie Duan, Zihao Chu, Yingda Chen, Weiyi Lu},
      year={2025},
      publisher = {GitHub},
      howpublished = {\url{https://github.com/modelscope/diffsynth-engine}},
}

Introduction

可用于构建高效的扩散模型推理流水线,支持多种模型格式和 LoRA 模型,具备模型量化、资源管理优化,能在有限硬件上运行大模型,跨平台且性能高效。【此简介由AI生成】

Customize your domain