MCPcopy
hub / github.com/modelscope/DiffSynth-Studio

github.com/modelscope/DiffSynth-Studio @v1.1.9 sqlite

repository ↗ · DeepWiki ↗ · release v1.1.9 ↗
3,423 symbols 12,664 edges 467 files 189 documented · 6%
README

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")

模型总览

模型 ID 推理 低显存推理 全量训练 全量训练后验证 LoRA 训练 LoRA 训练后验证
Qwen/Qwen-Image code code code code code code
Qwen/Qwen-Image-Edit code code code code code code
Qwen/Qwen-Image-Edit-2509 code code code code code code
DiffSynth-Studio/Qwen-Image-EliGen-V2 code code - - code code
DiffSynth-Studio/Qwen-Image-EliGen-Poster code code - - code code
DiffSynth-Studio/Qwen-Image-Distill-Full code code code code code code
DiffSynth-Studio/Qwen-Image-Distill-LoRA code code - - code code
DiffSynth-Studio/Qwen-Image-EliGen code code - - code code
DiffSynth-Studio/Qwen-Image-Blockwise-ControlNet-Canny code code code code code code
DiffSynth-Studio/Qwen-Image-Blockwise-ControlNet-Depth code code code code code code
DiffSynth-Studio/Qwen-Image-Blockwise-ControlNet-Inpaint code code code code code code
DiffSynth-Studio/Qwen-Image-In-Context-Control-Union code code - - code code
DiffSynth-Studio/Qwen-Image-Edit-Lowres-Fix code code - - - -

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 [co

Core symbols most depended-on inside this repo

to
called by 357
diffsynth/utils/__init__.py
to
called by 332
diffsynth/models/model_manager.py
save
called by 291
diffsynth/extensions/ImageQualityMetric/trainer/models/clip_model.py
from_pretrained
called by 225
diffsynth/models/cog_dit.py
save_video
called by 133
diffsynth/data/video.py
enable_vram_management
called by 129
diffsynth/pipelines/wan_video.py
fetch_model
called by 116
diffsynth/models/model_manager.py
load_models_to_device
called by 105
diffsynth/pipelines/base.py

Shape

Method 2,336
Class 711
Function 356
Route 20

Languages

Python100%

Modules by API surface

diffsynth/pipelines/wan_video_new.py102 symbols
diffsynth/pipelines/flux_image_new.py90 symbols
diffsynth/models/stepvideo_vae.py85 symbols
diffsynth/models/wan_video_vae.py78 symbols
diffsynth/models/kolors_text_encoder.py77 symbols
diffsynth/models/hunyuan_video_dit.py70 symbols
diffsynth/models/wan_video_animate_adapter.py69 symbols
diffsynth/models/stepvideo_dit.py68 symbols
diffsynth/trainers/unified_dataset.py61 symbols
diffsynth/extensions/ImageQualityMetric/BLIP/med.py61 symbols
diffsynth/models/longcat_video_dit.py59 symbols
diffsynth/pipelines/qwen_image.py58 symbols

Dependencies from manifests, versioned

torch2.0.0 · 1×

For agents

$ claude mcp add DiffSynth-Studio \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact