yuanzhi-zhu / DiffPIR

"Denoising Diffusion Models for Plug-and-Play Image Restoration", Yuanzhi Zhu, Kai Zhang, Jingyun Liang, Jiezhang Cao, Bihan Wen, Radu Timofte, Luc Van Gool.
https://yuanzhi-zhu.github.io/DiffPIR/
MIT License
368 stars 31 forks source link

算法过程 #30

Open wattting opened 6 months ago

wattting commented 6 months ago

作者你好,我有一个问题,在用预训练好的无条件扩散模型进行有条件扩散的具体过程是如何控制逆扩散过程中的随机性,我们如何保证在采样过程中从XT的高斯噪声渐渐变成我想要的图像而不是随机图像。如果您有机会看到,请大佬帮我解解惑,十分感谢!

yuanzhi-zhu commented 6 months ago

条件就是guidance, 引导生成指向我们想要的方向。 我们的算法中有额外的一项对应data-subproblem保证生成的图像和条件LR图像的一致性。

wattting commented 6 months ago

十分感谢大佬的回复, 是不是算法过程中第四步:solving data proximal subproblem,作为数据一致项来保证第三步predict z和x的一致性,这个x是不是条件LR图像。 guidance引导生成具体是如何操作的,是不是通过guidance_scale来控制,大佬方便的话,可以具体告诉引导的具体代码在哪吗,还有第四步的一些代码步骤。再次感谢!

yuanzhi-zhu commented 6 months ago

y是condition,x和z是两个子问题要求接的变量. 你可以先看一下这个slides https://yuanzhi-zhu.github.io/documents/slides/diffusion_models_for_pnp_IR.pdf 和论文,可以对我们的算法有更加深入的理解。

wattting commented 6 months ago

好的,感谢大佬!

wattting commented 6 months ago

大佬您好,再看了你给的相关slides之后,我发现了我的问题有可能出现在第四步中进行Solving data proximal subproblem,关于||y - H(x)||和rho||x - x_0_t||,其中的x变量是什么? 是不是这个||y - H(x)||是不是就是一种传统模型方法来得到一个比较好的值,然后rho||x - x_0_t||,就是在使用扩散过程的去噪效果,从而生成更高质量的图像。不知道我的理解有没有错误。往大佬指教,非常感谢!!!

wattting commented 6 months ago

是不是第四步就是在求解一个最优的x的问题,x不是一个自变量,而是一个因变量

大佬您好,再看了你给的相关slides之后,我发现了我的问题有可能出现在第四步中进行Solving data proximal subproblem,关于||y - H(x)||和rho||x - x_0_t||,其中的x变量是什么? 是不是这个||y - H(x)||是不是就是一种传统模型方法来得到一个比较好的值,然后rho||x - x_0_t||,就是在使用扩散过程的去噪效果,从而生成更高质量的图像。不知道我的理解有没有错误。往大佬指教,非常感谢!!!

yuanzhi-zhu commented 6 months ago

在第三步中我们得到了一个很好的x_0的表示x_0_t, 第四步是优化整个data subproblem目标,找到一个x使得||y - H(x)|| + rho||x - x_0_t|| 这个objective尽可能低,也就是希望找到x同时接近y和x_0_t。 整个算法中y只出现在第四步里面,用来保证最终复原的图片和y接近。

wattting commented 6 months ago

懂了懂了,再次感谢大佬的帮助, 祝好!!!

wattting commented 6 months ago

大佬,我在实验时又碰到些问题,这第三步是如何取得一个较好的初值,按照第三步的方程,应该是做一个predicted x0,这个x0是用去噪器随机得到的一个,然后在第四步我用了admm去迭代优化,最后发现得不到想要约束的条件结果,可以说没有啥效果,没起到约束作用,这其中的问题是出在了哪里。因为我是做交叉方向的,也是解决一个逆问题,在我们方向,没有一个好的初值再去迭代优化是很难得到一个很好的结果。大佬能给我分析下嘛

发自我的 iPhone

在 2024年3月25日,16:59,Yuanzhi Zhu @.***> 写道:



在第三步中我们得到了一个很好的x_0的表示x_0_t, 第四步是优化整个data subproblem目标,找到一个x使得 ||y - H(x)|| + rho||x - x_0_t|| 这个objective尽可能低,也就是希望找到x同时接近y和x_0_t。 整个算法中y只出现在第四步里面,用来保证最终复原的图片和y接近。

— Reply to this email directly, view it on GitHubhttps://github.com/yuanzhi-zhu/DiffPIR/issues/30#issuecomment-2017504622, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AN4E4UX4WNQHNRHCTECEPB3YZ7RNHAVCNFSM6AAAAABE5PKHVWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJXGUYDINRSGI. You are receiving this because you authored the thread.Message ID: @.***>

yuanzhi-zhu commented 6 months ago

我不知道问题在哪里,这需要你自己研究🧐

wattting commented 6 months ago

好的,感谢大佬😁

发自我的 iPhone

在 2024年3月27日,18:42,Yuanzhi Zhu @.***> 写道:



我不知道问题在哪里,这需要你自己研究🧐

— Reply to this email directly, view it on GitHubhttps://github.com/yuanzhi-zhu/DiffPIR/issues/30#issuecomment-2022443955, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AN4E4URHOQFRQZT6EKXHS63Y2KH77AVCNFSM6AAAAABE5PKHVWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRSGQ2DGOJVGU. You are receiving this because you authored the thread.Message ID: @.***>

chagelo commented 2 months ago

Hello, I have a question that Solving data proximal subproblem correspond to which lines in your code.

yuanzhi-zhu commented 2 months ago

@chagelo just below this closed-form solution code block https://github.com/yuanzhi-zhu/DiffPIR/blob/111d26e8cf11965c1777a8a664b08dfa3ef78f1e/main_ddpir.py#L380-L382

chagelo commented 2 months ago

For deblur, I should know the blur kernel for each pair of images, right? My task is deblur, and I have paired images(clean and blurred image) without blur kernel. And I see solving data proximal subproblem utilize the blur kernel.

yuanzhi-zhu commented 2 months ago

For deblur, I should know the blur kernel for each pair of images, right? My task is deblur, and I have paired images(clean and blurred image) without blur kernel. And I see solving data proximal subproblem utilize the blur kernel.

for your setup, you can refer to https://arxiv.org/abs/2303.11435