[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-wyhuai--DDNM":3,"tool-wyhuai--DDNM":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":78,"owner_twitter":78,"owner_website":79,"owner_url":80,"languages":81,"stars":90,"forks":91,"last_commit_at":92,"license":93,"difficulty_score":10,"env_os":94,"env_gpu":95,"env_ram":96,"env_deps":97,"category_tags":106,"github_topics":107,"view_count":32,"oss_zip_url":78,"oss_zip_packed_at":78,"status":17,"created_at":113,"updated_at":114,"faqs":115,"releases":144},5866,"wyhuai\u002FDDNM","DDNM","[ICLR 2023 Oral] Zero-Shot Image Restoration Using Denoising Diffusion Null-Space Model","DDNM 是一款基于去噪扩散零空间模型的图像修复工具，曾荣获 ICLR 2023 口头报告奖。它的核心能力在于能够以“零样本”（Zero-Shot）方式处理各类图像退化问题，这意味着用户无需针对特定任务进行额外的模型训练或参数优化，即可直接获得高质量的修复结果。\n\nDDNM 有效解决了传统方法中针对不同修复任务需单独训练模型的痛点，实现了“一个模型通吃多种场景”。它支持超分辨率、去噪、上色、图像补全、去模糊以及压缩感知等多种任务，甚至能处理任意尺寸的图片和老照片修复。其独特的技术亮点在于巧妙利用了扩散模型的零空间特性，既保留了预训练模型强大的生成先验知识，又通过数学推导确保修复后的图像严格符合观测数据的约束，从而在细节还原和真实性之间取得了极佳平衡。\n\n这款工具非常适合计算机视觉研究人员探索扩散模型的新应用，也适合开发者快速集成图像修复功能到现有系统中。对于设计师或摄影爱好者而言，借助其提供的 Colab 演示和 Hugging Face 空间，无需深厚的编程背景也能轻松体验先进的 AI 修复技术，让受损或低质量的图片重焕生机。","# Zero-Shot Image Restoration Using Denoising Diffusion Null-Space Model\n## 📖[**Paper**](https:\u002F\u002Farxiv.org\u002Fpdf\u002F2212.00490.pdf)|🖼️[**Project Page**](https:\u002F\u002Fwyhuai.github.io\u002Fddnm.io\u002F)| \u003Ca href=\"https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1SRSD6GXGqU0eO2CoTNY-2WykB9qRZHJv?usp=sharing\">\u003Cimg src=\"https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg\" alt=\"google colab logo\">\u003C\u002Fa> [![Hugging Face Spaces](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fhysts\u002FDDNM-HQ)\n\n[Yinhuai Wang*](https:\u002F\u002Fwyhuai.github.io\u002Finfo\u002F), [Jiwen Yu*](https:\u002F\u002Fscholar.google.com.hk\u002Fcitations?user=uoRPLHIAAAAJ), [Jian Zhang](https:\u002F\u002Fjianzhang.tech\u002F)  \nPeking University and PCL  \n\\*denotes equal contribution\n\n\n\nThis repository contains the code release for *Zero-Shot Image Restoration Using ***D***enoising ***D***iffusion ***N***ull-Space ***M***odel*. **DDNM** can solve various image restoration tasks **without any optimization or training! Yes, in a zero-shot manner**.\n\n\n***Supported Applications:***\n- **Arbitrary Size**🆕\n- **Old Photo Restoration**🆕\n- Super-Resolution\n- Denoising\n- Colorization\n- Inpainting\n- Deblurring\n- Compressed Sensing\n\n\n![front](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fwyhuai_DDNM_readme_a97b83cef1e9.jpg)\n\n\n\n## 🧩News\n- A Colab demo for high-quality results is now avaliable! \u003Ca href=\"https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1SRSD6GXGqU0eO2CoTNY-2WykB9qRZHJv?usp=sharing\">\u003Cimg src=\"https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg\" alt=\"google colab logo\">\u003C\u002Fa>\n\n## Installation\n### Code\n```\ngit clone https:\u002F\u002Fgithub.com\u002Fwyhuai\u002FDDNM.git\n```\n### Environment\n```\npip install numpy torch blobfile tqdm pyYaml pillow    # e.g. torch 1.7.1+cu110.\n```\n### Pre-Trained Models\nTo restore human face images, download this [model](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1wSoA5fm_d6JBZk4RZ1SzWLMgev4WqH21\u002Fview?usp=share_link)(from [SDEdit](https:\u002F\u002Fgithub.com\u002Fermongroup\u002FSDEdit)) and put it into `DDNM\u002Fexp\u002Flogs\u002Fceleba\u002F`. \n```\nhttps:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1wSoA5fm_d6JBZk4RZ1SzWLMgev4WqH21\u002Fview?usp=share_link\n```\nTo restore general images, download this [model](https:\u002F\u002Fopenaipublic.blob.core.windows.net\u002Fdiffusion\u002Fjul-2021\u002F256x256_diffusion_uncond.pt)(from [guided-diffusion](https:\u002F\u002Fgithub.com\u002Fopenai\u002Fguided-diffusion)) and put it into `DDNM\u002Fexp\u002Flogs\u002Fimagenet\u002F`.\n```\nwget https:\u002F\u002Fopenaipublic.blob.core.windows.net\u002Fdiffusion\u002Fjul-2021\u002F256x256_diffusion_uncond.pt\n```\n### Quick Start\nRun below command to get 4x SR results immediately. The results should be in `DDNM\u002Fexp\u002Fimage_samples\u002Fdemo`.\n```\npython main.py --ni --simplified --config celeba_hq.yml --path_y celeba_hq --eta 0.85 --deg \"sr_averagepooling\" --deg_scale 4.0 --sigma_y 0 -i demo\n```\n\n## Setting\nThe detailed sampling command is here:\n```\npython main.py --ni --simplified --config {CONFIG}.yml --path_y {PATH_Y} --eta {ETA} --deg {DEGRADATION} --deg_scale {DEGRADATION_SCALE} --sigma_y {SIGMA_Y} -i {IMAGE_FOLDER}\n```\nwith following options:\n- We implement **TWO** versions of DDNM in this repository. One is SVD-based version, which is more precise in solving noisy tasks. Another one is the simplified version, which does not involve SVD and is flexible for users to define their own degradations. Use `--simplified` to activate the simplified DDNM. Without `--simplified` will turn to the SVD-based DDNM.\n- `PATH_Y` is the folder name of the test dataset, in `DDNM\u002Fexp\u002Fdatasets`.\n- `ETA` is the DDIM hyperparameter. (default: `0.85`)\n- `DEGREDATION` is the supported tasks including `cs_walshhadamard`, `cs_blockbased`, `inpainting`, `denoising`, `deblur_uni`, `deblur_gauss`, `deblur_aniso`, `sr_averagepooling`,`sr_bicubic`, `colorization`, `mask_color_sr`, and user-defined `diy`.\n- `DEGRADATION_SCALE` is the scale of degredation. e.g., `--deg sr_bicubic --deg_scale 4` lead to 4xSR.\n- `SIGMA_Y` is the noise observed in y.\n- `CONFIG` is the name of the config file (see `configs\u002F` for a list), including hyperparameters such as batch size and sampling step.\n- `IMAGE_FOLDER` is the folder name of the results.\n\nFor the config files, e.g., celeba_hq.yml, you may change following properties:\n```\nsampling:\n    batch_size: 1\n    \ntime_travel:\n    T_sampling: 100     # sampling steps\n    travel_length: 1    # time-travel parameters l and s, see section 3.3 of the paper.\n    travel_repeat: 1    # time-travel parameter r, see section 3.3 of the paper.\n```\n\n## Reproduce The Results In The Paper\n### Quantitative Evaluation\nDataset download link: [[Google drive](https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1cSCTaBtnL7OIKXT4SVME88Vtk4uDd_u4?usp=sharing)] [[Baidu drive](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1tQaWBqIhE671v3rrB-Z2mQ?pwd=twq0)]\n\nDownload the CelebA testset and put it into `DDNM\u002Fexp\u002Fdatasets\u002Fceleba\u002F`.\n\nDownload the ImageNet testset and put it into `DDNM\u002Fexp\u002Fdatasets\u002Fimagenet\u002F` and replace the file `DDNM\u002Fexp\u002Fimagenet_val_1k.txt`.\n\nRun the following command. You may increase the batch_size to accelerate evaluation.\n```\nsh evaluation.sh\n```\n\n### High-Quality Results\nYou can try this [**Colab demo**](https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1SRSD6GXGqU0eO2CoTNY-2WykB9qRZHJv?usp=sharing) for High-Quality results. Note that the High-Quality results presented in the front figure are mostly generated by applying DDNM to the models in [RePaint](https:\u002F\u002Fgithub.com\u002Fandreas128\u002FRePaint).\n\n## 🔥Real-World Applications\n### Demo: Real-World Super-Resolution.\n![orig_62](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fwyhuai_DDNM_readme_07d01740cd54.png)\n![00000](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fwyhuai_DDNM_readme_0a5b0fcda07e.png)\n\nRun the following command\n```\npython main.py --ni --simplified --config celeba_hq.yml --path_y solvay --eta 0.85 --deg \"sr_averagepooling\" --deg_scale 4.0 --sigma_y 0.1 -i demo\n```\n### Demo: Old Photo Restoration.\n![image](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fwyhuai_DDNM_readme_be095007e42d.png)\n![image](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fwyhuai_DDNM_readme_57ac380e861b.png)\n\nRun the following command\n```\npython main.py --ni --simplified --config oldphoto.yml --path_y oldphoto --eta 0.85 --deg \"mask_color_sr\" --deg_scale 2.0 --sigma_y 0.02 -i demo\n```\n### Try your own photos.\nYou may use DDNM to restore your own degraded images. DDNM provides full flexibility for you to define the degradation operator and the noise level. Note that these definitions are critical for a good results. You may reference the following guidance.\n1. If you are using CelebA pretrained models, try the tool in [GFPGAN](https:\u002F\u002Fgithub.com\u002FTencentARC\u002FGFPGAN) to crop and align your photo.\n2. If there are local artifacts on your photo, try the tool in [LaMa](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fadvimman\u002Flama\u002Fblob\u002Fmaster\u002Fcolab\u002FLaMa_inpainting.ipynb#scrollTo=-VZWySTMeGDM) to draw a mask to cover them, and save this mask to `DDNM\u002Fexp\u002Finp_masks\u002Fmask.png`. Then run `DDNM\u002Fexp\u002Finp_masks\u002Fget_mask.py` to generate `mask.npy`.\n3. If your photo is faded, you need a grayscale operator as part of the degradation.\n4. If your photo is blur, you need a downsampler operator as part of the degradation. Also, you need to set a proper SR scale `--deg_scale`.\n5. If your photo suffers global artifacts, e.g., jpeg-like artifacts or unkown noise, you need to set a proper `sigma_y` to remove these artifacts.\n6. Search `args.deg =='diy'` in `DDNM\u002Fguided_diffusion\u002Fdiffusion.py` and change the definition of $\\mathbf{A}$ correspondingly.\nThen run\n```\npython main.py --ni --simplified --config celeba_hq.yml --path_y {YOUR_OWN_PATH} --eta 0.85 --deg \"diy\" --deg_scale {YOUR_OWN_SCALE} --sigma_y {YOUR_OWN_LEVEL} -i diy\n```\n\n## 🆕DDNM for Arbitrary Size\n![123456](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fwyhuai_DDNM_readme_bf2722564509.png)![image](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fwyhuai_DDNM_readme_6c2851deed26.png)\n\nAbove we show an example of using DDNM to SR a 64x256 input image into a 256x1024 result. The theory details can be found in this [paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F2303.00354), section 3.3.\n\nWe implement the **Mask-Shift Restoration** in the folder `hq_demo`, based on [RePaint](https:\u002F\u002Fgithub.com\u002Fandreas128\u002FRePaint). You can try this [**Colab demo**](https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1SRSD6GXGqU0eO2CoTNY-2WykB9qRZHJv?usp=sharing). \u003Ca href=\"https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1SRSD6GXGqU0eO2CoTNY-2WykB9qRZHJv?usp=sharing\">\u003Cimg src=\"https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg\" alt=\"google colab logo\">\u003C\u002Fa>\n\nOr, you can try this function on your own device, you need to download the pre-trained models:\n```\nwget https:\u002F\u002Fopenaipublic.blob.core.windows.net\u002Fdiffusion\u002Fjul-2021\u002F256x256_classifier.pt\nwget https:\u002F\u002Fopenaipublic.blob.core.windows.net\u002Fdiffusion\u002Fjul-2021\u002F256x256_diffusion.pt\n```\nand put it to `hq_demo\u002Fdata\u002Fpretrained`. Then run\n```\ncd hq_demo\nsh evaluation.sh\n```\nThis script contains SR results up to **2K** resolution. It may take hours to finish some demos in this script. Setting a smaller sampling step or time-travel parameters in hq_demo\u002Fconfs\u002Finet256.yml can speed up, but may compromise the generative quality.\n\n\n\n## 😊Applying DDNM to Your Own Diffusion Model\nIt is ***very easy*** to implement a basic DDNM on your own diffusion model! You may reference the following:\n1. Copy these operator implementations to the core diffusion sampling file, then define your task type, e.g., set `IR_mode=\"super resolution\"`.\n```python\ndef color2gray(x):\n    coef=1\u002F3\n    x = x[:,0,:,:] * coef + x[:,1,:,:]*coef +  x[:,2,:,:]*coef\n    return x.repeat(1,3,1,1)\n\ndef gray2color(x):\n    x = x[:,0,:,:]\n    coef=1\u002F3\n    base = coef**2 + coef**2 + coef**2\n    return th.stack((x*coef\u002Fbase, x*coef\u002Fbase, x*coef\u002Fbase), 1)    \n    \ndef PatchUpsample(x, scale):\n    n, c, h, w = x.shape\n    x = torch.zeros(n,c,h,scale,w,scale) + x.view(n,c,h,1,w,1)\n    return x.view(n,c,scale*h,scale*w)\n\n# Implementation of A and its pseudo-inverse Ap    \n    \nif IR_mode==\"colorization\":\n    A = color2gray\n    Ap = gray2color\n    \nelif IR_mode==\"inpainting\":\n    A = lambda z: z*mask\n    Ap = A\n      \nelif IR_mode==\"super resolution\":\n    A = torch.nn.AdaptiveAvgPool2d((256\u002F\u002Fscale,256\u002F\u002Fscale))\n    Ap = lambda z: PatchUpsample(z, scale)\n\nelif IR_mode==\"old photo restoration\":\n    A1 = lambda z: z*mask\n    A1p = A1\n    \n    A2 = color2gray\n    A2p = gray2color\n    \n    A3 = torch.nn.AdaptiveAvgPool2d((256\u002F\u002Fscale,256\u002F\u002Fscale))\n    A3p = lambda z: PatchUpsample(z, scale)\n    \n    A = lambda z: A3(A2(A1(z)))\n    Ap = lambda z: A1p(A2p(A3p(z)))\n```\n2. Find the variant $\\mathbf{x}\\_{0|t}$ in the target codes, and use the result of this function to modify the sampling of $\\mathbf{x}\\_{t-1}$. Your may need to provide the input degraded image $\\mathbf{y}$ and the corresponding noise level $\\sigma_\\mathbf{y}$.\n```python\n# Core Implementation of DDNM+, simplified denoising solution (Section 3.3).\n# For more accurate denoising, please refer to the paper (Appendix I) and the source code.\n\ndef ddnm_plus_core(x0t, y, sigma_y=0, sigma_t, a_t):\n\n    #Eq 19\n    if sigma_t >= a_t*sigma_y: \n        lambda_t = 1\n        gamma_t = sigma_t**2 - (a_t*lambda_t*sigma_y)**2\n    else:\n        lambda_t = sigma_t\u002F(a_t*sigma_y)\n        gamma_t = 0\n        \n    #Eq 17    \n    x0t= x0t + lambda_t*Ap(y - A(x0t))\n    \n    return x0t, gamma_t\n```\n3. Actually, this repository contains the above simplified implementation: try search `arg.simplified` in `DDNM\u002Fguided_diffusion\u002Fdiffusion.py` for related codes. \n\n# References\nIf you find this repository useful for your research, please cite the following work.\n```\n@article{wang2022zero,\n  title={Zero-Shot Image Restoration Using Denoising Diffusion Null-Space Model},\n  author={Wang, Yinhuai and Yu, Jiwen and Zhang, Jian},\n  journal={The Eleventh International Conference on Learning Representations},\n  year={2023}\n}\n```\nThis implementation is based on \u002F inspired by:\n- https:\u002F\u002Fgithub.com\u002Fwyhuai\u002FRND (null-space learning)\n- https:\u002F\u002Fgithub.com\u002Fandreas128\u002FRePaint (time-travel trick)\n- https:\u002F\u002Fgithub.com\u002Fbahjat-kawar\u002Fddrm (code structure)\n","# 使用去噪扩散零空间模型的零样本图像修复\n## 📖[**论文**](https:\u002F\u002Farxiv.org\u002Fpdf\u002F2212.00490.pdf)|🖼️[**项目页面**](https:\u002F\u002Fwyhuai.github.io\u002Fddnm.io\u002F)| \u003Ca href=\"https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1SRSD6GXGqU0eO2CoTNY-2WykB9qRZHJv?usp=sharing\">\u003Cimg src=\"https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg\" alt=\"google colab logo\">\u003C\u002Fa> [![Hugging Face Spaces](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fhysts\u002FDDNM-HQ)\n\n[Yinhuai Wang*](https:\u002F\u002Fwyhuai.github.io\u002Finfo\u002F)、[Jiwen Yu*](https:\u002F\u002Fscholar.google.com.hk\u002Fcitations?user=uoRPLHIAAAAJ)、[Jian Zhang](https:\u002F\u002Fjianzhang.tech\u002F)  \n北京大学与PCL  \n\\*表示共同贡献\n\n\n\n本仓库包含“使用***D***enoising ***D***iffusion ***N***ull-Space ***M***odel进行零样本图像修复”的代码发布。**DDNM**可以在**无需任何优化或训练的情况下**解决各种图像修复任务！是的，以零样本的方式即可实现。\n\n\n***支持的应用：***\n- **任意尺寸**🆕\n- **老照片修复**🆕\n- 超分辨率\n- 去噪\n- 上色\n- 修复缺失区域\n- 去模糊\n- 压缩感知\n\n\n![front](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fwyhuai_DDNM_readme_a97b83cef1e9.jpg)\n\n\n\n## 🧩新闻\n- 现已提供高质量结果的Colab演示！\u003Ca href=\"https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1SRSD6GXGqU0eO2CoTNY-2WykB9qRZHJv?usp=sharing\">\u003Cimg src=\"https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg\" alt=\"google colab logo\">\u003C\u002Fa>\n\n## 安装\n### 代码\n```\ngit clone https:\u002F\u002Fgithub.com\u002Fwyhuai\u002FDDNM.git\n```\n### 环境\n```\npip install numpy torch blobfile tqdm pyYaml pillow    # 例如torch 1.7.1+cu110。\n```\n### 预训练模型\n要修复人脸图像，请下载此[模型](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1wSoA5fm_d6JBZk4RZ1SzWLMgev4WqH21\u002Fview?usp=share_link)(来自[SDEdit](https:\u002F\u002Fgithub.com\u002Fermongroup\u002FSDEdit))并将其放入`DDNM\u002Fexp\u002Flogs\u002Fceleba\u002F`。\n```\nhttps:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1wSoA5fm_d6JBZk4RZ1SzWLMgev4WqH21\u002Fview?usp=share_link\n```\n要修复一般图像，请下载此[模型](https:\u002F\u002Fopenaipublic.blob.core.windows.net\u002Fdiffusion\u002Fjul-2021\u002F256x256_diffusion_uncond.pt)(来自[guided-diffusion](https:\u002F\u002Fgithub.com\u002Fopenai\u002Fguided-diffusion))并将其放入`DDNM\u002Fexp\u002Flogs\u002Fimagenet\u002F`。\n```\nwget https:\u002F\u002Fopenaipublic.blob.core.windows.net\u002Fdiffusion\u002Fjul-2021\u002F256x256_diffusion_uncond.pt\n```\n### 快速入门\n运行以下命令可立即获得4倍超分辨率结果。结果应位于`DDNM\u002Fexp\u002Fimage_samples\u002Fdemo`。\n```\npython main.py --ni --simplified --config celeba_hq.yml --path_y celeba_hq --eta 0.85 --deg \"sr_averagepooling\" --deg_scale 4.0 --sigma_y 0 -i demo\n```\n\n## 设置\n详细的采样命令如下：\n```\npython main.py --ni --simplified --config {CONFIG}.yml --path_y {PATH_Y} --eta {ETA} --deg {DEGRADATION} --deg_scale {DEGRADATION_SCALE} --sigma_y {SIGMA_Y} -i {IMAGE_FOLDER}\n```\n选项说明如下：\n- 本仓库实现了**两种**版本的DDNM。一种基于SVD的版本，在处理噪声任务时更为精确。另一种是简化版，不涉及SVD，用户可以灵活定义自己的退化类型。使用`--simplified`可激活简化版DDNM。若不加`--simplified`则为基于SVD的DDNM。\n- `PATH_Y`是测试数据集的文件夹名称，位于`DDNM\u002Fexp\u002Fdatasets`。\n- `ETA`是DDIM的超参数。（默认值：`0.85`）\n- `DEGREDATION`是支持的任务，包括`cs_walshhadamard`、`cs_blockbased`、`inpainting`、`denoising`、`deblur_uni`、`deblur_gauss`、`deblur_aniso`、`sr_averagepooling`、`sr_bicubic`、`colorization`、`mask_color_sr`以及用户自定义的`diy`。\n- `DEGRADATION_SCALE`是退化的尺度。例如，`--deg sr_bicubic --deg_scale 4`将产生4倍超分辨率效果。\n- `SIGMA_Y`是观测到的噪声水平。\n- `CONFIG`是配置文件的名称（详见`configs\u002F`目录），其中包含批量大小和采样步数等超参数。\n- `IMAGE_FOLDER`是保存结果的文件夹名称。\n\n对于配置文件，例如`celeba_hq.yml`，您可以修改以下属性：\n```\nsampling:\n    batch_size: 1\n    \ntime_travel:\n    T_sampling: 100     # 采样步数\n    travel_length: 1    # 时间旅行参数l和s，参见论文第3.3节。\n    travel_repeat: 1    # 时间旅行参数r，参见论文第3.3节。\n```\n\n## 复现论文中的结果\n### 定量评估\n数据集下载链接：[[Google云端硬盘](https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1cSCTaBtnL7OIKXT4SVME88Vtk4uDd_u4?usp=sharing)] [[百度网盘](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1tQaWBqIhE671v3rrB-Z2mQ?pwd=twq0)]\n\n下载CelebA测试集并将其放入`DDNM\u002Fexp\u002Fdatasets\u002Fceleba\u002F`。\n\n下载ImageNet测试集并将其放入`DDNM\u002Fexp\u002Fdatasets\u002Fimagenet\u002F`，同时替换文件`DDNM\u002Fexp\u002Fimagenet_val_1k.txt`。\n\n运行以下命令。您可以通过增加`batch_size`来加快评估速度。\n```\nsh evaluation.sh\n```\n\n### 高质量结果\n您可以尝试这个[**Colab演示**](https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1SRSD6GXGqU0eO2CoTNY-2WykB9qRZHJv?usp=sharing)来获得高质量结果。请注意，首页图中展示的高质量结果大多是由将DDNM应用于[RePaint](https:\u002F\u002Fgithub.com\u002Fandreas128\u002FRePaint)中的模型生成的。\n\n## 🔥真实世界应用\n### 演示：真实世界的超分辨率。\n![orig_62](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fwyhuai_DDNM_readme_07d01740cd54.png)\n![00000](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fwyhuai_DDNM_readme_0a5b0fcda07e.png)\n\n运行以下命令\n```\npython main.py --ni --simplified --config celeba_hq.yml --path_y solvay --eta 0.85 --deg \"sr_averagepooling\" --deg_scale 4.0 --sigma_y 0.1 -i demo\n```\n### 演示：老照片修复。\n![image](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fwyhuai_DDNM_readme_be095007e42d.png)\n![image](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fwyhuai_DDNM_readme_57ac380e861b.png)\n\n运行以下命令\n```\npython main.py --ni --simplified --config oldphoto.yml --path_y oldphoto --eta 0.85 --deg \"mask_color_sr\" --deg_scale 2.0 --sigma_y 0.02 -i demo\n```\n\n### 尝试你自己的照片。\n你可以使用 DDNM 来恢复你自己退化的图像。DDNM 为你提供了完全的灵活性，可以自定义退化算子和噪声水平。请注意，这些定义对获得良好的结果至关重要。你可以参考以下指导：\n1. 如果你使用的是 CelebA 预训练模型，可以尝试使用 [GFPGAN](https:\u002F\u002Fgithub.com\u002FTencentARC\u002FGFPGAN) 中的工具来裁剪和对齐你的照片。\n2. 如果你的照片上有局部伪影，可以尝试使用 [LaMa](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fadvimman\u002Flama\u002Fblob\u002Fmaster\u002Fcolab\u002FLaMa_inpainting.ipynb#scrollTo=-VZWySTMeGDM) 中的工具绘制遮罩来覆盖这些伪影，并将此遮罩保存到 `DDNM\u002Fexp\u002Finp_masks\u002Fmask.png`。然后运行 `DDNM\u002Fexp\u002Finp_masks\u002Fget_mask.py` 生成 `mask.npy`。\n3. 如果你的照片褪色了，你需要一个灰度算子作为退化的一部分。\n4. 如果你的照片模糊，你需要一个下采样算子作为退化的一部分。同时，还需要设置合适的超分辨率缩放比例 `--deg_scale`。\n5. 如果你的照片存在全局性的伪影，例如类似 JPEG 的伪影或未知噪声，你需要设置合适的 `sigma_y` 来去除这些伪影。\n6. 在 `DDNM\u002Fguided_diffusion\u002Fdiffusion.py` 中搜索 `args.deg =='diy'`，并相应地修改 $\\mathbf{A}$ 的定义。\n然后运行：\n```\npython main.py --ni --simplified --config celeba_hq.yml --path_y {YOUR_OWN_PATH} --eta 0.85 --deg \"diy\" --deg_scale {YOUR_OWN_SCALE} --sigma_y {YOUR_OWN_LEVEL} -i diy\n```\n\n## 🆕DDNM 适用于任意尺寸\n![123456](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fwyhuai_DDNM_readme_bf2722564509.png)![image](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fwyhuai_DDNM_readme_6c2851deed26.png)\n\n以上展示了使用 DDNM 将 64x256 输入图像超分辨率至 256x1024 结果的示例。相关理论细节可在该 [论文](https:\u002F\u002Farxiv.org\u002Fabs\u002F2303.00354) 的第 3.3 节中找到。\n\n我们在文件夹 `hq_demo` 中实现了基于 [RePaint](https:\u002F\u002Fgithub.com\u002Fandreas128\u002FRePaint) 的 **掩码移位修复** 功能。你可以尝试这个 [Colab 演示](https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1SRSD6GXGqU0eO2CoTNY-2WykB9qRZHJv?usp=sharing)。\u003Ca href=\"https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1SRSD6GXGqU0eO2CoTNY-2WykB9qRZHJv?usp=sharing\">\u003Cimg src=\"https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg\" alt=\"google colab logo\">\u003C\u002Fa>\n\n或者，你也可以在自己的设备上尝试该功能，需要下载预训练模型：\n```\nwget https:\u002F\u002Fopenaipublic.blob.core.windows.net\u002Fdiffusion\u002Fjul-2021\u002F256x256_classifier.pt\nwget https:\u002F\u002Fopenaipublic.blob.core.windows.net\u002Fdiffusion\u002Fjul-2021\u002F256x256_diffusion.pt\n```\n并将它们放入 `hq_demo\u002Fdata\u002Fpretrained` 目录。然后运行：\n```\ncd hq_demo\nsh evaluation.sh\n```\n该脚本包含了最高可达 **2K** 分辨率的超分辨率结果。某些演示可能需要数小时才能完成。通过在 `hq_demo\u002Fconfs\u002Finet256.yml` 中设置较小的采样步长或时间旅行参数，可以加快速度，但可能会降低生成质量。\n\n\n\n## 😊将 DDNM 应用于你自己的扩散模型\n在你自己的扩散模型上实现一个基础的 DDNM ***非常简单***！你可以参考以下步骤：\n1. 将这些算子实现复制到核心扩散采样文件中，然后定义你的任务类型，例如设置 `IR_mode=\"super resolution\"`。\n```python\ndef color2gray(x):\n    coef=1\u002F3\n    x = x[:,0,:,:] * coef + x[:,1,:,:]*coef +  x[:,2,:,:]*coef\n    return x.repeat(1,3,1,1)\n\ndef gray2color(x):\n    x = x[:,0,:,:]\n    coef=1\u002F3\n    base = coef**2 + coef**2 + coef**2\n    return th.stack((x*coef\u002Fbase, x*coef\u002Fbase, x*coef\u002Fbase), 1)    \n    \ndef PatchUpsample(x, scale):\n    n, c, h, w = x.shape\n    x = torch.zeros(n,c,h,scale,w,scale) + x.view(n,c,h,1,w,1)\n    return x.view(n,c,scale*h,scale*w)\n\n# A 及其伪逆 Ap 的实现\n    \nif IR_mode==\"colorization\":\n    A = color2gray\n    Ap = gray2color\n    \nelif IR_mode==\"inpainting\":\n    A = lambda z: z*mask\n    Ap = A\n      \nelif IR_mode==\"super resolution\":\n    A = torch.nn.AdaptiveAvgPool2d((256\u002F\u002Fscale,256\u002F\u002Fscale))\n    Ap = lambda z: PatchUpsample(z, scale)\n\nelif IR_mode==\"old photo restoration\":\n    A1 = lambda z: z*mask\n    A1p = A1\n    \n    A2 = color2gray\n    A2p = gray2color\n    \n    A3 = torch.nn.AdaptiveAvgPool2d((256\u002F\u002Fscale,256\u002F\u002Fscale))\n    A3p = lambda z: PatchUpsample(z, scale)\n    \n    A = lambda z: A3(A2(A1(z)))\n    Ap = lambda z: A1p(A2p(A3p(z)))\n```\n2. 在目标代码中找到变量 $\\mathbf{x}\\_{0|t}$，并使用该函数的结果来修改 $\\mathbf{x}\\_{t-1}$ 的采样过程。你可能需要提供输入的退化图像 $\\mathbf{y}$ 和对应的噪声水平 $\\sigma_\\mathbf{y}$。\n```python\n# DDNM+ 的核心实现，简化的去噪方案（第 3.3 节）。\n# 如需更精确的去噪，请参阅论文（附录 I）和源代码。\n\ndef ddnm_plus_core(x0t, y, sigma_y=0, sigma_t, a_t):\n\n    #式 19\n    if sigma_t >= a_t*sigma_y: \n        lambda_t = 1\n        gamma_t = sigma_t**2 - (a_t*lambda_t*sigma_y)**2\n    else:\n        lambda_t = sigma_t\u002F(a_t*sigma_y)\n        gamma_t = 0\n        \n    #式 17    \n    x0t= x0t + lambda_t*Ap(y - A(x0t))\n    \n    return x0t, gamma_t\n```\n3. 实际上，这个仓库就包含了上述简化实现：可以在 `DDNM\u002Fguided_diffusion\u002Fdiffusion.py` 中搜索 `arg.simplified` 查看相关代码。\n\n# 参考文献\n如果你觉得这个仓库对你的研究有帮助，请引用以下工作。\n```\n@article{wang2022zero,\n  title={Zero-Shot Image Restoration Using Denoising Diffusion Null-Space Model},\n  author={Wang, Yinhuai and Yu, Jiwen and Zhang, Jian},\n  journal={The Eleventh International Conference on Learning Representations},\n  year={2023}\n}\n```\n本实现基于或受以下项目启发：\n- https:\u002F\u002Fgithub.com\u002Fwyhuai\u002FRND（零空间学习）\n- https:\u002F\u002Fgithub.com\u002Fandreas128\u002FRePaint（时间旅行技巧）\n- https:\u002F\u002Fgithub.com\u002Fbahjat-kawar\u002Fddrm（代码结构）","# DDNM 快速上手指南\n\nDDNM (Denoising Diffusion Null-Space Model) 是一个基于去噪扩散模型的零样本图像修复工具。它无需任何微调或训练，即可解决超分辨率、去噪、上色、修复、去模糊等多种图像恢复任务。\n\n## 环境准备\n\n*   **系统要求**: Linux \u002F macOS \u002F Windows (推荐 Linux)\n*   **Python**: 3.6+\n*   **PyTorch**: 1.7.1+ (需包含 CUDA 支持，例如 `cu110`)\n*   **其他依赖**: numpy, blobfile, tqdm, pyYaml, pillow\n\n## 安装步骤\n\n### 1. 克隆代码库\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fwyhuai\u002FDDNM.git\ncd DDNM\n```\n\n### 2. 安装依赖\n建议使用国内镜像源加速安装：\n```bash\npip install numpy torch blobfile tqdm pyYaml pillow -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n# 注意：如果上述命令未安装指定版本的 torch，请根据官方文档单独安装对应 CUDA 版本的 torch\n# 例如：pip install torch==1.7.1+cu110 -f https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Ftorch_stable.html\n```\n\n### 3. 下载预训练模型\n根据需求下载对应的模型并放入指定目录：\n\n*   **人脸图像恢复 (CelebA)**:\n    下载 [模型文件](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1wSoA5fm_d6JBZk4RZ1SzWLMgev4WqH21\u002Fview?usp=share_link) 并存放至 `DDNM\u002Fexp\u002Flogs\u002Fceleba\u002F` 目录下。\n\n*   **通用图像恢复 (ImageNet)**:\n    ```bash\n    wget https:\u002F\u002Fopenaipublic.blob.core.windows.net\u002Fdiffusion\u002Fjul-2021\u002F256x256_diffusion_uncond.pt -P exp\u002Flogs\u002Fimagenet\u002F\n    ```\n    *(注：如果 wget 速度慢，可手动下载后放入 `DDNM\u002Fexp\u002Flogs\u002Fimagenet\u002F`)*\n\n## 基本使用\n\n以下命令演示如何立即运行一个 **4 倍超分辨率 (4x SR)** 任务。结果将保存在 `DDNM\u002Fexp\u002Fimage_samples\u002Fdemo` 目录中。\n\n```bash\npython main.py --ni --simplified --config celeba_hq.yml --path_y celeba_hq --eta 0.85 --deg \"sr_averagepooling\" --deg_scale 4.0 --sigma_y 0 -i demo\n```\n\n### 命令参数简析\n*   `--simplified`: 启用简化版 DDNM（无需 SVD 分解，更灵活）。\n*   `--config`: 配置文件名 (如 `celeba_hq.yml`, `oldphoto.yml`)。\n*   `--deg`: 退化类型，支持 `sr_averagepooling` (超分), `inpainting` (修复), `denoising` (去噪), `colorization` (上色), `deblur_uni` (去模糊) 等。\n*   `--deg_scale`: 退化尺度，例如超分倍数设为 `4.0`。\n*   `--sigma_y`: 观测噪声水平，无噪声设为 `0`。\n*   `-i`: 输出结果文件夹名称。\n\n### 更多应用场景示例\n\n**老照片修复:**\n```bash\npython main.py --ni --simplified --config oldphoto.yml --path_y oldphoto --eta 0.85 --deg \"mask_color_sr\" --deg_scale 2.0 --sigma_y 0.02 -i demo\n```\n\n**自定义图像修复:**\n将待处理图片放入 `exp\u002Fdatasets\u002F{YOUR_OWN_PATH}` 目录，然后运行：\n```bash\npython main.py --ni --simplified --config celeba_hq.yml --path_y {YOUR_OWN_PATH} --eta 0.85 --deg \"diy\" --deg_scale {YOUR_OWN_SCALE} --sigma_y {YOUR_OWN_LEVEL} -i diy\n```\n*(注：使用 `diy` 模式需在代码中自定义退化算子，详见原文档 \"Try your own photos\" 部分)*","一家小型数字档案馆正在紧急处理一批受损严重的百年老照片，需要在无原始高清图参考的情况下完成修复与上色。\n\n### 没有 DDNM 时\n- **训练成本高昂**：针对每种损坏类型（如划痕、噪点、褪色）需单独收集配对数据并训练专用模型，耗时数周且算力需求大。\n- **泛化能力受限**：遇到未见过的复杂退化组合（如同时存在模糊和彩色噪点）时，现有模型效果急剧下降，需重新调整网络结构。\n- **流程繁琐割裂**：去噪、超分、上色需串联多个独立工具，每一步的误差会累积，导致最终人脸细节失真或色彩怪异。\n- **尺寸适配困难**：传统模型通常固定输入分辨率，处理不同尺寸的老照片时需反复裁剪或缩放，破坏画面构图。\n\n### 使用 DDNM 后\n- **零样本即时修复**：利用预训练的扩散模型先验，无需任何微调或训练，直接通过命令行一键处理任意类型的图像退化。\n- **统一框架多任务**：单个模型即可同步完成去噪、4 倍超分辨率及自动上色，保持人物面部特征一致，避免多阶段处理的伪影。\n- **灵活适应未知退化**：基于零空间投影机制，能有效处理训练集中未出现的复杂混合损伤，显著提升老旧照片的自然度。\n- **任意尺寸支持**：原生支持任意分辨率输入，完整保留老照片的原始构图与边缘细节，无需预处理裁剪。\n\nDDNM 将原本需要数周建模优化的复杂修复流程，简化为单次推理的零样本任务，极大降低了历史影像数字化的技术门槛。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fwyhuai_DDNM_a97b83ce.jpg","wyhuai","Yinhuai Wang","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fwyhuai_4f122ada.jpg","CV \u002F Humanoid Manipulation","HKUST",null,"https:\u002F\u002Fwyhuai.github.io\u002Finfo\u002F","https:\u002F\u002Fgithub.com\u002Fwyhuai",[82,86],{"name":83,"color":84,"percentage":85},"Python","#3572A5",99.1,{"name":87,"color":88,"percentage":89},"Shell","#89e051",0.9,1334,104,"2026-04-02T04:16:37","MIT","Linux, macOS, Windows","需要 NVIDIA GPU (示例提及 cu110)，显存需求未明确说明 (建议 8GB+ 以运行高分辨率修复)","未说明",{"notes":98,"python":96,"dependencies":99},"1. 示例中提到的 PyTorch 版本为 1.7.1+cu110，表明需要 CUDA 支持。2. 首次运行前需手动下载预训练模型文件（如 CelebA 或 ImageNet 模型）并放置到指定目录。3. 提供简化版 (--simplified) 和基于 SVD 的版本，前者更灵活但后者在处理噪声任务时更精确。4. 支持任意尺寸图像修复的高清演示脚本运行时间可能长达数小时。5. 自定义退化操作需要修改源代码中的扩散采样文件。",[100,101,102,103,104,105],"numpy","torch","blobfile","tqdm","pyYaml","pillow",[15],[108,109,110,111,112],"diffusion-models","zero-shot","image-restoration","iclr","iclr2023","2026-03-27T02:49:30.150509","2026-04-09T20:54:34.395214",[116,121,125,130,135,140],{"id":117,"question_zh":118,"answer_zh":119,"source_url":120},26611,"如何在超分辨率任务中消除输出图像的模糊效果？","模糊效果主要是因为使用的预训练模型能力有限。您可以尝试以下解决方案：\n1. 使用基于 SVD 的版本（移除 --simplified 参数）：\n   python main.py --ni --config celeba_hq.yml --path_y celeba_hq --eta 0.85 --deg \"sr_averagepooling\" --deg_scale 8.0 --sigma_y 0 -i demo\n2. 修改配置文件中的 time_travel 参数。\n3. 参考 \"DDNM for Arbitrary Size\" 部分尝试高质量演示。\n4. 使用 Colab 演示获取高质量结果：https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1SRSD6GXGqU0eO2CoTNY-2WykB9qRZHJv?usp=sharing","https:\u002F\u002Fgithub.com\u002Fwyhuai\u002FDDNM\u002Fissues\u002F9",{"id":122,"question_zh":123,"answer_zh":124,"source_url":120},26612,"简化版（simplified）和基于 SVD 的版本在无噪声情况下的主要区别是什么？","是的，对于无噪声情况（公式 16 中 n=0），简化版与基于 SVD 版本的主要区别仅在于计算 A 逆矩阵（A-inverse）的方式不同。",{"id":126,"question_zh":127,"answer_zh":128,"source_url":129},26613,"如何使用 DDNM 进行图像上色（Colorization）任务？","不需要针对特定任务重新训练模型。您可以直接使用预训练的 ImageNet 模型并配合分类器引导来实现上色。运行命令如下：\npython main.py --ni --config imagenet_256.yml --path_y imagenet --eta 0.85 --deg \"colorization\" --sigma_y 0. -i imagenet_colorization\n建议尝试不同的随机种子以获得多样化的结果。目前官方仅提供超分辨率任务的完整演示，其他任务如上色需用户自行实现或等待后续更新。","https:\u002F\u002Fgithub.com\u002Fwyhuai\u002FDDNM\u002Fissues\u002F7",{"id":131,"question_zh":132,"answer_zh":133,"source_url":134},26614,"论文中提到的公式推导里，x_hat 和 x_bar 有什么区别？方差计算公式是否准确？","相关方程是一个简化版本，并不完全准确。方程左侧是简化后的方差，右侧是原始定义的方差。如果需要更准确的方差计算方法，请参考论文 \"Unlimited-Size Diffusion Restoration\" 的附录部分。","https:\u002F\u002Fgithub.com\u002Fwyhuai\u002FDDNM\u002Fissues\u002F38",{"id":136,"question_zh":137,"answer_zh":138,"source_url":139},26615,"在自定义数据集（如医学图像）上使用 DDNM 时，为什么重建结果存在大量噪声和块状效应？","如果在使用 HQ 代码时遇到质量问题和块状效应，而原始代码没有此问题，这通常是由于代码实现差异导致的。对于自定义模型（如基于 guided-diffusion 训练的模型），请确保正确加载模型和扩散配置。如果调整 sigma_y 参数无效，建议检查是否错误地使用了仅适用于特定预训练模型的 HQ 演示代码，尝试切换回原始代码库中的实现可能解决该问题。","https:\u002F\u002Fgithub.com\u002Fwyhuai\u002FDDNM\u002Fissues\u002F11",{"id":141,"question_zh":142,"answer_zh":143,"source_url":120},26616,"如何获得论文中展示的高质量（HQ）重建结果？","论文中展示的高质量结果主要是通过将 DDNM 应用于 RePaint 项目中的预训练 DDPM 模型生成的。目前官方已提供用于生成高质量结果的 Colab 演示，建议直接使用该演示来解决对高质量输出的需求，而不是仅依赖基础代码库中的默认模型。",[]]