[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-tianweiy--DMD2":3,"tool-tianweiy--DMD2":62},[4,18,26,35,44,53],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":17},4358,"openclaw","openclaw\u002Fopenclaw","OpenClaw 是一款专为个人打造的本地化 AI 助手，旨在让你在自己的设备上拥有完全可控的智能伙伴。它打破了传统 AI 助手局限于特定网页或应用的束缚，能够直接接入你日常使用的各类通讯渠道，包括微信、WhatsApp、Telegram、Discord、iMessage 等数十种平台。无论你在哪个聊天软件中发送消息，OpenClaw 都能即时响应，甚至支持在 macOS、iOS 和 Android 设备上进行语音交互，并提供实时的画布渲染功能供你操控。\n\n这款工具主要解决了用户对数据隐私、响应速度以及“始终在线”体验的需求。通过将 AI 部署在本地，用户无需依赖云端服务即可享受快速、私密的智能辅助，真正实现了“你的数据，你做主”。其独特的技术亮点在于强大的网关架构，将控制平面与核心助手分离，确保跨平台通信的流畅性与扩展性。\n\nOpenClaw 非常适合希望构建个性化工作流的技术爱好者、开发者，以及注重隐私保护且不愿被单一生态绑定的普通用户。只要具备基础的终端操作能力（支持 macOS、Linux 及 Windows WSL2），即可通过简单的命令行引导完成部署。如果你渴望拥有一个懂你",349277,3,"2026-04-06T06:32:30",[13,14,15,16],"Agent","开发框架","图像","数据工具","ready",{"id":19,"name":20,"github_repo":21,"description_zh":22,"stars":23,"difficulty_score":10,"last_commit_at":24,"category_tags":25,"status":17},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,"2026-04-05T11:01:52",[14,15,13],{"id":27,"name":28,"github_repo":29,"description_zh":30,"stars":31,"difficulty_score":32,"last_commit_at":33,"category_tags":34,"status":17},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",108322,2,"2026-04-10T11:39:34",[14,15,13],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":32,"last_commit_at":41,"category_tags":42,"status":17},6121,"gemini-cli","google-gemini\u002Fgemini-cli","gemini-cli 是一款由谷歌推出的开源 AI 命令行工具，它将强大的 Gemini 大模型能力直接集成到用户的终端环境中。对于习惯在命令行工作的开发者而言，它提供了一条从输入提示词到获取模型响应的最短路径，无需切换窗口即可享受智能辅助。\n\n这款工具主要解决了开发过程中频繁上下文切换的痛点，让用户能在熟悉的终端界面内直接完成代码理解、生成、调试以及自动化运维任务。无论是查询大型代码库、根据草图生成应用，还是执行复杂的 Git 操作，gemini-cli 都能通过自然语言指令高效处理。\n\n它特别适合广大软件工程师、DevOps 人员及技术研究人员使用。其核心亮点包括支持高达 100 万 token 的超长上下文窗口，具备出色的逻辑推理能力；内置 Google 搜索、文件操作及 Shell 命令执行等实用工具；更独特的是，它支持 MCP（模型上下文协议），允许用户灵活扩展自定义集成，连接如图像生成等外部能力。此外，个人谷歌账号即可享受免费的额度支持，且项目基于 Apache 2.0 协议完全开源，是提升终端工作效率的理想助手。",100752,"2026-04-10T01:20:03",[43,13,15,14],"插件",{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":10,"last_commit_at":50,"category_tags":51,"status":17},4487,"LLMs-from-scratch","rasbt\u002FLLMs-from-scratch","LLMs-from-scratch 是一个基于 PyTorch 的开源教育项目，旨在引导用户从零开始一步步构建一个类似 ChatGPT 的大型语言模型（LLM）。它不仅是同名技术著作的官方代码库，更提供了一套完整的实践方案，涵盖模型开发、预训练及微调的全过程。\n\n该项目主要解决了大模型领域“黑盒化”的学习痛点。许多开发者虽能调用现成模型，却难以深入理解其内部架构与训练机制。通过亲手编写每一行核心代码，用户能够透彻掌握 Transformer 架构、注意力机制等关键原理，从而真正理解大模型是如何“思考”的。此外，项目还包含了加载大型预训练权重进行微调的代码，帮助用户将理论知识延伸至实际应用。\n\nLLMs-from-scratch 特别适合希望深入底层原理的 AI 开发者、研究人员以及计算机专业的学生。对于不满足于仅使用 API，而是渴望探究模型构建细节的技术人员而言，这是极佳的学习资源。其独特的技术亮点在于“循序渐进”的教学设计：将复杂的系统工程拆解为清晰的步骤，配合详细的图表与示例，让构建一个虽小但功能完备的大模型变得触手可及。无论你是想夯实理论基础，还是为未来研发更大规模的模型做准备",90106,"2026-04-06T11:19:32",[52,15,13,14],"语言模型",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":10,"last_commit_at":59,"category_tags":60,"status":17},4292,"Deep-Live-Cam","hacksider\u002FDeep-Live-Cam","Deep-Live-Cam 是一款专注于实时换脸与视频生成的开源工具，用户仅需一张静态照片，即可通过“一键操作”实现摄像头画面的即时变脸或制作深度伪造视频。它有效解决了传统换脸技术流程繁琐、对硬件配置要求极高以及难以实时预览的痛点，让高质量的数字内容创作变得触手可及。\n\n这款工具不仅适合开发者和技术研究人员探索算法边界，更因其极简的操作逻辑（仅需三步：选脸、选摄像头、启动），广泛适用于普通用户、内容创作者、设计师及直播主播。无论是为了动画角色定制、服装展示模特替换，还是制作趣味短视频和直播互动，Deep-Live-Cam 都能提供流畅的支持。\n\n其核心技术亮点在于强大的实时处理能力，支持口型遮罩（Mouth Mask）以保留使用者原始的嘴部动作，确保表情自然精准；同时具备“人脸映射”功能，可同时对画面中的多个主体应用不同面孔。此外，项目内置了严格的内容安全过滤机制，自动拦截涉及裸露、暴力等不当素材，并倡导用户在获得授权及明确标注的前提下合规使用，体现了技术发展与伦理责任的平衡。",88924,"2026-04-06T03:28:53",[14,15,13,61],"视频",{"id":63,"github_repo":64,"name":65,"description_en":66,"description_zh":67,"ai_summary_zh":68,"readme_en":69,"readme_zh":70,"quickstart_zh":71,"use_case_zh":72,"hero_image_url":73,"owner_login":74,"owner_name":75,"owner_avatar_url":76,"owner_bio":77,"owner_company":78,"owner_location":79,"owner_email":77,"owner_twitter":77,"owner_website":80,"owner_url":81,"languages":82,"stars":91,"forks":92,"last_commit_at":93,"license":94,"difficulty_score":10,"env_os":95,"env_gpu":96,"env_ram":97,"env_deps":98,"category_tags":111,"github_topics":77,"view_count":32,"oss_zip_url":77,"oss_zip_packed_at":77,"status":17,"created_at":112,"updated_at":113,"faqs":114,"releases":148},6596,"tianweiy\u002FDMD2","DMD2","(NeurIPS 2024 Oral 🔥) Improved Distribution Matching Distillation for Fast Image Synthesis","DMD2 是一款专为加速图像生成而设计的开源 AI 模型，荣获 NeurIPS 2024 口头报告奖。它核心致力于解决传统扩散模型推理速度慢、计算成本高的问题，能够将原本需要数十步甚至上百步的生成过程压缩至 1 到 4 步，在大幅降低推理耗时（高达 500 倍）的同时，依然保持甚至超越原模型的图像质量。\n\n针对前代技术依赖昂贵数据集构建及训练不稳定的痛点，DMD2 引入了多项创新改进：首先，它摒弃了耗时的回归损失计算，提出“双时间尺度更新规则”以确保训练稳定；其次，巧妙融合 GAN 损失函数，让模型能直接利用真实数据进行蒸馏，有效修正了教师模型的估计偏差；最后，通过模拟推理时的采样过程，解决了多步生成中的训练与推理输入不匹配难题。这使得 DMD2 在 ImageNet 和 COCO 等基准测试中刷新了单步生成的质量记录，并成功支持 SDXL 架构生成百万像素级的高清图像。\n\nDMD2 非常适合希望部署高效文生图应用的研究人员、开发者，以及需要快速迭代创意内容的设计师。无论是希望在本地低算力环境下运行大模型，还是寻求极致生成速度的专业用户，都能从中获益。目前项目已提供 Hugging F","DMD2 是一款专为加速图像生成而设计的开源 AI 模型，荣获 NeurIPS 2024 口头报告奖。它核心致力于解决传统扩散模型推理速度慢、计算成本高的问题，能够将原本需要数十步甚至上百步的生成过程压缩至 1 到 4 步，在大幅降低推理耗时（高达 500 倍）的同时，依然保持甚至超越原模型的图像质量。\n\n针对前代技术依赖昂贵数据集构建及训练不稳定的痛点，DMD2 引入了多项创新改进：首先，它摒弃了耗时的回归损失计算，提出“双时间尺度更新规则”以确保训练稳定；其次，巧妙融合 GAN 损失函数，让模型能直接利用真实数据进行蒸馏，有效修正了教师模型的估计偏差；最后，通过模拟推理时的采样过程，解决了多步生成中的训练与推理输入不匹配难题。这使得 DMD2 在 ImageNet 和 COCO 等基准测试中刷新了单步生成的质量记录，并成功支持 SDXL 架构生成百万像素级的高清图像。\n\nDMD2 非常适合希望部署高效文生图应用的研究人员、开发者，以及需要快速迭代创意内容的设计师。无论是希望在本地低算力环境下运行大模型，还是寻求极致生成速度的专业用户，都能从中获益。目前项目已提供 Hugging Face 模型库、ComfyUI 节点及 Colab 演示，便于各类用户快速上手体验。","# Improved Distribution Matching Distillation for Fast Image Synthesis [[Huggingface Repo](https:\u002F\u002Fhuggingface.co\u002Ftianweiy\u002FDMD2)][[ComfyUI](https:\u002F\u002Fgist.github.com\u002Fcomfyanonymous\u002Ffcce4ced378f74f4c46026b134faf27a)][[Colab](https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1iGk7IW2WosophOVYpdW_KZGIfYpATOm7?usp=sharing)]\n\nFew-step Text-to-Image Generation.\n\n![image\u002Fjpeg](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftianweiy_DMD2_readme_70929be5cd8c.jpg)\n\n> [**Improved Distribution Matching Distillation for Fast Image Synthesis**](https:\u002F\u002Ftianweiy.github.io\u002Fdmd2\u002F),            \n> Tianwei Yin, Michaël Gharbi, Taesung Park, Richard Zhang, Eli Shechtman, Frédo Durand, William T. Freeman        \n> *NeurIPS 2024 ([arXiv 2405.14867](https:\u002F\u002Farxiv.org\u002Fabs\u002F2405.14867))*  \n\n## Contact \n\nFeel free to contact us if you have any questions about the paper!\n\nTianwei Yin [tianweiy@mit.edu](mailto:tianweiy@mit.edu)\n\n## Abstract\n\nRecent approaches have shown promises distilling diffusion models into\nefficient one-step generators. Among them, Distribution Matching Distillation\n(DMD) produces one-step generators that match their teacher in distribution,\nwithout enforcing a one-to-one correspondence with the sampling trajectories of\ntheir teachers. However, to ensure stable training, DMD requires an additional\nregression loss computed using a large set of noise-image pairs generated by\nthe teacher with many steps of a deterministic sampler. This is costly for\nlarge-scale text-to-image synthesis and limits the student's quality, tying it\ntoo closely to the teacher's original sampling paths. We introduce DMD2, a set\nof techniques that lift this limitation and improve DMD training. First, we\neliminate the regression loss and the need for expensive dataset construction.\nWe show that the resulting instability is due to the fake critic not estimating\nthe distribution of generated samples accurately and propose a two time-scale\nupdate rule as a remedy. Second, we integrate a GAN loss into the distillation\nprocedure, discriminating between generated samples and real images. This lets\nus train the student model on real data, mitigating the imperfect real score\nestimation from the teacher model, and enhancing quality. Lastly, we modify the\ntraining procedure to enable multi-step sampling. We identify and address the\ntraining-inference input mismatch problem in this setting, by simulating\ninference-time generator samples during training time. Taken together, our\nimprovements set new benchmarks in one-step image generation, with FID scores\nof 1.28 on ImageNet-64x64 and 8.35 on zero-shot COCO 2014, surpassing the\noriginal teacher despite a 500X reduction in inference cost. Further, we show\nour approach can generate megapixel images by distilling SDXL, demonstrating\nexceptional visual quality among few-step methods.\n\n## Environment Setup\n\n```.bash\n# In conda env \nconda create -n dmd2 python=3.8 -y \nconda activate dmd2 \n\npip install --upgrade anyio\npip install -r requirements.txt\npython setup.py  develop\n```\n\n## Inference Example\n\n#### ImageNet \n\n```.bash\npython -m demo.imagenet_example  --checkpoint_path IMAGENET_CKPT_PATH \n```\n\n#### Text-to-Image \n\n```.bash\n# Note: on the demo page, click ``Use Tiny VAE for faster decoding'' to enable much faster speed and lower memory consumption using a Tiny VAE from [madebyollin](https:\u002F\u002Fhuggingface.co\u002Fmadebyollin\u002Ftaesdxl)\n\n# 4 step (much higher quality than 1 step)\npython -m demo.text_to_image_sdxl --checkpoint_path SDXL_CKPT_PATH --precision float16\n\n# 1 step \npython -m demo.text_to_image_sdxl --num_step 1 --checkpoint_path SDXL_CKPT_PATH --precision float16 --conditioning_timestep 399\n```\n\nWe can also use the standard diffuser pipeline:\n\n#### 4-step UNet generation \n\n```python\nimport torch\nfrom diffusers import DiffusionPipeline, UNet2DConditionModel, LCMScheduler\nfrom huggingface_hub import hf_hub_download\nfrom safetensors.torch import load_file\nbase_model_id = \"stabilityai\u002Fstable-diffusion-xl-base-1.0\"\nrepo_name = \"tianweiy\u002FDMD2\"\nckpt_name = \"dmd2_sdxl_4step_unet_fp16.bin\"\n\n# Load model.\nwith torch.device(\"meta\"):\n    unet = UNet2DConditionModel.from_config(base_model_id, subfolder=\"unet\").to(torch.float16)\nstate_dict_path = hf_hub_download(repo_name, ckpt_name)\nunet.load_state_dict(torch.load(state_dict_path), assign=True)\nunet.to(\"cuda\")\n\npipe = DiffusionPipeline.from_pretrained(base_model_id, unet=unet, torch_dtype=torch.float16, variant=\"fp16\").to(\"cuda\")\npipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)\nprompt=\"a photo of a cat\"\n\n# LCMScheduler's default timesteps are different from the one we used for training \nimage=pipe(prompt=prompt, num_inference_steps=4, guidance_scale=0, timesteps=[999, 749, 499, 249]).images[0]\n```\n\n#### 4-step LoRA generation \n\n```python\nimport torch\nfrom diffusers import DiffusionPipeline, UNet2DConditionModel, LCMScheduler\nfrom huggingface_hub import hf_hub_download\nfrom safetensors.torch import load_file\nbase_model_id = \"stabilityai\u002Fstable-diffusion-xl-base-1.0\"\nrepo_name = \"tianweiy\u002FDMD2\"\nckpt_name = \"dmd2_sdxl_4step_lora_fp16.safetensors\"\n# Load model.\npipe = DiffusionPipeline.from_pretrained(base_model_id, torch_dtype=torch.float16, variant=\"fp16\").to(\"cuda\")\npipe.load_lora_weights(hf_hub_download(repo_name, ckpt_name))\npipe.fuse_lora(lora_scale=1.0)  # we might want to make the scale smaller for community models\n\npipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)\nprompt=\"a photo of a cat\"\n\n# LCMScheduler's default timesteps are different from the one we used for training \nimage=pipe(prompt=prompt, num_inference_steps=4, guidance_scale=0, timesteps=[999, 749, 499, 249]).images[0]\n```\n\n#### 1-step UNet generation \n\n```python\nimport torch\nfrom diffusers import DiffusionPipeline, UNet2DConditionModel, LCMScheduler\nfrom huggingface_hub import hf_hub_download\nfrom safetensors.torch import load_file\nbase_model_id = \"stabilityai\u002Fstable-diffusion-xl-base-1.0\"\nrepo_name = \"tianweiy\u002FDMD2\"\nckpt_name = \"dmd2_sdxl_1step_unet_fp16.bin\"\n# Load model.\nunet = UNet2DConditionModel.from_config(base_model_id, subfolder=\"unet\").to(\"cuda\", torch.float16)\nunet.load_state_dict(torch.load(hf_hub_download(repo_name, ckpt_name), map_location=\"cuda\"))\npipe = DiffusionPipeline.from_pretrained(base_model_id, unet=unet, torch_dtype=torch.float16, variant=\"fp16\").to(\"cuda\")\npipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)\nprompt=\"a photo of a cat\"\nimage=pipe(prompt=prompt, num_inference_steps=1, guidance_scale=0, timesteps=[399]).images[0]\n```\n\n#### 4-step T2I Adapter \n\n```python \nfrom diffusers import StableDiffusionXLAdapterPipeline, T2IAdapter, AutoencoderKL, UNet2DConditionModel, LCMScheduler\nfrom diffusers.utils import load_image, make_image_grid\nfrom controlnet_aux.canny import CannyDetector\nfrom huggingface_hub import hf_hub_download\nimport torch\n\n# load adapter\nadapter = T2IAdapter.from_pretrained(\"TencentARC\u002Ft2i-adapter-canny-sdxl-1.0\", torch_dtype=torch.float16, varient=\"fp16\").to(\"cuda\")\n\nvae=AutoencoderKL.from_pretrained(\"madebyollin\u002Fsdxl-vae-fp16-fix\", torch_dtype=torch.float16)\n\nbase_model_id = \"stabilityai\u002Fstable-diffusion-xl-base-1.0\"\nrepo_name = \"tianweiy\u002FDMD2\"\nckpt_name = \"dmd2_sdxl_4step_unet_fp16.bin\"\n# Load model.\nunet = UNet2DConditionModel.from_config(base_model_id, subfolder=\"unet\").to(\"cuda\", torch.float16)\nunet.load_state_dict(torch.load(hf_hub_download(repo_name, ckpt_name), map_location=\"cuda\"))\n\npipe = StableDiffusionXLAdapterPipeline.from_pretrained(\n    base_model_id, unet=unet, vae=vae, adapter=adapter, torch_dtype=torch.float16, variant=\"fp16\", \n).to(\"cuda\")\npipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)\npipe.enable_xformers_memory_efficient_attention()\n\ncanny_detector = CannyDetector()\n\nurl = \"https:\u002F\u002Fhuggingface.co\u002FAdapter\u002Ft2iadapter\u002Fresolve\u002Fmain\u002Ffigs_SDXLV1.0\u002Forg_canny.jpg\"\nimage = load_image(url)\n\n# Detect the canny map in low resolution to avoid high-frequency details\nimage = canny_detector(image, detect_resolution=384, image_resolution=1024)#.resize((1024, 1024))\n\nprompt = \"Mystical fairy in real, magic, 4k picture, high quality\"\n\ngen_images = pipe(\n  prompt=prompt,\n  image=image,\n  num_inference_steps=4,\n  guidance_scale=0, \n  adapter_conditioning_scale=0.8, \n  adapter_conditioning_factor=0.5,\n  timesteps=[999, 749, 499, 249]\n).images[0]\ngen_images.save('out_canny.png')\n```\n\nPretrained models can be found in [ImageNet](experiments\u002Fimagenet\u002FREADME.md) and [SDXL](experiments\u002Fsdxl\u002FREADME.md). \n\n## Training and Evaluation \n\n### ImageNet-64x64 \n\nPlease refer to [ImageNet-64x64](experiments\u002Fimagenet\u002FREADME.md) for details.\n\n### SDXL\n\nPlease refer to [SDXL](experiments\u002Fsdxl\u002FREADME.md) for details.\n\n### SDv1.5 \n\nPlease refer to [SDv1.5](experiments\u002Fsdv1.5\u002FREADME.md) for details.\n\n## License\n\nImproved Distribution Matching Distillation is released under [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License](LICENSE.md).\n\n## Known Issues \n\n- [ ] Current FSDP for SDXL training is really slow; help is greatly appreciated!\n- [ ] Current LORA training is actually slower than the full finetuning and takes the same amount of memory; help is greatly appreciated!\n\n\n## Citation \n\nIf you find DMD2 useful or relevant to your research, please kindly cite our papers:\n\n```bib\n@inproceedings{yin2024improved,\n    title={Improved Distribution Matching Distillation for Fast Image Synthesis},\n    author={Yin, Tianwei and Gharbi, Micha{\\\"e}l and Park, Taesung and Zhang, Richard and Shechtman, Eli and Durand, Fredo and Freeman, William T},\n    booktitle={NeurIPS},\n    year={2024}\n}\n\n@inproceedings{yin2024onestep,\n    title={One-step Diffusion with Distribution Matching Distillation},\n    author={Yin, Tianwei and Gharbi, Micha{\\\"e}l and Zhang, Richard and Shechtman, Eli and Durand, Fr{\\'e}do and Freeman, William T and Park, Taesung},\n    booktitle={CVPR},\n    year={2024}\n}\n```\n\n## Third-part Code\n\n[EDM](https:\u002F\u002Fgithub.com\u002FNVlabs\u002Fedm\u002Ftree\u002Fmain) for [dnnlib](dnnlib), [torch_utils](torch_utils) and [edm](third_party\u002Fedm) folders.\n\n## Acknowledgments \n\nThis work was done while Tianwei Yin was a full-time student at MIT. It was developed based on our reimplementation of the original DMD paper. This work was supported by the National Science Foundation under Cooperative Agreement PHY-2019786 (The NSF AI Institute for Artificial Intelligence and Fundamental Interactions, http:\u002F\u002Fiaifi.org\u002F), by NSF Grant 2105819, by NSF CISE award 1955864, and by funding from Google, GIST, Amazon, and Quanta Computer.\n\n","# 改进的分布匹配蒸馏用于快速图像生成 [[Huggingface 仓库](https:\u002F\u002Fhuggingface.co\u002Ftianweiy\u002FDMD2)][[ComfyUI](https:\u002F\u002Fgist.github.com\u002Fcomfyanonymous\u002Ffcce4ced378f74f4c46026b134faf27a)][[Colab](https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1iGk7IW2WosophOVYpdW_KZGIfYpATOm7?usp=sharing)]\n\n少步数文本到图像生成。\n\n![image\u002Fjpeg](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftianweiy_DMD2_readme_70929be5cd8c.jpg)\n\n> [**改进的分布匹配蒸馏用于快速图像生成**](https:\u002F\u002Ftianweiy.github.io\u002Fdmd2\u002F)，            \n> 田伟音、米夏埃尔·加尔比、泰松·朴、理查德·张、伊莱·谢赫特曼、弗雷多·杜兰、威廉·T·弗里曼        \n> *NeurIPS 2024 ([arXiv 2405.14867](https:\u002F\u002Farxiv.org\u002Fabs\u002F2405.14867))*  \n\n## 联系方式 \n\n如果您对论文有任何疑问，请随时与我们联系！\n\n田伟音 [tianweiy@mit.edu](mailto:tianweiy@mit.edu)\n\n## 摘要\n\n最近的一些方法通过将扩散模型蒸馏为高效的单步生成器展现了潜力。其中，分布匹配蒸馏（DMD）能够生成在分布上与其教师模型一致的单步生成器，而无需强制与教师模型的采样轨迹一一对应。然而，为了确保训练的稳定性，DMD需要额外使用由教师模型借助确定性采样器经过多步生成的一大批噪声-图像对来计算回归损失。这对于大规模的文本到图像合成来说成本高昂，并且限制了学生模型的质量，使其过于依赖教师模型的原始采样路径。我们提出了 DMD2，这是一套可以克服这一局限并改进 DMD 训练的技术。首先，我们消除了回归损失以及构建昂贵数据集的需求。我们证明了由此产生的不稳定性是由于虚假判别器未能准确估计生成样本的分布所致，并提出了一种双时间尺度更新规则作为解决方案。其次，我们将在蒸馏过程中引入 GAN 损失，用以区分生成样本和真实图像。这使得我们能够在真实数据上训练学生模型，从而缓解教师模型对真实分数估计不准确的问题，并提升生成质量。最后，我们修改了训练流程以支持多步采样。我们识别并解决了在这种情况下训练与推理输入不匹配的问题，即在训练时模拟推理阶段的生成器样本。综合来看，我们的改进在单步图像生成领域树立了新的标杆，在 ImageNet-64x64 数据集上的 FID 得分为 1.28，在零样本 COCO 2014 数据集上的 FID 得分为 8.35，尽管推理成本降低了 500 倍，但仍超越了原始教师模型。此外，我们还展示了通过蒸馏 SDXL 可以生成百万像素级别的图像，这在少步数方法中表现出卓越的视觉质量。\n\n## 环境搭建\n\n```.bash\n# 在 conda 环境中 \nconda create -n dmd2 python=3.8 -y \nconda activate dmd2 \n\npip install --upgrade anyio\npip install -r requirements.txt\npython setup.py  develop\n```\n\n## 推理示例\n\n#### ImageNet \n\n```.bash\npython -m demo.imagenet_example  --checkpoint_path IMAGENET_CKPT_PATH \n```\n\n#### 文本到图像 \n\n```.bash\n# 注意：在演示页面上，点击 ``使用 Tiny VAE 进行更快解码'' 以启用使用来自 [madebyollin](https:\u002F\u002Fhuggingface.co\u002Fmadebyollin\u002Ftaesdxl) 的 Tiny VAE，从而实现更快的速度和更低的内存消耗。\n\n# 4 步（质量远高于 1 步）\npython -m demo.text_to_image_sdxl --checkpoint_path SDXL_CKPT_PATH --precision float16\n\n# 1 步 \npython -m demo.text_to_image_sdxl --num_step 1 --checkpoint_path SDXL_CKPT_PATH --precision float16 --conditioning_timestep 399\n```\n\n我们也可以使用标准的 diffuser 流水线：\n\n#### 4 步 UNet 生成 \n\n```python\nimport torch\nfrom diffusers import DiffusionPipeline, UNet2DConditionModel, LCMScheduler\nfrom huggingface_hub import hf_hub_download\nfrom safetensors.torch import load_file\nbase_model_id = \"stabilityai\u002Fstable-diffusion-xl-base-1.0\"\nrepo_name = \"tianweiy\u002FDMD2\"\nckpt_name = \"dmd2_sdxl_4step_unet_fp16.bin\"\n\n# 加载模型。\nwith torch.device(\"meta\"):\n    unet = UNet2DConditionModel.from_config(base_model_id, subfolder=\"unet\").to(torch.float16)\nstate_dict_path = hf_hub_download(repo_name, ckpt_name)\nunet.load_state_dict(torch.load(state_dict_path), assign=True)\nunet.to(\"cuda\")\n\npipe = DiffusionPipeline.from_pretrained(base_model_id, unet=unet, torch_dtype=torch.float16, variant=\"fp16\").to(\"cuda\")\npipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)\nprompt=\"a photo of a cat\"\n\n# LCMScheduler 的默认时间步长与我们在训练时使用的不同 \nimage=pipe(prompt=prompt，num_inference_steps=4，guidance_scale=0，timesteps=[999，749，499，249]).images[0]\n```\n\n#### 4 步 LoRA 生成 \n\n```python\nimport torch\nfrom diffusers import DiffusionPipeline，UNet2DConditionModel，LCMScheduler\nfrom huggingface_hub import hf_hub_download\nfrom safetensors.torch import load_file\nbase_model_id = \"stabilityai\u002Fstable-diffusion-xl-base-1.0\"\nrepo_name = \"tianweiy\u002FDMD2\"\nckpt_name = \"dmd2_sdxl_4step_lora_fp16.safetensors\"\n# 加载模型。\npipe = DiffusionPipeline.from_pretrained(base_model_id，torch_dtype=torch.float16，variant=\"fp16\").to(\"cuda\")\npipe.load_lora_weights(hf_hub_download(repo_name，ckpt_name))\npipe.fuse_lora(lora_scale=1.0)  # 对于社区模型，我们可能希望将比例调小\n\npipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)\nprompt=\"a photo of a cat\"\n\n# LCMScheduler 的默认时间步长与我们在训练时使用的不同 \nimage=pipe(prompt=prompt，num_inference_steps=4，guidance_scale=0，timesteps=[999，749，499，249]).images[0]\n```\n\n#### 1 步 UNet 生成 \n\n```python\nimport torch\nfrom diffusers import DiffusionPipeline，UNet2DConditionModel，LCMScheduler\nfrom huggingface hub 有下载，从安全传感器中加载文件，基础型号是“稳定AI稳定的扩散XL基底1.0”，仓库名称是“天伟义DMD2”，检查名是“dmd2_sdxl_1step_unet_fp16.bin”。# 加载模型。\nunet = UNet2DConditionModel from config base model id，subfolder “unet” to “cuda”，torch float16。Unet load state dict from hf hub download repo name，ckpt name，map location “cuda”。Pipe = Diffusion Pipeline from pre-trained base model id，unet = unet，torch dtype = torch float16，variant “fp16”。To “cuda”。Pipe scheduler = LCMScheduler from config pipe scheduler’s config。Prompt = “a photo of a cat”。Image = pipe prompt = prompt，num inference steps = 1，guidance scale = 0，timesteps = [399]。Images[0]。\n```\n\n#### 4 步 T2I Adapter \n\n```python \nfrom diffusers import StableDiffusionXLAdapterPipeline，T2IAdapter，AutoencoderKL，UNet2DConditionModel，LCMScheduler\nfrom diffusers.utils import load image，make image grid\nfrom controlnet_aux.canny import CannyDetector\nfrom huggingface hub 有下载，import torch\n\n# 加载适配器\nadapter = T2IAdapter.from_pretrained(\"TencentARC\u002Ft2i-adapter-canny-sdxl-1.0\", torch_dtype=torch.float16, varient=\"fp16\").to(\"cuda\")\n\nvae=AutoencoderKL.from_pretrained(\"madebyollin\u002Fsdxl-vae-fp16-fix\", torch_dtype=torch.float16)\n\nbase_model_id = \"stabilityai\u002Fstable-diffusion-xl-base-1.0\"\nrepo_name = \"tianweiy\u002FDMD2\"\nckpt_name = \"dmd2_sdxl_4step_unet_fp16.bin\"\n# 加载模型。\nunet = UNet2DConditionModel.from_config(base_model_id, subfolder=\"unet\").to(\"cuda\", torch.float16)\nunet.load_state_dict(torch.load(hf_hub_download(repo_name, ckpt_name), map_location=\"cuda\"))\n\npipe = StableDiffusionXLAdapterPipeline.from_pretrained(\n    base_model_id, unet=unet, vae=vae, adapter=adapter, torch_dtype=torch.float16, variant=\"fp16\", \n).to(\"cuda\")\npipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)\npipe.enable_xformers_memory_efficient_attention()\n\ncanny_detector = CannyDetector()\n\nurl = \"https:\u002F\u002Fhuggingface.co\u002FAdapter\u002Ft2iadapter\u002Fresolve\u002Fmain\u002Ffigs_SDXLV1.0\u002Forg_canny.jpg\"\nimage = load_image(url)\n\n# 检测低分辨率的Canny边缘图，以避免高频细节\nimage = canny_detector(image, detect_resolution=384, image_resolution=1024)#.resize((1024, 1024))\n\nprompt = \"神秘的仙女，真实、魔法风格，4k高清画质\"\n\ngen_images = pipe(\n  prompt=prompt,\n  image=image,\n  num_inference_steps=4,\n  guidance_scale=0, \n  adapter_conditioning_scale=0.8, \n  adapter_conditioning_factor=0.5,\n  timesteps=[999, 749, 499, 249]\n).images[0]\ngen_images.save('out_canny.png')\n```\n\n预训练模型可以在 [ImageNet](experiments\u002Fimagenet\u002FREADME.md) 和 [SDXL](experiments\u002Fsdxl\u002FREADME.md) 中找到。\n\n## 训练与评估\n\n### ImageNet-64x64\n\n详情请参阅 [ImageNet-64x64](experiments\u002Fimagenet\u002FREADME.md)。\n\n### SDXL\n\n详情请参阅 [SDXL](experiments\u002Fsdxl\u002FREADME.md)。\n\n### SDv1.5\n\n详情请参阅 [SDv1.5](experiments\u002Fsdv1.5\u002FREADME.md)。\n\n## 许可证\n\n改进型分布匹配蒸馏技术根据 [知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议](LICENSE.md) 发布。\n\n## 已知问题\n\n- [ ] 目前用于 SDXL 训练的 FSDP 效率非常低；非常欢迎帮助！\n- [ ] 目前的 LORA 训练实际上比全量微调还要慢，并且占用的内存相同；同样非常欢迎帮助！\n\n## 引用\n\n如果您认为 DMD2 对您的研究有用或相关，请引用我们的论文：\n\n```bib\n@inproceedings{yin2024improved,\n    title={用于快速图像合成的改进型分布匹配蒸馏},\n    author={Yin, Tianwei and Gharbi, Micha{\\\"e}l and Park, Taesung and Zhang, Richard and Shechtman, Eli and Durand, Fredo and Freeman, William T},\n    booktitle={NeurIPS},\n    year={2024}\n}\n\n@inproceedings{yin2024onestep,\n    title={基于分布匹配蒸馏的一步扩散模型},\n    author={Yin, Tianwei and Gharbi, Micha{\\\"e}l and Zhang, Richard and Shechtman, Eli and Durand, Fr{\\'e}do and Freeman, William T and Park, Taesung},\n    booktitle={CVPR},\n    year={2024}\n}\n```\n\n## 第三方代码\n\n[EDM](https:\u002F\u002Fgithub.com\u002FNVlabs\u002Fedm\u002Ftree\u002Fmain) 位于 [dnnlib](dnnlib)、[torch_utils](torch_utils) 和 [edm](third_party\u002Fedm) 文件夹中。\n\n## 致谢\n\n本工作是在 Yin Tianwei 全职就读于麻省理工学院期间完成的。它基于我们对原始 DMD 论文的重新实现而开发。本研究得到了美国国家科学基金会的合作协议 PHY-2019786（NSF 人工智能与基本相互作用研究所，http:\u002F\u002Fiaifi.org\u002F）、NSF 资助项目 2105819、NSF CISE 奖项 1955864，以及来自 Google、GIST、亚马逊和广达电脑的资金支持。","# DMD2 快速上手指南\n\nDMD2 (Improved Distribution Matching Distillation) 是一个用于快速图像生成的开源工具，能够将扩散模型蒸馏为高效的单步或少数几步生成器。它在保持高质量的同时，将推理成本降低了 500 倍，支持 ImageNet 和 SDXL 等模型。\n\n## 环境准备\n\n*   **操作系统**: Linux (推荐) 或 macOS\n*   **Python 版本**: 3.8\n*   **GPU**: 支持 CUDA 的 NVIDIA 显卡（运行 SDXL 建议显存 16GB+）\n*   **前置依赖**: Conda 包管理器\n\n## 安装步骤\n\n1.  **创建并激活 Conda 环境**\n    ```bash\n    conda create -n dmd2 python=3.8 -y \n    conda activate dmd2 \n    ```\n\n2.  **安装依赖库**\n    为了获得更快的下载速度，建议配置 pip 使用国内镜像源（如清华源）。\n    ```bash\n    # 升级 anyio\n    pip install --upgrade anyio -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n\n    # 安装项目依赖\n    pip install -r requirements.txt -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n\n    # 以开发模式安装当前包\n    python setup.py develop\n    ```\n\n## 基本使用\n\n以下示例展示如何使用预训练模型进行文生图（Text-to-Image）推理。请确保已下载相应的检查点文件（Checkpoint），或代码会自动从 Hugging Face 拉取。\n\n### 1. 命令行快速推理 (SDXL)\n\n**4 步生成（推荐，质量更高）：**\n```bash\npython -m demo.text_to_image_sdxl --checkpoint_path SDXL_CKPT_PATH --precision float16\n```\n\n**1 步生成（极速）：**\n```bash\npython -m demo.text_to_image_sdxl --num_step 1 --checkpoint_path SDXL_CKPT_PATH --precision float16 --conditioning_timestep 399\n```\n> **提示**: 在演示页面中，可点击 \"Use Tiny VAE for faster decoding\" 以启用更小的 VAE 模型，从而显著提升解码速度并降低显存占用。\n\n### 2. Python 代码调用 (Diffusers Pipeline)\n\n如果你希望在代码中集成 DMD2，可以使用标准的 `diffusers` 管道。以下是加载 4 步 UNet 模型的示例：\n\n```python\nimport torch\nfrom diffusers import DiffusionPipeline, UNet2DConditionModel, LCMScheduler\nfrom huggingface_hub import hf_hub_download\n\nbase_model_id = \"stabilityai\u002Fstable-diffusion-xl-base-1.0\"\nrepo_name = \"tianweiy\u002FDMD2\"\nckpt_name = \"dmd2_sdxl_4step_unet_fp16.bin\"\n\n# 加载模型配置\nwith torch.device(\"meta\"):\n    unet = UNet2DConditionModel.from_config(base_model_id, subfolder=\"unet\").to(torch.float16)\n\n# 下载并加载权重\nstate_dict_path = hf_hub_download(repo_name, ckpt_name)\nunet.load_state_dict(torch.load(state_dict_path), assign=True)\nunet.to(\"cuda\")\n\n# 构建管道\npipe = DiffusionPipeline.from_pretrained(base_model_id, unet=unet, torch_dtype=torch.float16, variant=\"fp16\").to(\"cuda\")\npipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)\n\nprompt = \"a photo of a cat\"\n\n# 执行推理\n# 注意：LCMScheduler 的默认时间步与训练时不同，需手动指定 timesteps\nimage = pipe(\n    prompt=prompt, \n    num_inference_steps=4, \n    guidance_scale=0, \n    timesteps=[999, 749, 499, 249]\n).images[0]\n\nimage.save(\"output.png\")\n```\n\n### 3. 进阶功能：LoRA 与 ControlNet\n\nDMD2 同样支持 LoRA 微调模式和 T2I Adapter (如 Canny 边缘检测)。\n\n*   **LoRA 生成**: 使用 `pipe.load_lora_weights()` 加载 `.safetensors` 格式的 LoRA 权重，并调用 `pipe.fuse_lora()`。\n*   **ControlNet\u002FAdapter**: 结合 `StableDiffusionXLAdapterPipeline` 和 `T2IAdapter`，可在 4 步内完成条件图像生成（参考 README 中的 \"4-step T2I Adapter\" 代码段）。\n\n更多预训练模型详情及训练脚本，请访问项目的 [Hugging Face Repo](https:\u002F\u002Fhuggingface.co\u002Ftianweiy\u002FDMD2) 或查看 `experiments` 目录下的文档。","某电商平台的营销团队需要在“双 11\"大促期间，根据实时热点快速生成成千上万张高清商品推广图，并集成到自动化的广告素材系统中。\n\n### 没有 DMD2 时\n- **生成速度严重滞后**：传统扩散模型（如原生 SDXL）生成一张高清图需数十步迭代，耗时数秒，无法支撑高并发下的实时素材需求。\n- **硬件成本高昂**：为了缩短等待时间，必须部署大量昂贵的 GPU 集群进行并行计算，导致运营成本急剧上升。\n- **加速方案画质受损**：现有的少步数加速方法往往依赖复杂的轨迹蒸馏或牺牲图像细节，导致生成的商品纹理模糊、光影不自然。\n- **训练数据构建困难**：若要自定义加速模型，需预先用教师模型生成海量噪声 - 图像对作为回归损失的数据集，过程繁琐且存储成本巨大。\n\n### 使用 DMD2 后\n- **推理速度提升 500 倍**：DMD2 将生成过程压缩至 1-4 步，单图生成时间从秒级降至毫秒级，轻松应对实时流量洪峰。\n- **大幅降低算力门槛**：极少的采样步数显著减少了 GPU 占用，使得在消费级显卡甚至边缘设备上部署高质量生成成为可能。\n- **一步生成媲美原图**：通过引入 GAN 损失和真实数据训练，DMD2 在仅用 1 步的情况下，其 FID 分数甚至超越了原始教师模型，商品细节锐利逼真。\n- **简化训练流程**：DMD2 消除了对昂贵回归损失数据集的依赖，无需预先生成海量中间数据，让团队能更快速地微调专属模型。\n\nDMD2 通过革命性的分布匹配蒸馏技术，在将图像生成速度提升两个数量级的同时，反而进一步提升了画质，真正实现了“既要速度又要质量”的工业级落地。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftianweiy_DMD2_70929be5.jpg","tianweiy","Tianwei Yin","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Ftianweiy_f89c9a28.jpg",null,"Reve AI","Palo Alto","https:\u002F\u002Ftianweiy.github.io\u002F","https:\u002F\u002Fgithub.com\u002Ftianweiy",[83,87],{"name":84,"color":85,"percentage":86},"Python","#3572A5",95.6,{"name":88,"color":89,"percentage":90},"Shell","#89e051",4.4,1292,70,"2026-04-08T10:41:16","NOASSERTION","Linux","必需 NVIDIA GPU (代码中明确使用 .to('cuda') 和 float16 精度)，显存建议 16GB+ (运行 SDXL 模型及训练时)，CUDA 版本未说明 (需匹配 PyTorch 版本)","未说明 (建议 32GB+ 以支持 SDXL 模型加载和训练)",{"notes":99,"python":100,"dependencies":101},"1. 必须使用 Conda 创建 Python 3.8 环境。2. 推理示例默认使用 float16 精度，需显卡支持。3. 支持 1 步和 4 步快速生成，可配合 Tiny VAE 降低显存消耗。4. 训练部分已知问题：当前 SDXL 的 FSDP 训练速度极慢，LoRA 训练比全量微调更慢且显存占用相同。5. 需要安装 xformers 以启用内存高效注意力机制。","3.8",[102,103,104,105,106,107,108,109,110],"torch","diffusers","transformers","accelerate","xformers","safetensors","huggingface_hub","controlnet_aux","anyio",[15],"2026-03-27T02:49:30.150509","2026-04-11T21:59:50.087498",[115,120,125,130,135,140,144],{"id":116,"question_zh":117,"answer_zh":118,"source_url":119},29793,"如何在显存有限的单卡或多卡环境下训练 SDXL 模型（解决 OOM 或配置问题）？","如果移除 FSDP 后仍无法运行，请尝试在创建 accelerator 时将 mixed_precision 设置为 \"bf16\" 而不是 \"no\"，并确保准备好模型。例如：在单张 80G GPU 上移除 --fsdp 并使用 bf16 精度可以将 batch size 设为 2；在多卡环境下，如果显存紧张，可能需要将每张卡的 batch size 调整为 1。","https:\u002F\u002Fgithub.com\u002Ftianweiy\u002FDMD2\u002Fissues\u002F47",{"id":121,"question_zh":122,"answer_zh":123,"source_url":124},29794,"学生模型（Student Model）训练时是否需要开启 Dropout 或设置为 train() 模式？","所有学生模型均在 dropout=0 的情况下进行训练，这在代码中已明确指定。因此，模型处于 train() 还是 eval() 模式对结果影响不大，因为加载后的 SD 模型在 dropout 层中 dropout 值默认为 0。","https:\u002F\u002Fgithub.com\u002Ftianweiy\u002FDMD2\u002Fissues\u002F21",{"id":126,"question_zh":127,"answer_zh":128,"source_url":129},29795,"如何将 DMD2 的 4 步推理能力通过 LoRA 迁移到其他微调过的 SDXL 社区模型上？","可以成功迁移，但可能需要调整 LoRA 的缩放比例（lora_scale）。对于原始 SDXL 模型效果最好；对于其他微调模型（如 Juggernaut），建议尝试较小的 lora_scale（例如 0.5 或 0.75）以减少伪影。代码示例：pipe.fuse_lora(lora_scale=0.75)。","https:\u002F\u002Fgithub.com\u002Ftianweiy\u002FDMD2\u002Fissues\u002F5",{"id":131,"question_zh":132,"answer_zh":133,"source_url":134},29796,"在 SDv1.5 第二阶段训练中，生成器损失（gen_cls_loss）增加而判别器损失（guidance_cls_loss）减少是否正常？","这种情况是可能发生的。即使生成器损失增加，只要 FID 指标持续下降并接近论文水平，训练就是有效的。此外，生成器损失的量级通常比 DMD 损失小一个数量级（例如 g loss 为 0.001 而 dmd loss 为 0.01），这也是预期现象。使用较小的 batch size 可能会影响损失曲线的具体表现，但不一定阻碍最终性能。","https:\u002F\u002Fgithub.com\u002Ftianweiy\u002FDMD2\u002Fissues\u002F39",{"id":136,"question_zh":137,"answer_zh":138,"source_url":139},29797,"遇到 LMDB 数据读取错误 'AttributeError: NoneType object has no attribute decode' 该如何解决？","这通常是由于下载的数据文件不完整或损坏导致的。解决方案是重新下载数据集。有用户反馈重新下载数据后问题消失。请确保下载的 .mdb 文件完整无误。","https:\u002F\u002Fgithub.com\u002Ftianweiy\u002FDMD2\u002Fissues\u002F30",{"id":141,"question_zh":142,"answer_zh":143,"source_url":134},29798,"是否可以为生成器训练带有 CFG (Classifier-Free Guidance) 的模型？训练时使用的 CFG 比例是否必须与推理时一致？","目前主要关注无 CFG 训练的生成器。关于是否使用 CFG 训练生成器以提升性能，或者能否用无 CFG 训练的模型进行带 CFG 的推理，官方尚未给出定论，但这属于探索方向。通常建议如果训练时使用了特定的 guidance scale（如 8），推理时使用相同或相近的 scale 效果更稳定；若需灵活调整，可能需要针对不同 scale 分别训练或验证泛化性。",{"id":145,"question_zh":146,"answer_zh":147,"source_url":139},29799,"在 SDXL 上使用 256x256 分辨率进行预测或训练是否可行？","不建议。教师模型（Teacher Model）可能无法很好地处理 256x256 分辨率，因为该分辨率对于 SDXL 模型来说分布差异过大（out of distribution）。建议先使用 512x512 分辨率进行微调，这样不仅效果更好，训练速度也会更快。",[]]