[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-arpitbansal297--Cold-Diffusion-Models":3,"tool-arpitbansal297--Cold-Diffusion-Models":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 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",108111,2,"2026-04-08T11:23:26",[14,15,13],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":10,"last_commit_at":41,"category_tags":42,"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",[43,15,13,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},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,52],"视频",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":59,"last_commit_at":60,"category_tags":61,"status":17},5646,"opencv","opencv\u002Fopencv","OpenCV 是一个功能强大的开源计算机视觉库，被誉为机器视觉领域的“瑞士军刀”。它主要解决让计算机“看懂”图像和视频的核心难题，提供了从基础的图像读取、色彩转换、边缘检测，到复杂的人脸识别、物体追踪、3D 重建及深度学习模型部署等全方位算法支持。无论是处理静态图片还是分析实时视频流，OpenCV 都能高效完成特征提取与模式识别任务。\n\n这款工具特别适合计算机视觉开发者、人工智能研究人员以及机器人工程师使用。对于希望将视觉感知能力集成到应用中的软件工程师，或是需要快速验证算法原型的学术研究者，OpenCV 都是不可或缺的基础设施。虽然普通用户通常不会直接操作代码，但日常生活中使用的扫码支付、美颜相机和自动驾驶系统，背后往往都有它的身影。\n\nOpenCV 的独特亮点在于其卓越的性能与广泛的兼容性。它采用 C++ 编写以确保高速运算，同时提供 Python、Java 等多种语言接口，极大降低了开发门槛。库中内置了数千种优化算法，并支持跨平台运行，能够无缝对接各类硬件加速器。作为社区驱动的项目，OpenCV 拥有活跃的生态系统和丰富的学习资源，持续推动着视觉技术的前沿发展。",86988,1,"2026-04-08T16:06:22",[14,15],{"id":63,"github_repo":64,"name":65,"description_en":66,"description_zh":67,"ai_summary_zh":67,"readme_en":68,"readme_zh":69,"quickstart_zh":70,"use_case_zh":71,"hero_image_url":72,"owner_login":73,"owner_name":74,"owner_avatar_url":75,"owner_bio":76,"owner_company":77,"owner_location":78,"owner_email":79,"owner_twitter":73,"owner_website":80,"owner_url":81,"languages":82,"stars":91,"forks":92,"last_commit_at":93,"license":76,"difficulty_score":94,"env_os":95,"env_gpu":96,"env_ram":95,"env_deps":97,"category_tags":106,"github_topics":76,"view_count":32,"oss_zip_url":76,"oss_zip_packed_at":76,"status":17,"created_at":107,"updated_at":108,"faqs":109,"releases":130},5791,"arpitbansal297\u002FCold-Diffusion-Models","Cold-Diffusion-Models","Official implementation of Cold-Diffusion for different transformations in pytorch.","Cold-Diffusion-Models 是一个基于 PyTorch 的开源项目，实现了名为“冷扩散”的创新图像生成技术。与传统扩散模型依赖添加高斯噪声来破坏图像不同，该工具能够直接对图像执行任意变换（如高斯模糊、形态扭曲、分辨率降低、去色或添加雪景效果等），并学习如何从这些变换后的状态完美还原出原始清晰图像。\n\n它主要解决了传统生成模型在逆向过程中必须引入随机噪声的局限性，提供了一种无需噪声即可反转复杂图像变换的新范式。这使得模型在处理特定类型的图像退化任务时更加精准和可控，同时也为无条件图像生成提供了新的对比基准。\n\n该项目非常适合人工智能研究人员、计算机视觉开发者以及对生成式模型原理感兴趣的技术人员使用。通过内置的训练与测试脚本，用户可以轻松复现论文实验，或在 CelebA、AFHQ 等数据集上探索不同变换下的模型表现。其核心技术亮点在于提出了两种独特的采样算法，并兼容 DDIM 等主流方法，允许灵活调整去噪步数与策略。代码结构清晰，依托于成熟的 denoising-diffusion-pytorch 框架，便于扩展与二次开发。","# Cold Diffusion: Inverting Arbitrary Image Transforms Without Noise\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Farpitbansal297_Cold-Diffusion-Models_readme_8c0d3dd8df4d.png\" width=\"1000px\">\u003C\u002Fimg>\n\nThe official PyTorch implementation of \u003Ca href=\"https:\u002F\u002Farxiv.org\u002Fabs\u002F2208.09392\">Cold-Diffusion\u003C\u002Fa>. Developed collaboratively by Arpit Bansal, Eitan Borgnia, Hong-Min Chu, Jie Li, and Hamid Kazemi, all at the University of Maryland. This repository has code to train and test various cold diffusion models based on the following image degradations: Gaussian blur, _animorphosis_, Gaussian mask, resolution downsampling, image snow, and color desaturation. Our implementation is based on the denoising diffusion repository from \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Flucidrains\u002Fdenoising-diffusion-pytorch\">lucidrains\u003C\u002Fa>, which is a PyTorch implementation of \u003Ca href=\"https:\u002F\u002Farxiv.org\u002Fabs\u002F2006.11239\">DDPM\u003C\u002Fa>.\n\n## Updates\nOctober 12, 2022 : Pretrained models for CelebA generation using blur and animorphs, and AFHQ generation using blur, added to \u003Ca href=\"https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1R7CKUrkiIDsDYh2__Yi1iLvRR6wNxVFF?usp=sharing\">our drive\u003C\u002Fa>.\n\n## Citing Our Work\n\nTo cite our paper please use the following bibtex entry.\n\n```bibtex\n@misc{bansal2022cold,\n      title={Cold Diffusion: Inverting Arbitrary Image Transforms Without Noise}, \n      author={Arpit Bansal and Eitan Borgnia and Hong-Min Chu and Jie S. Li and Hamid Kazemi and Furong Huang and Micah Goldblum and Jonas Geiping and Tom Goldstein},\n      year={2022},\n      eprint={2208.09392},\n      archivePrefix={arXiv},\n      primaryClass={cs.CV}\n}\n```\n\n## Preparing the Datasets\n\nWe use the `create_data.py` file to split data into individual folders for training and testing data. The MNIST and CIFAR-10 datasets can be processed directly with `create_data.py`, but a path to the folder for the CelebA dataset is required. The AFHQ dataset is already split up into individual folders for training and testing data, so preprocessing is unecessary. The save directory for each of the data folders can be modified and will be used in the training scripts for the various hot\u002Fcold diffusion models.\n\n## Denoising (hot) Diffusion Models\n\nFor completeness, we present the code to produce models trained to undo Gaussian noise for direct comparison to our cold diffusion models on the task of unconditional generation. The code for these models is in the `denoising-diffusion-pytorch` folder.\n\n#### Training \n\nWe have separate scripts for training models on each dataset _i.e_ `\u003Cdataset>_noise_\u003Cresolution>.py`. As per Section 5 of the paper, we include scripts for the 128 x 128 CelebA and AFHQ datasets. The `--time_steps` argument can used to vary the number of steps it takes to reach the final isotropic Gaussian noise distribution. \n\nThe `--sampling_routine` argument allows you to switch between different sampling algorithms. Choosing `default` will sample using Algorithm 1 from our paper, `x0_step_down` is Algorithm 2 from our paper with fixed noise, and `ddim` is the version of Algorithm 2 where one uses estimated noise as in \u003Ca href=\"https:\u002F\u002Farxiv.org\u002Fabs\u002F2010.02502\">Song et al.\u003C\u002Fa>.\n\nThe `--save_folder` argument indicates the path to save the trained model, and the training data samples produced to keep track of progress. The frequency of saving and progress tracking can be modified in the `Trainer` class defined in `denoising_diffusion_pytorch.py`. The `data_path` argument specifies the path to the training data folder produced in the dataset preparation step.\n\nBelow is an example script for training denoising diffusion models.\n\n```\npython \u003Cdataset>_noise_\u003Cresolution>.py --time_steps 200 --sampling_routine x0_step_down --save_folder \u003CPath to save model folder> --data_path \u003CPath to train data folder>\n```\n\n#### Testing\n\nTo test the models, it is important to input the same number of time steps used during training. The sampling routine can be different, and additionally the `test_type` argument can be used to specify the type of testing to be done. See the `Trainer` class defined in `denoising_diffusion_pytorch.py` to understand the different testing methods. \n\nWe present two example testing scripts below. The first script uses the DDIM sampling method with estimated noise, and the second script uses the fixed noise method we describe in Algorithm 2 of our paper.\n\n```\npython \u003Cdataset>_noise_\u003Cresolution>_test.py --time_steps 200 --sampling_routine ddim --save_folder \u003CPath to save images> --load_path \u003CPath to load model> --data_path \u003CPath to data folder> --test_type test_sample_and_save_for_fid\n```\n\n```\npython \u003Cdataset>_noise_\u003Cresolution>_test.py --time_steps 200 --sampling_routine x0_step_down --save_folder \u003CPath to save images> --load_path \u003CPath to load model> --data_path \u003CPath to data folder> --test_type test_sample_and_save_for_fid\n```\n\n## Cold Diffusion Models\n\nWe present the training and testing procedure for the various cold diffusions explored in our paper. For each cold diffusion, there are example scripts for two different degradation schedules. The conditional generation schedule can be used to reproduce results from Section 4 of the paper, and the unconditional generation schedule can be used to reproduce section 5. Unless otherwise specified, the arguments and procedure work exactly the same as described in detail for the hot diffusion models.\n\n### Gaussian Blur\n\nThe code for these models is in the `deblurring-diffusion-pytorch` folder. For Gaussian blurring, the arguments that specify the degradation schedule are `--time_steps`, `--blur_size`, `--blur_std`, and `blur_routine`. See the help strings in the training scripts for details on what these arguments specify.\n\n#### Conditional Generation\n\n*Training*\n```\npython mnist_train.py --time_steps 20 --blur_size 11 --blur_std 7.0 --blur_routine 'Constant' --sampling_routine x0_step_down --data_path \u003CPath to data folder> --save_folder \u003CPath to save model> \npython cifar10_train.py --time_steps 50 --blur_routine 'Special_6_routine' --sampling_routine x0_step_down --data_path \u003CPath to data folder> --save_folder \u003CPath to save model> \npython celebA_128.py --time_steps 200 --blur_size 15 --blur_std 0.01 --blur_routine Exponential_reflect --sampling_routine x0_step_down --data_path \u003CPath to data folder> --save_folder \u003CPath to save model> \n```\n*Testing*\n```\npython mnist_test.py --time_steps 20 --blur_size 11 --blur_std 7.0 --blur_routine 'Constant' --sampling_routine 'x0_step_down' --save_folder \u003CPath to save results> --data_path \u003CPath to data folder> --test_type test_data\npython cifar10_test.py --time_steps 50 --blur_routine 'Special_6_routine' --sampling_routine 'x0_step_down' --save_folder \u003CPath to save results> --data_path \u003CPath to data folder> --test_type test_data\npython celebA_128_test.py --time_steps 200 --blur_size 15 --blur_std 0.01 --blur_routine Exponential_reflect --sampling_routine x0_step_down --save_folder \u003CPath to save results> --data_path \u003CPath to data folder> --test_type test_data\n```\n\n#### Unconditional Generation\n\n*Training*\n```\npython celebA_128.py --discrete --time_steps 300 --blur_size 27 --blur_std 0.01 --blur_routine Exponential --sampling_routine x0_step_down --data_path \u003CPath to data folder> --save_folder \u003CPath to save models>\npython AFHQ_128.py --discrete --time_steps 300 --blur_size 27 --blur_std 0.01 --blur_routine Exponential --sampling_routine x0_step_down --data_path \u003CPath to data folder> --save_folder \u003CPath to save models>\n```\n*Testing*\n\nBelow are two sets of testing scripts for the models\u002Fdatasets presented in the paper. The first set of scripts corresponds to the sampling done with **perfect symmetry**, and the second set of scripts corresponds to sampling done with **broken** symmetry. The `--gmm_cluster` argument specifies the number of modes for the Gaussian mixture model (GMM) that is fit to the distribution of degraded images. The `--noise` argument is used to control the degree to which symmetry is broken after sampling from the GMM.\n```\npython celebA_128_test.py --gmm_cluster 1 --noise 0.000 --discrete --time_steps 300 --blur_size 27 --blur_std 0.01 --blur_routine Exponential --sampling_routine x0_step_down --save_folder \u003CPath to save results> --load_path \u003CPath to load models> --data_path \u003CPath to data folder> --test_type train_distribution_mean_blur_torch_gmm_ablation\npython AFHQ_128_test.py --gmm_cluster 1 --noise 0.000 --discrete --time_steps 300 --blur_size 27 --blur_std 0.01 --blur_routine Exponential --sampling_routine x0_step_down --save_folder \u003CPath to save results> --load_path \u003CPath to load models> --data_path \u003CPath to data folder> --test_type train_distribution_mean_blur_torch_gmm_ablation\n```\n```\npython celebA_128_test.py --gmm_cluster 1 --noise 0.002 --discrete --time_steps 300 --blur_size 27 --blur_std 0.01 --blur_routine Exponential --sampling_routine x0_step_down --save_folder \u003CPath to save results> --load_path \u003CPath to load models> --data_path \u003CPath to data folder> --test_type train_distribution_mean_blur_torch_gmm_ablation\npython AFHQ_128_test.py --gmm_cluster 1 --noise 0.002 --discrete --time_steps 300 --blur_size 27 --blur_std 0.01 --blur_routine Exponential --sampling_routine x0_step_down --save_folder \u003CPath to save results> --load_path \u003CPath to load models> --data_path \u003CPath to data folder> --test_type train_distribution_mean_blur_torch_gmm_ablation\n```\n\n### Animorphosis\n\nThe code for these models is in the `demixing-diffusion-pytorch` folder.\n\n#### Unconditional Generation\n\n*Training*\n```\npython AFHQ_128_to_celebA_128.py --time_steps 200 --sampling_routine x0_step_down --save_folder \u003Cpath to save models> --data_path_start \u003CPath to starting data manifold> --data_path_end \u003CPath to ending data manifold>\n```\n*Testing*\n```\npython AFHQ_128_to_celebA_128_test.py --time_steps 200 --sampling_routine x0_step_down --save_folder \u003CPath to save images> --load_path \u003CPath to load model> --data_path_start \u003CPath to starting data manifold> --data_path_end \u003CPath to ending data manifold> --test_type test_sample_and_save_for_fid\n```\n\n### Inpainting\n\nThe code for the conditional generation is in the `defading-diffusion-pytorch` folder, and the code for unconditional generation is in the `defading-generation-diffusion-pytorch` folder. For Gaussian masking, the arguments that specify the degradation schedule are `--time_steps`, `--kernel_std`, and `fade_routine`. See the help strings in the training scripts for details on what these arguments specify.\n\n#### Conditional Generation\n\n*Training*\n```\npython mnist_train.py --time_steps 50 --save_folder \u003Cpath to save models> --discrete --sampling_routine x0_step_down --train_steps 700000 --kernel_std 0.1 --fade_routine Random_Incremental --data_path \u003CPath to data folder>\npython cifar10_train.py --time_steps 50 --save_folder \u003Cpath to save models> --discrete --sampling_routine x0_step_down --train_steps 700000 --kernel_std 0.1 --fade_routine Random_Incremental --data_path \u003CPath to data folder>\npython celebA_train.py --time_steps 100 --fade_routine Incremental --save_folder \u003Cpath to save models> --sampling_routine x0_step_down --train_steps 350000 --kernel_std 0.2 --image_size 128 --dataset celebA --data_path \u003CPath to data folder>\n```\n*Testing*\n```\npython mnist_test.py --time_steps 50 --save_folder test_mnist --discrete --sampling_routine x0_step_down --kernel_std 0.1 --initial_mask 1 --image_size 28 --fade_routine Random_Incremental --load_path \u003CPath to load model> --data_path \u003CPath to data folder> --test_type test_data \npython cifar10_test.py --time_steps 50 --save_folder test_cifar10 --discrete --sampling_routine x0_step_down --kernel_std 0.1 --initial_mask 1 --image_size 32 --fade_routine Random_Incremental --load_path \u003CPath to load model> --data_path \u003CPath to data folder> --test_type test_data\npython celebA_test.py --time_steps 100 --fade_routine Incremental --save_folder test_celebA --sampling_routine x0_step_down --kernel_std 0.2 --initial_mask 1 --image_size 128 --dataset celebA --load_path \u003CPath to load model> --data_path \u003CPath to data folder> --test_type test_data\n```\n\n#### Unconditional Generation\n\n*Training*\n```\npython celebA_128.py --reverse --kernel_std 0.05 --initial_mask 1 --time_steps 750 --sampling_routine x0_step_down --save_folder \u003CPath to save models> --data_path \u003CPath to data folder>\n```\n\n*Testing*\n```\npython celebA_constant_128_test.py --reverse --kernel_std 0.05 --time_steps 750 --sampling_routine x0_step_down --save_folder \u003CPath to save images> --data_path \u003CPath to data folder> --load_path \u003CPath to load model> --test_type test_sample_and_save_for_fid\n```\n\n### Super-Resolution\n\nThe code for these models is in the `resolution-diffusion-pytorch` folder. For downsampling, the arguments that specify the degradation schedule are `--time_steps`, and `resolution_routine`. See the help strings in the training scripts for details on what these arguments specify.\n\n#### Conditional Generation\n\n*Training*\n```\npython mnist_train.py --time_steps 3 --resolution_routine 'Incremental_factor_2' --save_folder \u003CPath to save models>\npython cifar10_train.py --time_steps 3 --resolution_routine 'Incremental_factor_2' --save_folder \u003CPath to save models>\npython celebA_128.py --time_steps 4 --resolution_routine 'Incremental_factor_2' --save_folder \u003CPath to save models>\n```\n*Testing*\n```\npython mnist_test.py --time_steps 3 --train_routine 'Final' --sampling_routine 'x0_step_down' --resolution_routine 'Incremental_factor_2' --save_folder \u003CPath to save images> --load_path \u003CPath to load model> --test_type test_data\npython cifar10_test.py --time_steps 3 --train_routine 'Final' --sampling_routine 'x0_step_down' --resolution_routine 'Incremental_factor_2' --save_folder \u003CPath to save images> --load_path \u003CPath to load model> --test_type test_data\npython celebA_test.py --time_steps 4 --train_routine 'Final' --sampling_routine 'x0_step_down' --resolution_routine 'Incremental_factor_2' --save_folder \u003CPath to save images> --load_path \u003CPath to load model> --test_type test_data\n```\n\n#### Unconditional Generation\n\n*Training*\n```\npython celebA_test.py --time_steps 4 --train_routine 'Final' --sampling_routine 'x0_step_down' --resolution_routine 'Incremental_factor_2' --save_folder \u003CPath to save images> --load_path \u003CPath to load model> --test_type test_data\n```\n*Testing*\n```\npython celebA_test.py --time_steps 4 --train_routine 'Final' --sampling_routine 'x0_step_down' --resolution_routine 'Incremental_factor_2' --save_folder \u003CPath to save images> --load_path \u003CPath to load model> --test_type test_data\n```\n\n### Snowification\n\nThe code for these models is in the `snowification` folder. This code stems from the existing \u003Ca href=\"https:\u002F\u002Fpypi.org\u002Fproject\u002Fimagenet-c\u002F\">ImageNet C\u003C\u002Fa> repository. The arguments that specify the degradation schedule are `--time_steps`, `--snow_level`, `--random_snow`, and `--fix_brightness`. See the help strings in the training scripts for details on what these arguments specify.\n\n#### Conditional Generation\n\n*Training*\n```\npython train.py --dataset cifar10 --time_steps 200 --forward_process_type ‘Snow’ --snow_level 3 --exp_name \u003Cexp_name>  --dataset_folder \u003Cpath-to-dataset> --random_snow --fix_brightness  --sampling_routine x0_step_down\npython train.py --dataset celebA --time_steps 200 --forward_process_type ‘Snow’ --snow_level 4 --exp_name \u003Cexp_name> --dataset_folder \u003Cpath-to-dataset> --random_snow --fix_brightness  --sampling_routine x0_step_down\n```\n*Testing*\n```\npython test.py --dataset cifar10 --time_steps 200 --forward_process_type ‘Snow’ --snow_level 3 --exp_name \u003Cexp_name> --dataset_folder \u003Cpath-to-dataset> --random_snow --fix_brightness --resume_training --sampling_routine x0_step_down --test_type test_data --order_seed 1\npython test.py --dataset celebA --time_steps 200 --forward_process_type ‘Snow’ --snow_level 4 --exp_name \u003Cexp_name> --dataset_folder \u003Cpath-to-dataset> --random_snow --fix_brightness --resume_training --sampling_routine x0_step_down --test_type test_data --order_seed 1\n```\n\n### Colorization\n\nThe code for these models is in the `decolor-diffusion` folder. For color desaturation, the arguments that specify the degradation schedule are `--time_steps`, `decolor_total_remove`, and `decolor_routine`. See the help strings in the training scripts for details on what these arguments specify.\n\n#### Conditional Generation\n\n*Training*\n```\npython train.py --dataset cifar10 --time_steps 20 --forward_process_type ‘Decolorization’ --exp_name \u003Cexp_name> --decolor_total_remove --decolor_routine ‘Linear’ --dataset_folder \u003Cpath-to-dataset>\npython train.py --dataset celebA --time_steps 20 --forward_process_type ‘Decolorization’ --exp_name \u003Cexp_name> --decolor_total_remove --decolor_routine ‘Linear’ --dataset_folder \u003Cpath-to-dataset>\n```\n*Testing*\n```\npython test.py --dataset cifar10 --time_steps 20 --forward_process_type ‘Decolorization’ --exp_name \u003Cexp-name>  --decolor_total_remove --decolor_routine ‘Linear’ --dataset_folder \u003Cpath-to-dataset> --sampling_routine x0_step_down --test_type test_data --order_seed 1\npython test.py --dataset celebA --time_steps 20 --forward_process_type ‘Decolorization’ --exp_name \u003Cexp-name>  --decolor_total_remove --decolor_routine ‘Linear’ --dataset_folder \u003Cpath-to-dataset> --sampling_routine x0_step_down --test_type test_data --order_seed 1\n```\n","# 冷扩散：无噪声地逆向任意图像变换\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Farpitbansal297_Cold-Diffusion-Models_readme_8c0d3dd8df4d.png\" width=\"1000px\">\u003C\u002Fimg>\n\n这是 \u003Ca href=\"https:\u002F\u002Farxiv.org\u002Fabs\u002F2208.09392\">冷扩散\u003C\u002Fa> 的官方 PyTorch 实现。由马里兰大学的 Arpit Bansal、Eitan Borgnia、Hong-Min Chu、Jie Li 和 Hamid Kazemi 共同开发。该仓库包含用于训练和测试多种冷扩散模型的代码，这些模型针对以下图像退化类型：高斯模糊、_变形_、高斯掩码、分辨率下采样、图像雪景以及色彩去饱和。我们的实现基于 \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Flucidrains\u002Fdenoising-diffusion-pytorch\">lucidrains\u003C\u002Fa> 提供的去噪扩散仓库，后者是 \u003Ca href=\"https:\u002F\u002Farxiv.org\u002Fabs\u002F2006.11239\">DDPM\u003C\u002Fa> 的 PyTorch 实现。\n\n## 更新\n2022年10月12日：使用模糊和变形处理生成 CelebA 数据集的预训练模型，以及使用模糊处理生成 AFHQ 数据集的预训练模型，已添加至 \u003Ca href=\"https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1R7CKUrkiIDsDYh2__Yi1iLvRR6wNxVFF?usp=sharing\">我们的云盘\u003C\u002Fa>。\n\n## 引用我们的工作\n\n如需引用我们的论文，请使用以下 BibTeX 条目：\n\n```bibtex\n@misc{bansal2022cold,\n      title={Cold Diffusion: Inverting Arbitrary Image Transforms Without Noise}, \n      author={Arpit Bansal and Eitan Borgnia and Hong-Min Chu and Jie S. Li and Hamid Kazemi and Furong Huang and Micah Goldblum and Jonas Geiping and Tom Goldstein},\n      year={2022},\n      eprint={2208.09392},\n      archivePrefix={arXiv},\n      primaryClass={cs.CV}\n}\n```\n\n## 数据集准备\n\n我们使用 `create_data.py` 文件将数据拆分为用于训练和测试的独立文件夹。MNIST 和 CIFAR-10 数据集可以直接通过 `create_data.py` 处理，但需要提供 CelebA 数据集文件夹的路径。AFHQ 数据集已经按训练和测试数据分好文件夹，因此无需额外预处理。每个数据文件夹的保存目录可以修改，并将在各种热\u002F冷扩散模型的训练脚本中使用。\n\n## 去噪（热）扩散模型\n\n为完整起见，我们提供了用于生成可去除 Gaussian 噪声模型的代码，以便与我们在无条件生成任务上的冷扩散模型直接比较。这些模型的代码位于 `denoising-diffusion-pytorch` 文件夹中。\n\n#### 训练\n\n我们为每个数据集的模型训练准备了单独的脚本，即 `\u003Cdataset>_noise_\u003Cresolution>.py`。根据论文第 5 节的内容，我们包含了针对 128×128 分辨率的 CelebA 和 AFHQ 数据集的脚本。`--time_steps` 参数可用于调整达到最终各向同性 Gaussian 噪声分布所需的步数。\n\n`--sampling_routine` 参数允许在不同采样算法之间切换。选择 `default` 将使用我们论文中的算法 1 进行采样；`x0_step_down` 是我们论文中算法 2 的固定噪声版本；而 `ddim` 则是 Song 等人 \u003Ca href=\"https:\u002F\u002Farxiv.org\u002Fabs\u002F2010.02502\">提出\u003C\u002Fa>的、采用估计噪声的算法 2 版本。\n\n`--save_folder` 参数指定了保存训练好的模型以及用于跟踪进度的训练数据样本的路径。保存和进度跟踪的频率可以在 `denoising_diffusion_pytorch.py` 中定义的 `Trainer` 类中进行修改。`data_path` 参数则指定了数据集准备步骤中生成的训练数据文件夹路径。\n\n以下是训练去噪扩散模型的示例脚本：\n\n```\npython \u003Cdataset>_noise_\u003Cresolution>.py --time_steps 200 --sampling_routine x0_step_down --save_folder \u003C模型保存路径> --data_path \u003C训练数据路径>\n```\n\n#### 测试\n\n测试模型时，务必输入与训练时相同的步数。采样方法可以不同，此外还可以使用 `test_type` 参数指定要进行的测试类型。有关不同测试方法的说明，请参阅 `denoising_diffusion_pytorch.py` 中定义的 `Trainer` 类。\n\n下面提供两个测试脚本示例。第一个脚本使用 DDIM 采样方法并采用估计噪声，第二个脚本则使用我们在论文算法 2 中描述的固定噪声方法。\n\n```\npython \u003Cdataset>_noise_\u003Cresolution>_test.py --time_steps 200 --sampling_routine ddim --save_folder \u003C图片保存路径> --load_path \u003C模型加载路径> --data_path \u003C数据路径> --test_type test_sample_and_save_for_fid\n```\n\n```\npython \u003Cdataset>_noise_\u003Cresolution>_test.py --time_steps 200 --sampling_routine x0_step_down --save_folder \u003C图片保存路径> --load_path \u003C模型加载路径> --data_path \u003C数据路径> --test_type test_sample_and_save_for_fid\n```\n\n## 冷扩散模型\n\n我们介绍了论文中探讨的各种冷扩散模型的训练和测试流程。对于每种冷扩散，都提供了两种不同退化方案的示例脚本。有条件生成的方案可用于复现论文第 4 节的结果，而无条件生成的方案则可用于复现第 5 节的结果。除非另有说明，否则参数和流程与热扩散模型的详细描述完全相同。\n\n### 高斯模糊\n\n这些模型的代码位于 `deblurring-diffusion-pytorch` 文件夹中。对于高斯模糊，用于指定退化时间表的参数包括 `--time_steps`、`--blur_size`、`--blur_std` 和 `blur_routine`。有关这些参数的具体含义，请参阅训练脚本中的帮助信息。\n\n#### 条件生成\n\n*训练*\n```\npython mnist_train.py --time_steps 20 --blur_size 11 --blur_std 7.0 --blur_routine 'Constant' --sampling_routine x0_step_down --data_path \u003C数据文件夹路径> --save_folder \u003C保存模型路径> \npython cifar10_train.py --time_steps 50 --blur_routine 'Special_6_routine' --sampling_routine x0_step_down --data_path \u003C数据文件夹路径> --save_folder \u003C保存模型路径> \npython celebA_128.py --time_steps 200 --blur_size 15 --blur_std 0.01 --blur_routine Exponential_reflect --sampling_routine x0_step_down --data_path \u003C数据文件夹路径> --save_folder \u003C保存模型路径> \n```\n*测试*\n```\npython mnist_test.py --time_steps 20 --blur_size 11 --blur_std 7.0 --blur_routine 'Constant' --sampling_routine 'x0_step_down' --save_folder \u003C保存结果路径> --data_path \u003C数据文件夹路径> --test_type test_data\npython cifar10_test.py --time_steps 50 --blur_routine 'Special_6_routine' --sampling_routine 'x0_step_down' --save_folder \u003C保存结果路径> --data_path \u003C数据文件夹路径> --test_type test_data\npython celebA_128_test.py --time_steps 200 --blur_size 15 --blur_std 0.01 --blur_routine Exponential_reflect --sampling_routine x0_step_down --save_folder \u003C保存结果路径> --data_path \u003C数据文件夹路径> --test_type test_data\n```\n\n#### 无条件生成\n\n*训练*\n```\npython celebA_128.py --discrete --time_steps 300 --blur_size 27 --blur_std 0.01 --blur_routine Exponential --sampling_routine x0_step_down --data_path \u003C数据文件夹路径> --save_folder \u003C保存模型路径>\npython AFHQ_128.py --discrete --time_steps 300 --blur_size 27 --blur_std 0.01 --blur_routine Exponential --sampling_routine x0_step_down --data_path \u003C数据文件夹路径> --save_folder \u003C保存模型路径>\n```\n*测试*\n\n以下是论文中所展示的模型\u002F数据集的两组测试脚本。第一组脚本对应于在**完全对称**条件下进行的采样，第二组脚本则对应于在**对称性被破坏**的情况下进行的采样。`--gmm_cluster` 参数指定了拟合到退化图像分布上的高斯混合模型（GMM）的模式数。`--noise` 参数用于控制从 GMM 采样后对称性被破坏的程度。\n```\npython celebA_128_test.py --gmm_cluster 1 --noise 0.000 --discrete --time_steps 300 --blur_size 27 --blur_std 0.01 --blur_routine Exponential --sampling_routine x0_step_down --save_folder \u003C保存结果路径> --load_path \u003C加载模型路径> --data_path \u003C数据文件夹路径> --test_type train_distribution_mean_blur_torch_gmm_ablation\npython AFHQ_128_test.py --gmm_cluster 1 --noise 0.000 --discrete --time_steps 300 --blur_size 27 --blur_std 0.01 --blur_routine Exponential --sampling_routine x0_step_down --save_folder \u003C保存结果路径> --load_path \u003C加载模型路径> --data_path \u003C数据文件夹路径> --test_type train_distribution_mean_blur_torch_gmm_ablation\n```\n```\npython celebA_128_test.py --gmm_cluster 1 --noise 0.002 --discrete --time_steps 300 --blur_size 27 --blur_std 0.01 --blur_routine Exponential --sampling_routine x0_step_down --save_folder \u003C保存结果路径> --load_path \u003C加载模型路径> --data_path \u003C数据文件夹路径> --test_type train_distribution_mean_blur_torch_gmm_ablation\npython AFHQ_128_test.py --gmm_cluster 1 --noise 0.002 --discrete --time_steps 300 --blur_size 27 --blur_std 0.01 --blur_routine Exponential --sampling_routine x0_step_down --save_folder \u003C保存结果路径> --load_path \u003C加载模型路径> --data_path \u003C数据文件夹路径> --test_type train_distribution_mean_blur_torch_gmm_ablation\n```\n\n### 动物变形术\n\n这些模型的代码位于 `demixing-diffusion-pytorch` 文件夹中。\n\n#### 无条件生成\n\n*训练*\n```\npython AFHQ_128_to_celebA_128.py --time_steps 200 --sampling_routine x0_step_down --save_folder \u003C保存模型路径> --data_path_start \u003C起始数据流形路径> --data_path_end \u003C终止数据流形路径>\n```\n*测试*\n```\npython AFHQ_128_to_celebA_128_test.py --time_steps 200 --sampling_routine x0_step_down --save_folder \u003C保存图像路径> --load_path \u003C加载模型路径> --data_path_start \u003C起始数据流形路径> --data_path_end \u003C终止数据流形路径> --test_type test_sample_and_save_for_fid\n```\n\n### 图像修复\n\n条件生成的代码位于 `defading-diffusion-pytorch` 文件夹中，而非条件生成的代码则位于 `defading-generation-diffusion-pytorch` 文件夹中。对于高斯掩码，用于指定退化过程的参数包括 `--time_steps`、`--kernel_std` 和 `fade_routine`。有关这些参数的具体含义，请参阅训练脚本中的帮助信息。\n\n#### 条件生成\n\n*训练*\n```\npython mnist_train.py --time_steps 50 --save_folder \u003C保存模型的路径> --discrete --sampling_routine x0_step_down --train_steps 700000 --kernel_std 0.1 --fade_routine Random_Incremental --data_path \u003C数据文件夹路径>\npython cifar10_train.py --time_steps 50 --save_folder \u003C保存模型的路径> --discrete --sampling_routine x0_step_down --train_steps 700000 --kernel_std 0.1 --fade_routine Random_Incremental --data_path \u003C数据文件夹路径>\npython celebA_train.py --time_steps 100 --fade_routine Incremental --save_folder \u003C保存模型的路径> --sampling_routine x0_step_down --train_steps 350000 --kernel_std 0.2 --image_size 128 --dataset celebA --data_path \u003C数据文件夹路径>\n```\n*测试*\n```\npython mnist_test.py --time_steps 50 --save_folder test_mnist --discrete --sampling_routine x0_step_down --kernel_std 0.1 --initial_mask 1 --image_size 28 --fade_routine Random_Incremental --load_path \u003C加载模型的路径> --data_path \u003C数据文件夹路径> --test_type test_data \npython cifar10_test.py --time_steps 50 --save_folder test_cifar10 --discrete --sampling_routine x0_step_down --kernel_std 0.1 --initial_mask 1 --image_size 32 --fade_routine Random_Incremental --load_path \u003C加载模型的路径> --data_path \u003C 数据文件夹路径 > --test_type test_data\npython celebA_test.py --time_steps 100 --fade_routine Incremental --save_folder test_celebA --sampling_routine x0_step_down --kernel_std 0.2 --initial_mask 1 --image_size 128 --dataset celebA --load_path \u003C加载模型的路径> --data_path \u003C 数据文件夹路径 > --test_type test_data\n```\n\n#### 非条件生成\n\n*训练*\n```\npython celebA_128.py --reverse --kernel_std 0.05 --initial_mask 1 --time_steps 750 --sampling_routine x0_step_down --save_folder \u003C保存模型的路径> --data_path \u003C 数据文件夹路径 >\n```\n\n*测试*\n```\npython celebA_constant_128_test.py --reverse --kernel_std 0.05 --time_steps 750 --sampling_routine x0_step_down --save_folder \u003C保存图像的路径> --data_path \u003C 数据文件夹路径 > --load_path \u003C 加载模型的路径 > --test_type test_sample_and_save_for_fid\n```\n\n### 超分辨率\n\n这些模型的代码位于 `resolution-diffusion-pytorch` 文件夹中。对于下采样，用于指定退化过程的参数包括 `--time_steps` 和 `resolution_routine`。有关这些参数的具体含义，请参阅训练脚本中的帮助信息。\n\n#### 条件生成\n\n*训练*\n```\npython mnist_train.py --time_steps 3 --resolution_routine 'Incremental_factor_2' --save_folder \u003C保存模型的路径>\npython cifar10_train.py --time_steps 3 --resolution_routine 'Incremental_factor_2' --save_folder \u003C保存模型的路径>\npython celebA_128.py --time_steps 4 --resolution_routine 'Incremental_factor_2' --save_folder \u003C保存模型的路径>\n```\n*测试*\n```\npython mnist_test.py --time_steps 3 --train_routine 'Final' --sampling_routine 'x0_step_down' --resolution_routine 'Incremental_factor_2' --save_folder \u003C保存图像的路径> --load_path \u003C加载模型的路径> --test_type test_data\npython cifar10_test.py --time_steps 3 --train_routine 'Final' --sampling_routine 'x0_step_down' --resolution_routine 'Incremental_factor_2' --save_folder \u003C保存图像的路径> --load_path \u003C 加载模型的路径 > --test_type test_data\npython celebA_test.py --time_steps 4 --train_routine 'Final' --sampling_routine 'x0_step_down' --resolution_routine 'Incremental_factor_2' --save_folder \u003C保存图像的路径> --load_path \u003C 加载模型的路径 > --test_type test_data\n```\n\n#### 非条件生成\n\n*训练*\n```\npython celebA_test.py --time_steps 4 --train_routine 'Final' --sampling_routine 'x0_step_down' --resolution_routine 'Incremental_factor_2' --save_folder \u003C保存图像的路径> --load_path \u003C 加载模型的路径 > --test_type test_data\n```\n*测试*\n```\npython celebA_test.py --time_steps 4 --train_routine 'Final' --sampling_routine 'x0_step_down' --resolution_routine 'Incremental_factor_2' --save_folder \u003C保存图像的路径> --load_path \u003C 加载模型的路径 > --test_type test_data\n```\n\n### 降雪效果\n\n这些模型的代码位于 `snowification` 文件夹中。该代码源自现有的 \u003Ca href=\"https:\u002F\u002Fpypi.org\u002Fproject\u002Fimagenet-c\u002F\">ImageNet C\u003C\u002Fa> 仓库。用于指定退化过程的参数包括 `--time_steps`、`--snow_level`、`--random_snow` 和 `--fix_brightness`。有关这些参数的具体含义，请参阅训练脚本中的帮助信息。\n\n#### 条件生成\n\n*训练*\n```\npython train.py --dataset cifar10 --time_steps 200 --forward_process_type ‘Snow’ --snow_level 3 --exp_name \u003C实验名称>  --dataset_folder \u003C数据集路径> --random_snow --fix_brightness  --sampling_routine x0_step_down\npython train.py --dataset celebA --time_steps 200 --forward_process_type ‘Snow’ --snow_level 4 --exp_name \u003C实验名称> --dataset_folder \u003C数据集路径> --random_snow --fix_brightness  --sampling_routine x0_step_down\n```\n*测试*\n```\npython test.py --dataset cifar10 --time_steps 200 --forward_process_type ‘Snow’ --snow_level 3 --exp_name \u003C实验名称> --dataset_folder \u003C数据集路径> --random_snow --fix_brightness --resume_training --sampling_routine x0_step_down --test_type test_data --order_seed 1\npython test.py --dataset celebA --time_steps 200 --forward_process_type ‘Snow’ --snow_level 4 --exp_name \u003C实验名称> --dataset_folder \u003C数据集路径> --random_snow --fix_brightness --resume_training --sampling_routine x0_step_down --test_type test_data --order_seed 1\n```\n\n### 彩色化\n\n这些模型的代码位于 `decolor-diffusion` 文件夹中。对于颜色去饱和处理，用于指定退化时间表的参数是 `--time_steps`、`decolor_total_remove` 和 `decolor_routine`。有关这些参数的具体含义，请参阅训练脚本中的帮助信息。\n\n#### 条件生成\n\n*训练*\n```\npython train.py --dataset cifar10 --time_steps 20 --forward_process_type ‘Decolorization’ --exp_name \u003Cexp_name> --decolor_total_remove --decolor_routine ‘Linear’ --dataset_folder \u003Cpath-to-dataset>\npython train.py --dataset celebA --time_steps 20 --forward_process_type ‘Decolorization’ --exp_name \u003Cexp_name> --decolor_total_remove --decolor_routine ‘Linear’ --dataset_folder \u003Cpath-to-dataset>\n```\n*测试*\n```\npython test.py --dataset cifar10 --time_steps 20 --forward_process_type ‘Decolorization’ --exp_name \u003Cexp-name>  --decolor_total_remove --decolor_routine ‘Linear’ --dataset_folder \u003Cpath-to-dataset> --sampling_routine x0_step_down --test_type test_data --order_seed 1\npython test.py --dataset celebA --time_steps 20 --forward_process_type ‘Decolorization’ --exp_name \u003Cexp-name>  --decolor_total_remove --decolor_routine ‘Linear’ --dataset_folder \u003Cpath-to-dataset> --sampling_routine x0_step_down --test_type test_data --order_seed 1\n```","# Cold Diffusion Models 快速上手指南\n\nCold Diffusion 是一种无需添加噪声即可逆转任意图像变换（如高斯模糊、掩膜、降采样等）的扩散模型。本指南基于官方 PyTorch 实现，帮助开发者快速完成环境配置、安装及基础运行。\n\n## 环境准备\n\n在开始之前，请确保您的开发环境满足以下要求：\n\n*   **操作系统**: Linux (推荐 Ubuntu 18.04+) 或 macOS。Windows 用户建议使用 WSL2。\n*   **Python**: 3.8 或更高版本。\n*   **GPU**: 推荐使用 NVIDIA GPU 以加速训练和推理（需安装对应的 CUDA 驱动）。\n*   **依赖库**:\n    *   PyTorch (最新版)\n    *   torchvision\n    *   tqdm, PIL, numpy, scipy 等常用科学计算库。\n\n> **国内加速建议**：\n> 安装 PyTorch 时，推荐使用清华或中科大镜像源以提升下载速度：\n> ```bash\n> pip install torch torchvision torchaudio --index-url https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n> ```\n\n## 安装步骤\n\n1.  **克隆仓库**\n    从 GitHub 获取源代码：\n    ```bash\n    git clone https:\u002F\u002Fgithub.com\u002Farpitbansal97\u002FCold-Diffusion-Models.git\n    cd Cold-Diffusion-Models\n    ```\n\n2.  **安装 Python 依赖**\n    项目根目录下通常包含 `requirements.txt`（若不存在，请根据代码导入手动安装核心库）。执行以下命令安装依赖：\n    ```bash\n    pip install -r requirements.txt\n    ```\n    *注：若缺少 `requirements.txt`，请至少确保安装了 `torch`, `torchvision`, `tqdm`, `pillow`, `numpy`。*\n\n3.  **数据集准备**\n    使用提供的脚本处理数据集。对于 MNIST 和 CIFAR-10 可直接处理，CelebA 需指定路径，AFHQ 无需预处理。\n    ```bash\n    # 示例：处理 MNIST 或 CIFAR-10\n    python create_data.py --dataset mnist --data_path .\u002Fdata\u002Fmnist\n    # 对于 CelebA，需提前下载并解压，然后指定路径\n    ```\n\n## 基本使用\n\nCold Diffusion 支持多种退化类型（如高斯模糊、Animorphosis、图像修复等）。以下以**高斯模糊去模糊（Conditional Generation）**为例，展示最简训练与测试流程。\n\n### 1. 训练模型 (Training)\n\n以 MNIST 数据集为例，训练一个逆转高斯模糊的 Cold Diffusion 模型：\n\n```bash\npython mnist_train.py \\\n  --time_steps 20 \\\n  --blur_size 11 \\\n  --blur_std 7.0 \\\n  --blur_routine 'Constant' \\\n  --sampling_routine x0_step_down \\\n  --data_path .\u002Fdata\u002Fmnist \\\n  --save_folder .\u002Fmodels\u002Fmnist_blur\n```\n\n**参数说明：**\n*   `--time_steps`: 扩散步数。\n*   `--blur_size` \u002F `--blur_std`: 定义高斯模糊核的大小和标准差。\n*   `--blur_routine`: 退化调度策略（如 'Constant', 'Exponential' 等）。\n*   `--sampling_routine`: 采样算法，推荐使用 `x0_step_down` (论文算法 2)。\n\n### 2. 测试\u002F推理 (Testing)\n\n使用训练好的模型对测试数据进行去模糊还原：\n\n```bash\npython mnist_test.py \\\n  --time_steps 20 \\\n  --blur_size 11 \\\n  --blur_std 7.0 \\\n  --blur_routine 'Constant' \\\n  --sampling_routine 'x0_step_down' \\\n  --save_folder .\u002Fresults\u002Fmnist_blur \\\n  --data_path .\u002Fdata\u002Fmnist \\\n  --load_path .\u002Fmodels\u002Fmnist_blur \\\n  --test_type test_data\n```\n\n**注意：**\n*   测试时的 `--time_steps`、`--blur_size`、`--blur_std` 和 `--blur_routine` 必须与训练时保持一致。\n*   `--load_path` 指向训练保存的模型文件夹。\n*   生成结果将保存在 `--save_folder` 指定的目录中。\n\n### 其他任务简述\n*   **无条件生成 (Unconditional Generation)**: 参考 README 中 `celebA_128.py` 脚本，需增加 `--discrete` 参数并调整步数（如 300 步）。\n*   **图像形态转换 (Animorphosis)**: 使用 `demixing-diffusion-pytorch` 文件夹下的脚本，需指定起始和结束数据流形路径 (`--data_path_start`, `--data_path_end`)。\n*   **图像修复 (Inpainting)**: 使用 `defading-diffusion-pytorch` 文件夹，通过 `--kernel_std` 和 `--fade_routine` 控制掩膜退化过程。","一家数字档案修复团队正在处理一批因年代久远而严重模糊、褪色且覆盖雪花噪点的历史照片，急需将其还原为高清彩色原貌。\n\n### 没有 Cold-Diffusion-Models 时\n- **修复效果失真**：传统去噪模型（如 DDPM）必须人为添加高斯噪声作为中间步骤，导致还原过程引入虚假纹理，使人脸细节变得模糊或扭曲。\n- **变换类型受限**：现有工具通常只能针对单一退化类型（如仅去噪或仅超分），面对“模糊 + 褪色 + 雪花”的复合损伤时，需要串联多个模型，误差逐级累积。\n- **计算成本高昂**：为了逼近真实分布，往往需要数百次迭代采样，处理单张高分辨率老照片耗时极长，难以满足批量修复需求。\n- **缺乏可控性**：无法精确逆向特定的图像变换（如特定的模糊核或遮罩），还原结果具有较大的随机性，难以保证文物修复的严谨性。\n\n### 使用 Cold-Diffusion-Models 后\n- **无损逆向还原**：Cold-Diffusion-Models 直接学习逆向任意图像变换（如高斯模糊、去色、雪花遮挡），无需添加破坏性噪声，完美保留原始照片的微观纹理。\n- **统一处理复合损伤**：一套模型即可同时处理模糊、分辨率下采样及色彩丢失等多种退化情况，直接输出高质量复原图，避免了多模型串联的误差。\n- **高效采样生成**：利用其特有的采样算法（如 `x0_step_down`），在更少的步数内即可收敛到清晰图像，大幅缩短单张照片的修复时间，提升批量处理效率。\n- **精准可控变换**：支持针对特定退化算子进行训练和推理，能够精确“撤销”已知的损坏模式，确保修复结果符合历史原貌，满足专业档案标准。\n\nCold-Diffusion-Models 通过摒弃传统的加噪机制，实现了对复杂图像退化的精准、高效且无损的逆向还原，彻底改变了低质量历史影像的修复范式。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Farpitbansal297_Cold-Diffusion-Models_8c0d3dd8.png","arpitbansal297","Arpit Bansal","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Farpitbansal297_be1abaea.jpg",null,"University of Maryland, College Park","College Park","arpitbansal297@gmail.com","https:\u002F\u002Farpitbansal297.github.io\u002F","https:\u002F\u002Fgithub.com\u002Farpitbansal297",[83,87],{"name":84,"color":85,"percentage":86},"Python","#3572A5",98.9,{"name":88,"color":89,"percentage":90},"Shell","#89e051",1.1,1122,82,"2026-04-06T16:34:18",4,"未说明","需要 NVIDIA GPU (基于 PyTorch 实现，具体型号和显存未说明，但训练 CelebA\u002FAFHQ 128x128 模型通常建议 8GB+ 显存)",{"notes":98,"python":95,"dependencies":99},"该工具是基于 lucidrains 的 denoising-diffusion-pytorch 仓库开发的。支持多种图像退化任务（高斯模糊、Animorphosis、高斯掩码、分辨率下采样、图像雪景、颜色去饱和）。训练和测试脚本针对 MNIST、CIFAR-10、CelebA 和 AFHQ 数据集进行了区分。部分无条件生成测试需要拟合高斯混合模型 (GMM)。README 中未明确列出具体的 Python 版本、CUDA 版本或精确的显存需求，需参考底层 PyTorch 版本要求及所处理图像分辨率（如 128x128）来估算硬件资源。",[100,101,102,103,104,105],"torch","torchvision","Pillow","numpy","tqdm","matplotlib",[15],"2026-03-27T02:49:30.150509","2026-04-09T12:33:51.587832",[110,115,120,125],{"id":111,"question_zh":112,"answer_zh":113,"source_url":114},26249,"是否有预训练模型或检查点文件可供使用？","是的，维护者已将预训练模型上传至 Google Drive，并在项目的 README 文件中添加了下载链接。","https:\u002F\u002Fgithub.com\u002Farpitbansal297\u002FCold-Diffusion-Models\u002Fissues\u002F3",{"id":116,"question_zh":117,"answer_zh":118,"source_url":119},26250,"遇到 'GaussianDiffusion' 对象没有 'module' 属性的错误如何解决？","该错误通常与数据并行（Data Parallel）有关。在使用数据并行时，模型会被包裹在 `module` 中。解决方案是将代码修改为访问 `self.ema_model.module`（例如：`X_0s, X_ts = self.ema_model.module.all_sample(...)`），或者根据是否启用数据并行来动态处理属性访问。","https:\u002F\u002Fgithub.com\u002Farpitbansal297\u002FCold-Diffusion-Models\u002Fissues\u002F8",{"id":121,"question_zh":122,"answer_zh":123,"source_url":124},26251,"在哪里可以找到热扩散（去噪模型）与冷扩散的定量对比结果？","论文第 5 节（Section 5）中展示了噪声情况下的定量结果，其中包含了热扩散模型在相同设置下的表现数据。","https:\u002F\u002Fgithub.com\u002Farpitbansal297\u002FCold-Diffusion-Models\u002Fissues\u002F2",{"id":126,"question_zh":127,"answer_zh":128,"source_url":129},26252,"运行 Animorphosis 功能时，--data_path_start 和 --data_path_end 参数应分别指向什么文件夹？","根据参数命名惯例及形态变换任务的需求，`--data_path_start` 应放置起始域的图片（如原始图像），而 `--data_path_end` 应放置目标域的图片（即想要变换成的目标风格图像，如 Animorphosis 的目标图像）。用户需确保这两个路径分别对应变换过程的起点和终点数据集。","https:\u002F\u002Fgithub.com\u002Farpitbansal297\u002FCold-Diffusion-Models\u002Fissues\u002F6",[]]