Views
No views yet
DiffSynth-Studio Documentation: 中文版、English version
DiffSynth-Studio has undergone major version updates, and some old features are no longer maintained. If you need to use old features, please switch to the last historical version before the major version update.
Currently, the development personnel of this project are limited, with most of the work handled by Artiprocher. Therefore, the progress of new feature development will be relatively slow, and the speed of responding to and resolving issues is limited. We apologize for this and ask developers to understand.
1024 x 1024 images. It includes general, English text rendering, and Chinese text rendering subsets. We provide annotations for image descriptions, entities, and structural control images for each image. Developers can use this dataset to train Qwen-Image models' ControlNet and EliGen models. We aim to promote technological development through open-sourcing!./examples/ControlNet/.examples/ExVideo.git clone https://github.com/modelscope/DiffSynth-Studio.git
cd DiffSynth-Studio
pip install -e .pip install diffsynthBefore running model inference or training, you can configure settings such as the model download source via environment variables.By default, this project downloads models from ModelScope. For users outside China, you can configure the system to download models from the ModelScope international site as follows:python1import os 2os.environ["MODELSCOPE_DOMAIN"] = "www.modelscope.ai"To download models from other sources, please modify the environment variable DIFFSYNTH_DOWNLOAD_SOURCE.
1from diffsynth.pipelines.z_image import ZImagePipeline, ModelConfig
2import torch
3
4vram_config = {
5 "offload_dtype": torch.bfloat16,
6 "offload_device": "cpu",
7 "onload_dtype": torch.bfloat16,
8 "onload_device": "cpu",
9 "preparing_dtype": torch.bfloat16,
10 "preparing_device": "cuda",
11 "computation_dtype": torch.bfloat16,
12 "computation_device": "cuda",
13}
14pipe = ZImagePipeline.from_pretrained(
15 torch_dtype=torch.bfloat16,
16 device="cuda",
17 model_configs=[
18 ModelConfig(model_id="Tongyi-MAI/Z-Image-Turbo", origin_file_pattern="transformer/*.safetensors", **vram_config),
19 ModelConfig(model_id="Tongyi-MAI/Z-Image-Turbo", origin_file_pattern="text_encoder/*.safetensors", **vram_config),
20 ModelConfig(model_id="Tongyi-MAI/Z-Image-Turbo", origin_file_pattern="vae/diffusion_pytorch_model.safetensors", **vram_config),
21 ],
22 tokenizer_config=ModelConfig(model_id="Tongyi-MAI/Z-Image-Turbo", origin_file_pattern="tokenizer/"),
23 vram_limit=torch.cuda.mem_get_info("cuda")[1] / (1024 ** 3) - 0.5,
24)
25prompt = "Young Chinese woman in red Hanfu, intricate embroidery. Impeccable makeup, red floral forehead pattern. Elaborate high bun, golden phoenix headdress, red flowers, beads. Holds round folding fan with lady, trees, bird. Neon lightning-bolt lamp (⚡️), bright yellow glow, above extended left palm. Soft-lit outdoor night background, silhouetted tiered pagoda (西安大雁塔), blurred colorful distant lights."
26image = pipe(prompt=prompt, seed=42, rand_device="cuda")
27image.save("image.jpg")1from diffsynth.pipelines.flux2_image import Flux2ImagePipeline, ModelConfig
2import torch
3
4vram_config = {
5 "offload_dtype": "disk",
6 "offload_device": "disk",
7 "onload_dtype": torch.float8_e4m3fn,
8 "onload_device": "cpu",
9 "preparing_dtype": torch.float8_e4m3fn,
10 "preparing_device": "cuda",
11 "computation_dtype": torch.bfloat16,
12 "computation_device": "cuda",
13}
14pipe = Flux2ImagePipeline.from_pretrained(
15 torch_dtype=torch.bfloat16,
16 device="cuda",
17 model_configs=[
18 ModelConfig(model_id="black-forest-labs/FLUX.2-dev", origin_file_pattern="text_encoder/*.safetensors", **vram_config),
19 ModelConfig(model_id="black-forest-labs/FLUX.2-dev", origin_file_pattern="transformer/*.safetensors", **vram_config),
20 ModelConfig(model_id="black-forest-labs/FLUX.2-dev", origin_file_pattern="vae/diffusion_pytorch_model.safetensors"),
21 ],
22 tokenizer_config=ModelConfig(model_id="black-forest-labs/FLUX.2-dev", origin_file_pattern="tokenizer/"),
23 vram_limit=torch.cuda.mem_get_info("cuda")[1] / (1024 ** 3) - 0.5,
24)
25prompt = "High resolution. A dreamy underwater portrait of a serene young woman in a flowing blue dress. Her hair floats softly around her face, strands delicately suspended in the water. Clear, shimmering light filters through, casting gentle highlights, while tiny bubbles rise around her. Her expression is calm, her features finely detailed—creating a tranquil, ethereal scene."
26image = pipe(prompt, seed=42, rand_device="cuda", num_inference_steps=50)
27image.save("image.jpg")| Model ID | Inference | Low-VRAM Inference | LoRA Training | LoRA Training Validation |
|---|---|---|---|---|
| black-forest-labs/FLUX.2-dev | code | code | code | code |
1from diffsynth.pipelines.qwen_image import QwenImagePipeline, ModelConfig
2import torch
3
4vram_config = {
5 "offload_dtype": "disk",
6 "offload_device": "disk",
7 "onload_dtype": torch.float8_e4m3fn,
8 "onload_device": "cpu",
9 "preparing_dtype": torch.float8_e4m3fn,
10 "preparing_device": "cuda",
11 "computation_dtype": torch.bfloat16,
12 "computation_device": "cuda",
13}
14pipe = QwenImagePipeline.from_pretrained(
15 torch_dtype=torch.bfloat16,
16 device="cuda",
17 model_configs=[
18 ModelConfig(model_id="Qwen/Qwen-Image", origin_file_pattern="transformer/diffusion_pytorch_model*.safetensors", **vram_config),
19 ModelConfig(model_id="Qwen/Qwen-Image", origin_file_pattern="text_encoder/model*.safetensors", **vram_config),
20 ModelConfig(model_id="Qwen/Qwen-Image", origin_file_pattern="vae/diffusion_pytorch_model.safetensors", **vram_config),
21 ],
22 tokenizer_config=ModelConfig(model_id="Qwen/Qwen-Image", origin_file_pattern="tokenizer/"),
23 vram_limit=torch.cuda.mem_get_info("cuda")[1] / (1024 ** 3) - 0.5,
24)
25prompt = "精致肖像,水下少女,蓝裙飘逸,发丝轻扬,光影透澈,气泡环绕,面容恬静,细节精致,梦幻唯美。"
26image = pipe(prompt, seed=0, num_inference_steps=40)
27image.save("image.jpg")1graph LR;
2 Qwen/Qwen-Image-->Qwen/Qwen-Image-Edit;
3 Qwen/Qwen-Image-Edit-->Qwen/Qwen-Image-Edit-2509;
4 Qwen/Qwen-Image-->EliGen-Series;
5 EliGen-Series-->DiffSynth-Studio/Qwen-Image-EliGen;
6 DiffSynth-Studio/Qwen-Image-EliGen-->DiffSynth-Studio/Qwen-Image-EliGen-V2;
7 EliGen-Series-->DiffSynth-Studio/Qwen-Image-EliGen-Poster;
8 Qwen/Qwen-Image-->Distill-Series;
9 Distill-Series-->DiffSynth-Studio/Qwen-Image-Distill-Full;
10 Distill-Series-->DiffSynth-Studio/Qwen-Image-Distill-LoRA;
11 Qwen/Qwen-Image-->ControlNet-Series;
12 ControlNet-Series-->Blockwise-ControlNet-Series;
13 Blockwise-ControlNet-Series-->DiffSynth-Studio/Qwen-Image-Blockwise-ControlNet-Canny;
14 Blockwise-ControlNet-Series-->DiffSynth-Studio/Qwen-Image-Blockwise-ControlNet-Depth;
15 Blockwise-ControlNet-Series-->DiffSynth-Studio/Qwen-Image-Blockwise-ControlNet-Inpaint;
16 ControlNet-Series-->DiffSynth-Studio/Qwen-Image-In-Context-Control-Union;
17 Qwen/Qwen-Image-->DiffSynth-Studio/Qwen-Image-Edit-Lowres-Fix;1import torch
2from diffsynth.pipelines.flux_image import FluxImagePipeline, ModelConfig
3
4vram_config = {
5 "offload_dtype": torch.float8_e4m3fn,
6 "offload_device": "cpu",
7 "onload_dtype": torch.float8_e4m3fn,
8 "onload_device": "cpu",
9 "preparing_dtype": torch.float8_e4m3fn,
10 "preparing_device": "cuda",
11 "computation_dtype": torch.bfloat16,
12 "computation_device": "cuda",
13}
14pipe = FluxImagePipeline.from_pretrained(
15 torch_dtype=torch.bfloat16,
16 device="cuda",
17 model_configs=[
18 ModelConfig(model_id="black-forest-labs/FLUX.1-dev", origin_file_pattern="flux1-dev.safetensors", **vram_config),
19 ModelConfig(model_id="black-forest-labs/FLUX.1-dev", origin_file_pattern="text_encoder/model.safetensors", **vram_config),
20 ModelConfig(model_id="black-forest-labs/FLUX.1-dev", origin_file_pattern="text_encoder_2/*.safetensors", **vram_config),
21 ModelConfig(model_id="black-forest-labs/FLUX.1-dev", origin_file_pattern="ae.safetensors", **vram_config),
22 ],
23 vram_limit=torch.cuda.mem_get_info("cuda")[1] / (1024 ** 3) - 1,
24)
25prompt = "CG, masterpiece, best quality, solo, long hair, wavy hair, silver hair, blue eyes, blue dress, medium breasts, dress, underwater, air bubble, floating hair, refraction, portrait. The girl's flowing silver hair shimmers with every color of the rainbow and cascades down, merging with the floating flora around her."
26image = pipe(prompt=prompt, seed=0)
27image.save("image.jpg")1graph LR;
2 FLUX.1-Series-->black-forest-labs/FLUX.1-dev;
3 FLUX.1-Series-->black-forest-labs/FLUX.1-Krea-dev;
4 FLUX.1-Series-->black-forest-labs/FLUX.1-Kontext-dev;
5 black-forest-labs/FLUX.1-dev-->FLUX.1-dev-ControlNet-Series;
6 FLUX.1-dev-ControlNet-Series-->alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Beta;
7 FLUX.1-dev-ControlNet-Series-->InstantX/FLUX.1-dev-Controlnet-Union-alpha;
8 FLUX.1-dev-ControlNet-Series-->jasperai/Flux.1-dev-Controlnet-Upscaler;
9 black-forest-labs/FLUX.1-dev-->InstantX/FLUX.1-dev-IP-Adapter;
10 black-forest-labs/FLUX.1-dev-->ByteDance/InfiniteYou;
11 black-forest-labs/FLUX.1-dev-->DiffSynth-Studio/Eligen;
12 black-forest-labs/FLUX.1-dev-->DiffSynth-Studio/LoRA-Encoder-FLUX.1-Dev;
13 black-forest-labs/FLUX.1-dev-->DiffSynth-Studio/LoRAFusion-preview-FLUX.1-dev;
14 black-forest-labs/FLUX.1-dev-->ostris/Flex.2-preview;
15 black-forest-labs/FLUX.1-dev-->stepfun-ai/Step1X-Edit;
16 Qwen/Qwen2.5-VL-7B-Instruct-->stepfun-ai/Step1X-Edit;
17 black-forest-labs/FLUX.1-dev-->DiffSynth-Studio/Nexus-GenV2;
18 Qwen/Qwen2.5-VL-7B-Instruct-->DiffSynth-Studio/Nexus-GenV2;1import torch
2from diffsynth.utils.data import save_video, VideoData
3from diffsynth.pipelines.wan_video import WanVideoPipeline, ModelConfig
4
5vram_config = {
6 "offload_dtype": "disk",
7 "offload_device": "disk",
8 "onload_dtype": torch.bfloat16,
9 "onload_device": "cpu",
10 "preparing_dtype": torch.bfloat16,
11 "preparing_device": "cuda",
12 "computation_dtype": torch.bfloat16,
13 "computation_device": "cuda",
14}
15pipe = WanVideoPipeline.from_pretrained(
16 torch_dtype=torch.bfloat16,
17 device="cuda",
18 model_configs=[
19 ModelConfig(model_id="Wan-AI/Wan2.1-T2V-1.3B", origin_file_pattern="diffusion_pytorch_model*.safetensors", **vram_config),
20 ModelConfig(model_id="Wan-AI/Wan2.1-T2V-1.3B", origin_file_pattern="models_t5_umt5-xxl-enc-bf16.pth", **vram_config),
21 ModelConfig(model_id="Wan-AI/Wan2.1-T2V-1.3B", origin_file_pattern="Wan2.1_VAE.pth", **vram_config),
22 ],
23 tokenizer_config=ModelConfig(model_id="Wan-AI/Wan2.1-T2V-1.3B", origin_file_pattern="google/umt5-xxl/"),
24 vram_limit=torch.cuda.mem_get_info("cuda")[1] / (1024 ** 3) - 2,
25)
26
27video = pipe(
28 prompt="纪实摄影风格画面,一只活泼的小狗在绿茵茵的草地上迅速奔跑。小狗毛色棕黄,两只耳朵立起,神情专注而欢快。阳光洒在它身上,使得毛发看上去格外柔软而闪亮。背景是一片开阔的草地,偶尔点缀着几朵野花,远处隐约可见蓝天和几片白云。透视感鲜明,捕捉小狗奔跑时的动感和四周草地的生机。中景侧面移动视角。",
29 negative_prompt="色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走",
30 seed=0, tiled=True,
31)
32save_video(video, "video.mp4", fps=15, quality=5)1graph LR;
2 Wan-Series-->Wan2.1-Series;
3 Wan-Series-->Wan2.2-Series;
4 Wan2.1-Series-->Wan-AI/Wan2.1-T2V-1.3B;
5 Wan2.1-Series-->Wan-AI/Wan2.1-T2V-14B;
6 Wan-AI/Wan2.1-T2V-14B-->Wan-AI/Wan2.1-I2V-14B-480P;
7 Wan-AI/Wan2.1-I2V-14B-480P-->Wan-AI/Wan2.1-I2V-14B-720P;
8 Wan-AI/Wan2.1-T2V-14B-->Wan-AI/Wan2.1-FLF2V-14B-720P;
9 Wan-AI/Wan2.1-T2V-1.3B-->iic/VACE-Wan2.1-1.3B-Preview;
10 iic/VACE-Wan2.1-1.3B-Preview-->Wan-AI/Wan2.1-VACE-1.3B;
11 Wan-AI/Wan2.1-T2V-14B-->Wan-AI/Wan2.1-VACE-14B;
12 Wan-AI/Wan2.1-T2V-1.3B-->Wan2.1-Fun-1.3B-Series;
13 Wan2.1-Fun-1.3B-Series-->PAI/Wan2.1-Fun-1.3B-InP;
14 Wan2.1-Fun-1.3B-Series-->PAI/Wan2.1-Fun-1.3B-Control;
15 Wan-AI/Wan2.1-T2V-14B-->Wan2.1-Fun-14B-Series;
16 Wan2.1-Fun-14B-Series-->PAI/Wan2.1-Fun-14B-InP;
17 Wan2.1-Fun-14B-Series-->PAI/Wan2.1-Fun-14B-Control;
18 Wan-AI/Wan2.1-T2V-1.3B-->Wan2.1-Fun-V1.1-1.3B-Series;
19 Wan2.1-Fun-V1.1-1.3B-Series-->PAI/Wan2.1-Fun-V1.1-1.3B-Control;
20 Wan2.1-Fun-V1.1-1.3B-Series-->PAI/Wan2.1-Fun-V1.1-1.3B-InP;
21 Wan2.1-Fun-V1.1-1.3B-Series-->PAI/Wan2.1-Fun-V1.1-1.3B-Control-Camera;
22 Wan-AI/Wan2.1-T2V-14B-->Wan2.1-Fun-V1.1-14B-Series;
23 Wan2.1-Fun-V1.1-14B-Series-->PAI/Wan2.1-Fun-V1.1-14B-Control;
24 Wan2.1-Fun-V1.1-14B-Series-->PAI/Wan2.1-Fun-V1.1-14B-InP;
25 Wan2.1-Fun-V1.1-14B-Series-->PAI/Wan2.1-Fun-V1.1-14B-Control-Camera;
26 Wan-AI/Wan2.1-T2V-1.3B-->DiffSynth-Studio/Wan2.1-1.3b-speedcontrol-v1;
27 Wan-AI/Wan2.1-T2V-14B-->krea/krea-realtime-video;
28 Wan-AI/Wan2.1-T2V-14B-->meituan-longcat/LongCat-Video;
29 Wan-AI/Wan2.1-I2V-14B-720P-->ByteDance/Video-As-Prompt-Wan2.1-14B;
30 Wan-AI/Wan2.1-T2V-14B-->Wan-AI/Wan2.2-Animate-14B;
31 Wan-AI/Wan2.1-T2V-14B-->Wan-AI/Wan2.2-S2V-14B;
32 Wan2.2-Series-->Wan-AI/Wan2.2-T2V-A14B;
33 Wan2.2-Series-->Wan-AI/Wan2.2-I2V-A14B;
34 Wan2.2-Series-->Wan-AI/Wan2.2-TI2V-5B;
35 Wan-AI/Wan2.2-T2V-A14B-->Wan2.2-Fun-Series;
36 Wan2.2-Fun-Series-->PAI/Wan2.2-VACE-Fun-A14B;
37 Wan2.2-Fun-Series-->PAI/Wan2.2-Fun-A14B-InP;
38 Wan2.2-Fun-Series-->PAI/Wan2.2-Fun-A14B-Control;
39 Wan2.2-Fun-Series-->PAI/Wan2.2-Fun-A14B-Control-Camera;| brightness scale = 0.1 | brightness scale = 0.3 | brightness scale = 0.5 | brightness scale = 0.7 | brightness scale = 0.9 |
|---|---|---|---|---|
![]() | ![]() | ![]() | ![]() | ![]() |

| FLUX.1-dev | FLUX.1-dev + ArtAug LoRA |
|---|---|
| Entity Control Region | Generated Image |
|---|---|