diff-storyboard / README_zh.md
jiaxi2002's picture
Upload folder using huggingface_hub
feb33a0 verified

DiffSynth-Studio

modelscope%2FDiffSynth-Studio | Trendshift

PyPI license open issues GitHub pull-requests GitHub latest commit

Switch to English

简介

欢迎来到 Diffusion 模型的魔法世界!DiffSynth-Studio 是由魔搭社区团队开发和维护的开源 Diffusion 模型引擎。我们期望以框架建设孵化技术创新,凝聚开源社区的力量,探索生成式模型技术的边界!

DiffSynth 目前包括两个开源项目:

  • DiffSynth-Studio: 聚焦于激进的技术探索,面向学术界,提供更前沿的模型能力支持。
  • DiffSynth-Engine: 聚焦于稳定的模型部署,面向工业界,提供更高的计算性能与更稳定的功能。

DiffSynth-StudioDiffSynth-Engine 作为魔搭社区 AIGC 专区 的核心技术支撑,提供了强大的AI生成内容能力。欢迎体验我们精心打造的产品化功能,开启您的AI创作之旅!

安装

从源码安装(推荐):

git clone https://github.com/modelscope/DiffSynth-Studio.git
cd DiffSynth-Studio
pip install -e .
其他安装方式

从 pypi 安装(存在版本更新延迟,如需使用最新功能,请从源码安装)

pip install diffsynth

如果在安装过程中遇到问题,可能是由上游依赖包导致的,请参考这些包的文档:

基础框架

DiffSynth-Studio 为主流 Diffusion 模型(包括 FLUX、Wan 等)重新设计了推理和训练流水线,能够实现高效的显存管理、灵活的模型训练。

Qwen-Image 系列 (🔥新模型)

详细页面:./examples/qwen_image/

Image

快速开始
from diffsynth.pipelines.qwen_image import QwenImagePipeline, ModelConfig
from PIL import Image
import torch

pipe = QwenImagePipeline.from_pretrained(
    torch_dtype=torch.bfloat16,
    device="cuda",
    model_configs=[
        ModelConfig(model_id="Qwen/Qwen-Image", origin_file_pattern="transformer/diffusion_pytorch_model*.safetensors"),
        ModelConfig(model_id="Qwen/Qwen-Image", origin_file_pattern="text_encoder/model*.safetensors"),
        ModelConfig(model_id="Qwen/Qwen-Image", origin_file_pattern="vae/diffusion_pytorch_model.safetensors"),
    ],
    tokenizer_config=ModelConfig(model_id="Qwen/Qwen-Image", origin_file_pattern="tokenizer/"),
)
prompt = "精致肖像,水下少女,蓝裙飘逸,发丝轻扬,光影透澈,气泡环绕,面容恬静,细节精致,梦幻唯美。"
image = pipe(
    prompt, seed=0, num_inference_steps=40,
    # edit_image=Image.open("xxx.jpg").resize((1328, 1328)) # For Qwen-Image-Edit
)
image.save("image.jpg")
模型总览

FLUX 系列

详细页面:./examples/flux/

Image

快速开始
import torch
from diffsynth.pipelines.flux_image_new import FluxImagePipeline, ModelConfig

pipe = FluxImagePipeline.from_pretrained(
    torch_dtype=torch.bfloat16,
    device="cuda",
    model_configs=[
        ModelConfig(model_id="black-forest-labs/FLUX.1-dev", origin_file_pattern="flux1-dev.safetensors"),
        ModelConfig(model_id="black-forest-labs/FLUX.1-dev", origin_file_pattern="text_encoder/model.safetensors"),
        ModelConfig(model_id="black-forest-labs/FLUX.1-dev", origin_file_pattern="text_encoder_2/"),
        ModelConfig(model_id="black-forest-labs/FLUX.1-dev", origin_file_pattern="ae.safetensors"),
    ],
)

image = pipe(prompt="a cat", seed=0)
image.save("image.jpg")
模型总览
模型 ID 额外参数 推理 低显存推理 全量训练 全量训练后验证 LoRA 训练 LoRA 训练后验证
FLUX.1-dev code code code code code code
FLUX.1-Krea-dev code code code code code code
FLUX.1-Kontext-dev kontext_images code code code code code code
FLUX.1-dev-Controlnet-Inpainting-Beta controlnet_inputs code code code code code code
FLUX.1-dev-Controlnet-Union-alpha controlnet_inputs code code code code code code
FLUX.1-dev-Controlnet-Upscaler controlnet_inputs code code code code code code
FLUX.1-dev-IP-Adapter ipadapter_images, ipadapter_scale code code code code code code
FLUX.1-dev-InfiniteYou infinityou_id_image, infinityou_guidance, controlnet_inputs code code code code code code
FLUX.1-dev-EliGen eligen_entity_prompts, eligen_entity_masks, eligen_enable_on_negative, eligen_enable_inpaint code code - - code code
FLUX.1-dev-LoRA-Encoder lora_encoder_inputs, lora_encoder_scale code code code code - -
FLUX.1-dev-LoRA-Fusion-Preview code - - - - -
Step1X-Edit step1x_reference_image code code code code code code
FLEX.2-preview flex_inpaint_image, flex_inpaint_mask, flex_control_image, flex_control_strength, flex_control_stop code code code code code code
Nexus-Gen nexus_gen_reference_image code code code code code code

Wan 系列

详细页面:./examples/wanvideo/

https://github.com/user-attachments/assets/1d66ae74-3b02-40a9-acc3-ea95fc039314

快速开始
import torch
from diffsynth import save_video
from diffsynth.pipelines.wan_video_new import WanVideoPipeline, ModelConfig

pipe = WanVideoPipeline.from_pretrained(
    torch_dtype=torch.bfloat16,
    device="cuda",
    model_configs=[
        ModelConfig(model_id="Wan-AI/Wan2.1-T2V-1.3B", origin_file_pattern="diffusion_pytorch_model*.safetensors", offload_device="cpu"),
        ModelConfig(model_id="Wan-AI/Wan2.1-T2V-1.3B", origin_file_pattern="models_t5_umt5-xxl-enc-bf16.pth", offload_device="cpu"),
        ModelConfig(model_id="Wan-AI/Wan2.1-T2V-1.3B", origin_file_pattern="Wan2.1_VAE.pth", offload_device="cpu"),
    ],
)
pipe.enable_vram_management()

video = pipe(
    prompt="纪实摄影风格画面,一只活泼的小狗在绿茵茵的草地上迅速奔跑。小狗毛色棕黄,两只耳朵立起,神情专注而欢快。阳光洒在它身上,使得毛发看上去格外柔软而闪亮。背景是一片开阔的草地,偶尔点缀着几朵野花,远处隐约可见蓝天和几片白云。透视感鲜明,捕捉小狗奔跑时的动感和四周草地的生机。中景侧面移动视角。",
    negative_prompt="色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走",
    seed=0, tiled=True,
)
save_video(video, "video1.mp4", fps=15, quality=5)
模型总览
模型 ID 额外参数 推理 全量训练 全量训练后验证 LoRA 训练 LoRA 训练后验证
Wan-AI/Wan2.2-Animate-14B input_image, animate_pose_video, animate_face_video, animate_inpaint_video, animate_mask_video code code code code code
Wan-AI/Wan2.2-S2V-14B input_image, input_audio, audio_sample_rate, s2v_pose_video code code code code code
Wan-AI/Wan2.2-I2V-A14B input_image code code code code code
Wan-AI/Wan2.2-T2V-A14B code code code code code
Wan-AI/Wan2.2-TI2V-5B input_image code code code code code
Wan-AI/Wan2.2-VACE-Fun-A14B vace_control_video, vace_reference_image code code code code code
PAI/Wan2.2-Fun-A14B-InP input_image, end_image code code code code code
PAI/Wan2.2-Fun-A14B-Control control_video, reference_image code code code code code
PAI/Wan2.2-Fun-A14B-Control-Camera control_camera_video, input_image code code code code code
Wan-AI/Wan2.1-T2V-1.3B code code code code code
Wan-AI/Wan2.1-T2V-14B code code code code code
Wan-AI/Wan2.1-I2V-14B-480P input_image code code code code code
Wan-AI/Wan2.1-I2V-14B-720P input_image code code code code code
Wan-AI/Wan2.1-FLF2V-14B-720P input_image, end_image code code code code code
PAI/Wan2.1-Fun-1.3B-InP input_image, end_image code code code code code
PAI/Wan2.1-Fun-1.3B-Control control_video code code code code code
PAI/Wan2.1-Fun-14B-InP input_image, end_image code code code code code
PAI/Wan2.1-Fun-14B-Control control_video code code code code code
PAI/Wan2.1-Fun-V1.1-1.3B-Control control_video, reference_image code code code code code
PAI/Wan2.1-Fun-V1.1-14B-Control control_video, reference_image code code code code code
PAI/Wan2.1-Fun-V1.1-1.3B-InP input_image, end_image code code code code code
PAI/Wan2.1-Fun-V1.1-14B-InP input_image, end_image code code code code code
PAI/Wan2.1-Fun-V1.1-1.3B-Control-Camera control_camera_video, input_image code code code code code
PAI/Wan2.1-Fun-V1.1-14B-Control-Camera control_camera_video, input_image code code code code code
iic/VACE-Wan2.1-1.3B-Preview vace_control_video, vace_reference_image code code code code code
Wan-AI/Wan2.1-VACE-1.3B vace_control_video, vace_reference_image code code code code code
Wan-AI/Wan2.1-VACE-14B vace_control_video, vace_reference_image code code code code code
DiffSynth-Studio/Wan2.1-1.3b-speedcontrol-v1 motion_bucket_id code code code code code
krea/krea-realtime-video code code code code code
meituan-longcat/LongCat-Video longcat_video code code code code code
ByteDance/Video-As-Prompt-Wan2.1-14B vap_video, vap_prompt code code code code code

更多模型

图像生成模型

详细页面:./examples/image_synthesis/

FLUX Stable Diffusion 3
image_1024_cfg image_1024
Kolors Hunyuan-DiT
image_1024 image_1024
Stable Diffusion Stable Diffusion XL
1024 1024
视频生成模型

https://github.com/user-attachments/assets/48dd24bb-0cc6-40d2-88c3-10feed3267e9

https://github.com/user-attachments/assets/5954fdaa-a3cf-45a3-bd35-886e3cc4581b

https://github.com/user-attachments/assets/26b044c1-4a60-44a4-842f-627ff289d006

图像质量评估模型

我们集成了一系列图像质量评估模型,这些模型可以用于图像生成模型的评测、对齐训练等场景中。

详细页面:./examples/image_quality_metric/

创新成果

DiffSynth-Studio 不仅仅是一个工程化的模型框架,更是创新成果的孵化器。

Nexus-Gen: 统一架构的图像理解、生成、编辑

ArtAug: 图像生成模型的美学提升
FLUX.1-dev FLUX.1-dev + ArtAug LoRA
image_1_base image_1_enhance
EliGen: 精准的图像分区控制
实体控制区域 生成图像
eligen_example_2_mask_0 eligen_example_2_0
ExVideo: 视频生成模型的扩展训练

https://github.com/modelscope/DiffSynth-Studio/assets/35051019/d97f6aa9-8064-4b5b-9d49-ed6001bb9acc

Diffutoon: 高分辨率动漫风格视频渲染

https://github.com/Artiprocher/DiffSynth-Studio/assets/35051019/b54c05c5-d747-4709-be5e-b39af82404dd

DiffSynth: 本项目的初代版本

https://github.com/Artiprocher/DiffSynth-Studio/assets/35051019/59fb2f7b-8de0-4481-b79f-0c3a7361a1ea

更新历史

更多
  • 2025年6月15日 ModelScope 官方评测框架 EvalScope 现已支持文生图生成评测。请参考最佳实践指南进行尝试。

  • 2025年3月25日 我们的新开源项目 DiffSynth-Engine 现已开源!专注于稳定的模型部署,面向工业界,提供更好的工程支持、更高的计算性能和更稳定的功能。

  • 2025年3月31日 我们支持 InfiniteYou,一种用于 FLUX 的人脸特征保留方法。更多细节请参考 ./examples/InfiniteYou/

  • 2025年3月13日 我们支持 HunyuanVideo-I2V,即腾讯开源的 HunyuanVideo 的图像到视频生成版本。更多细节请参考 ./examples/HunyuanVideo/

  • 2025年2月25日 我们支持 Wan-Video,这是阿里巴巴开源的一系列最先进的视频合成模型。详见 ./examples/wanvideo/

  • 2025年2月17日 我们支持 StepVideo!先进的视频合成模型!详见 ./examples/stepvideo

  • 2024年12月31日 我们提出 EliGen,一种用于精确实体级别控制的文本到图像生成的新框架,并辅以修复融合管道,将其能力扩展到图像修复任务。EliGen 可以无缝集成现有的社区模型,如 IP-Adapter 和 In-Context LoRA,提升其通用性。更多详情,请见 ./examples/EntityControl

  • 2024年12月19日 我们为 HunyuanVideo 实现了高级显存管理,使得在 24GB 显存下可以生成分辨率为 129x720x1280 的视频,或在仅 6GB 显存下生成分辨率为 129x512x384 的视频。更多细节请参考 ./examples/HunyuanVideo/

  • 2024年12月18日 我们提出 ArtAug,一种通过合成-理解交互来改进文生图模型的方法。我们以 LoRA 格式为 FLUX.1-dev 训练了一个 ArtAug 增强模块。该模型将 Qwen2-VL-72B 的美学理解融入 FLUX.1-dev,从而提升了生成图像的质量。

  • 2024年10月25日 我们提供了广泛的 FLUX ControlNet 支持。该项目支持许多不同的 ControlNet 模型,并且可以自由组合,即使它们的结构不同。此外,ControlNet 模型兼容高分辨率优化和分区控制技术,能够实现非常强大的可控图像生成。详见 ./examples/ControlNet/

  • 2024年10月8日 我们发布了基于 CogVideoX-5B 和 ExVideo 的扩展 LoRA。您可以从 ModelScopeHuggingFace 下载此模型。

  • 2024年8月22日 本项目现已支持 CogVideoX-5B。详见 此处。我们为这个文生视频模型提供了几个有趣的功能,包括:

    • 文本到视频
    • 视频编辑
    • 自我超分
    • 视频插帧
  • 2024年8月22日 我们实现了一个有趣的画笔功能,支持所有文生图模型。现在,您可以在 AI 的辅助下使用画笔创作惊艳的图像了!

    • 在我们的 WebUI 中使用它。
  • 2024年8月21日 DiffSynth-Studio 现已支持 FLUX。

    • 启用 CFG 和高分辨率修复以提升视觉质量。详见 此处
    • LoRA、ControlNet 和其他附加模型将很快推出。
  • 2024年6月21日 我们提出 ExVideo,一种旨在增强视频生成模型能力的后训练微调技术。我们将 Stable Video Diffusion 进行了扩展,实现了长达 128 帧的长视频生成。

  • 2024年6月13日 DiffSynth Studio 已迁移至 ModelScope。开发团队也从“我”转变为“我们”。当然,我仍会参与后续的开发和维护工作。

  • 2024年1月29日 我们提出 Diffutoon,这是一个出色的卡通着色解决方案。

    • 项目页面
    • 源代码已在此项目中发布。
    • 技术报告(IJCAI 2024)已发布于 arXiv
  • 2023年12月8日 我们决定启动一个新项目,旨在释放扩散模型的潜力,尤其是在视频合成方面。该项目的开发工作正式开始。

  • 2023年11月15日 我们提出 FastBlend,一种强大的视频去闪烁算法。

  • 2023年10月1日 我们发布了该项目的早期版本,名为 FastSDXL。这是构建一个扩散引擎的初步尝试。

    • 源代码已发布于 GitHub
    • FastSDXL 包含一个可训练的 OLSS 调度器,以提高效率。
      • OLSS 的原始仓库位于 此处
      • 技术报告(CIKM 2023)已发布于 arXiv
      • 演示视频已发布于 Bilibili
      • 由于 OLSS 需要额外训练,我们未在本项目中实现它。
  • 2023年8月29日 我们提出 DiffSynth,一个视频合成框架。