Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

图像恢复任务的训练 #2

Closed
MrWan001 opened this issue Oct 19, 2023 · 68 comments
Closed

图像恢复任务的训练 #2

MrWan001 opened this issue Oct 19, 2023 · 68 comments

Comments

@MrWan001
Copy link

您好,想使用成对数据集进行图像恢复任务的训练,请问应该怎样设置数据集路径,训练指令需要修改吗(非常感谢)

@nachifur
Copy link
Owner

  1. 修改train.py
    image

train.py中,其他任务类似于42行(阴影去除,有mask输入)和49行(低光照增强,无mask输入)。

train.py中,35行-37行
阴影去除:
condition = True
input_condition = True
input_condition_mask = True

低光照:
condition = True
input_condition = False
input_condition_mask = False

  1. 修改src/residual_denoising_diffusion_pytorch.py

a. [self.alphas_cumsum[t]*self.num_timesteps, self.betas_cumsum[t]*self.num_timesteps]] -> [t,t] (in L852 and L1292).
b. modify the corresponding experimental settings (see Table 4 in the Appendix), e.g., Loss, Optimizer

@MrWan001
Copy link
Author

好的,非常感谢!

@MrWan001
Copy link
Author

MrWan001 commented Oct 22, 2023

作者您好,我在尝试复现低光照增强的实验,在修改附录中表4的参数时遇到以下问题:
牛蛙3
1、βT²在哪里设置,好像没有找到。
2、LOSS为残差损失+噪声损失在哪里设置,我看到一些if num_unet = 2 else语句,是设置了参数num_unet = 2,就自动对应是残差+噪声的损失类型了吗
3、论文中表述的是,对于图像恢复任务,使用残差+噪声损失,但附录表4中,低光照任务显示只使用残差损失,这是因为对于低光照任务,只预测残差,实验效果比两个都预测更好吗。
4、采样方法设置λres=1,λϵ=1,如何设置,没有找到对应的地方,是确定了num_unet = 2这个参数,loss和sampling method在源代码中就是对应设置好的吗
4、优化器的设置,恢复任务使用的是Adma,我参照residual_denoising_diffusion_pytorch.py中1467-1476行进行了修改,您看是这样改的吗,
牛蛙2

期待您的回复!非常感谢

@nachifur
Copy link
Owner

rddm是根据以下仓库进行修改的:https://github.com/lucidrains/denoising-diffusion-pytorch。

对于图像恢复任务,暂时需要可以根据目前已公开的代码,和上述原始代码自行修改。

  1. $\beta_T^2$对应sum_scale
  2. loss修改对应的p_losses(),和表4对应上即可
  3. 采样方法的修改,对应test_res_or_noise
  4. 目前的代码对应:SM-Res-N-2Net (见最新的arxiv). If computational resources are sufficient, two separate networks (num_unet = 2) can be trained for noise and residual predictions, and the optimal sampling method can be determined during testing.
  5. Adam优化器:self.opt = Adam(diffusion_model.parameters(), lr=train_lr, betas=adam_betas)

非常抱歉目前仅提供用于探索partially path-independent generation process的代码。为了更好的代码可读性,后续我们将逐步更新、重构代码,请关注该仓库。

@MrWan001
Copy link
Author

MrWan001 commented Nov 5, 2023

感谢之前的回复!已经跑通了图像修复的代码,并阅读了V2版本的论文,附录部分很丰富,关于残差和噪声解耦的研究感觉很有意义。
还有个问题是测试代码中的低光照部分,我看代码计算的是ycbcr空间y通道的指标,低光照任务目前普遍都是测这个指标而不是rgb的吗。

@nachifur nachifur mentioned this issue Nov 14, 2023
@nil0330
Copy link

nil0330 commented Nov 27, 2023

感谢之前的回复!已经跑通了图像修复的代码,并阅读了V2版本的论文,附录部分很丰富,关于残差和噪声解耦的研究感觉很有意义。 还有个问题是测试代码中的低光照部分,我看代码计算的是ycbcr空间y通道的指标,低光照任务目前普遍都是测这个指标而不是rgb的吗。

你好我也在复现这篇代码,但是数据集配置中
xxx/dataset/ISTD_Dataset_arg/data_val/ISTD_shadow_free_train.flist这个应该具体替换成什么能否举个例子,感谢和期待您的回答

@nachifur nachifur mentioned this issue Nov 27, 2023
@nachifur
Copy link
Owner

@nil0330 .flist是文件路径列表

@nil0330
Copy link

nil0330 commented Dec 3, 2023

感谢之前的回复!已经跑通了图像修复的代码,并阅读了V2版本的论文,附录部分很丰富,关于残差和噪声解耦的研究感觉很有意义。 还有个问题是测试代码中的低光照部分,我看代码计算的是ycbcr空间y通道的指标,低光照任务目前普遍都是测这个指标而不是rgb的吗。

你好我在复现时发现model_out的内容如下
image
请问您运行时也是同样的吗

@nachifur
Copy link
Owner

nachifur commented Dec 6, 2023

@nil0330 单unet是这样的(返回:一个为0,一个是噪声或残差图像)。

@shenyue0530
Copy link

作者,您好,请问去雨的话针对35-37行应该怎么修改呢,还有就是xxx/dataset/ISTD_Dataset_arg/data_val/ISTD_shadow_free_train.flist目录下是成对的图片么,因为降雨的数据集里的图片是成对的,所以这个目录下的数据集是“有雨和无雨”的图像对么

@nachifur
Copy link
Owner

@shenyue0530

condition = True # 生成(无条件输入)=False, 恢复(有条件输入)=True
input_condition = False # 额外的输入条件=Ture, 例如阴影去除任务重的mask
input_condition_mask = False # 如果额外的输入条件如果是mask时,为True

folder = ["xxx/dataset/ISTD_Dataset_arg/data_val/ISTD_shadow_free_train.flist", # 训练集的gt, 图片文件列表
"xxx/dataset/ISTD_Dataset_arg/data_val/ISTD_shadow_train.flist", # 训练集的输入, 图片文件列表
"xxx/dataset/ISTD_Dataset_arg/data_val/ISTD_shadow_free_test.flist", # 测试集的gt, 图片文件列表
"xxx/dataset/ISTD_Dataset_arg/data_val/ISTD_shadow_test.flist"] # 测试集的输入, 图片文件列表

@nil0330
Copy link

nil0330 commented Dec 11, 2023

作者你好,代码已经成功运起来我有一个疑问,代码产生的结果result/sample中会出现四个图片,他们分别代表的是什么?
image
如图:分别代表的是输入,gt,输出和残差嘛

@nachifur
Copy link
Owner

@nil0330 你可以修改和debug一下对应的代码,应该很容易修改输出的图像。

@JunningSu
Copy link

作者您好,我的研究领域不在CV上,但是看完您的工作十分感兴趣,但在复现时源码中并没有给出数据集,方便的话可以把数据集加在源码中吗?或者分享一个网盘链接,谢谢!

@nachifur
Copy link
Owner

nachifur commented Dec 13, 2023 via email

@GeroRoman
Copy link

您好,我是深度学习的初学者,我今天 在运行程序的时候出现这个报错,我不太清楚这个报错是什么意思RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.

    This probably means that you are not using fork to start your
    child processes and you have forgotten to use the proper idiom
    in the main module:

        if __name__ == '__main__':
            freeze_support()
            ...

    The "freeze_support()" line can be omitted if the program
    is not going to be frozen to produce an executable.请问能解释一下这个assertion吗

@nachifur
Copy link
Owner

nachifur commented Mar 5, 2024

您好,我是深度学习的初学者,我今天 在运行程序的时候出现这个报错,我不太清楚这个报错是什么意思RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase.

    This probably means that you are not using fork to start your
    child processes and you have forgotten to use the proper idiom
    in the main module:

        if __name__ == '__main__':
            freeze_support()
            ...

    The "freeze_support()" line can be omitted if the program
    is not going to be frozen to produce an executable.请问能解释一下这个assertion吗

这个错误没有遇到过,可以bing/google搜搜,排查一下

@GeroRoman
Copy link

Snipaste_2024-03-07_21-23-40
您好,作者!
我把代码跑通了但是这里显示test生成的图片是这样的,请问我是哪里没有设置正确吗?能不能给我一点提示,我是否需要修改代码中的某些部分?我是修改了folder的路径并在folder文件夹里和上图中的results里面的sample里面分别加入了celeba数据集的图片,但是我感觉这里面训练的时候并没有用到这些图片

@KasuganoLove
Copy link

KasuganoLove commented Mar 12, 2024

train.py中,其他任务类似于42行(阴影去除,有mask输入)和49行(低光照增强,无mask输入)。

你好,请问ISTD数据集的GT mask在推理的时候会作为condition一起输入到网络中吗?

@KasuganoLove
Copy link

KasuganoLove commented Mar 12, 2024

train.py中,其他任务类似于42行(阴影去除,有mask输入)和49行(低光照增强,无mask输入)。

你好,请问ISTD数据集的GT mask在推理的时候会作为condition一起输入到网络中吗?

根据以下代码,我的理解是作为condition输入的,请问您在测试是是直接用测试集GT的mask作为condition吗?还是有其他的网络生成一个mask。

RDDM/datasets/base.py

Lines 114 to 147 in 46ffd50

elif self.condition == 2:
# condition
img0 = Image.open(self.gt[index])
img1 = Image.open(self.input[index])
img2 = Image.open(self.input_condition[index])
img0 = convert_image_to_fn(
self.convert_image_to, img0) if self.convert_image_to else img0
img1 = convert_image_to_fn(
self.convert_image_to, img1) if self.convert_image_to else img1
img2 = convert_image_to_fn(
self.convert_image_to, img2) if self.convert_image_to else img2
img0, img1, img2 = self.pad_img(
[img0, img1, img2], self.image_size)
if self.crop_patch and not self.sample:
img0, img1, img2 = self.get_patch(
[img0, img1, img2], self.image_size)
img1 = self.cv2equalizeHist(img1) if self.equalizeHist else img1
images = [[img0, img1, img2]]
p = Augmentor.DataPipeline(images)
if self.augment_flip:
p.flip_left_right(1)
if not self.crop_patch:
p.resize(1, self.image_size, self.image_size)
g = p.generator(batch_size=1)
augmented_images = next(g)
img0 = cv2.cvtColor(augmented_images[0][0], cv2.COLOR_BGR2RGB)
img1 = cv2.cvtColor(augmented_images[0][1], cv2.COLOR_BGR2RGB)
img2 = cv2.cvtColor(augmented_images[0][2], cv2.COLOR_BGR2RGB)
return [self.to_tensor(img0), self.to_tensor(img1), self.to_tensor(img2)]

def p_losses(self, imgs, t, noise=None):
if isinstance(imgs, list): # Condition
if self.input_condition:
x_input_condition = imgs[2]
else:
x_input_condition = 0
x_input = imgs[1]
x_start = imgs[0] # gt = imgs[0], input = imgs[1]
else: # Generation
x_input = 0
x_start = imgs
noise = default(noise, lambda: torch.randn_like(x_start))
x_res = x_input - x_start
b, c, h, w = x_start.shape
# noise sample
x = self.q_sample(x_start, x_res, t, noise=noise)
# if doing self-conditioning, 50% of the time, predict x_start from current set of times
# and condition with unet with that
# this technique will slow down training by 25%, but seems to lower FID significantly
x_self_cond = None
if self.self_condition and random.random() < 0.5:
with torch.no_grad():
x_self_cond = self.model_predictions(
x_input, x, t, x_input_condition if self.input_condition else 0).pred_x_start
x_self_cond.detach_()

def model_predictions(self, x_input, x, t, x_input_condition=0, x_self_cond=None, clip_denoised=True):
if not self.condition:
x_in = x
else:
if self.input_condition:
x_in = torch.cat((x, x_input, x_input_condition), dim=1)
else:
x_in = torch.cat((x, x_input), dim=1)

根据以下代码,我的理解是作为condition输入的,请问您在测试是是直接用测试集GT的mask作为condition吗?还是有其他的网络生成一个mask。

根据我对以下代码的理解,测试是是直接用测试集GT的mask作为condition:

elif len(folder) == 6:
self.condition_type = 3
# test_gt+test_input
ds = dataset(folder[3:6], self.image_size,
augment_flip=False, convert_image_to=convert_image_to, condition=2, equalizeHist=equalizeHist, crop_patch=crop_patch, sample=True, generation=generation)
trian_folder = folder[0:3]
self.sample_dataset = ds
self.sample_loader = cycle(self.accelerator.prepare(DataLoader(self.sample_dataset, batch_size=num_samples, shuffle=True,
pin_memory=True, num_workers=4))) # cpu_count()
ds = dataset(trian_folder, self.image_size, augment_flip=augment_flip,
convert_image_to=convert_image_to, condition=2, equalizeHist=equalizeHist, crop_patch=crop_patch, generation=generation)
self.dl = cycle(self.accelerator.prepare(DataLoader(ds, batch_size=train_batch_size,
shuffle=True, pin_memory=True, num_workers=4)))

@nachifur
Copy link
Owner

nachifur commented Mar 12, 2024

Snipaste_2024-03-07_21-23-40 您好,作者! 我把代码跑通了但是这里显示test生成的图片是这样的,请问我是哪里没有设置正确吗?能不能给我一点提示,我是否需要修改代码中的某些部分?我是修改了folder的路径并在folder文件夹里和上图中的results里面的sample里面分别加入了celeba数据集的图片,但是我感觉这里面训练的时候并没有用到这些图片

如果是:图像生成对于celeba(默认的代码会自己下载数据集,可能需要梯子),可以看一下./datasets/get_dataset.py,[29-31行取消注释,注释33行]。(

# dataset_import = "generation"
)

debug一下,设置断点,看看能不能正常加载数据。

注意:除了partially path-independent generation process实验(目前release的代码是针对这个实验的)使用[self.alphas_cumsum[t]*self.num_timesteps, self.betas_cumsum[t]*self.num_timesteps]] ,其他所有任务默认使用[t,t]

@nachifur
Copy link
Owner

train.py中,其他任务类似于42行(阴影去除,有mask输入)和49行(低光照增强,无mask输入)。

你好,请问ISTD数据集的GT mask在推理的时候会作为condition一起输入到网络中吗?

concat一起送到网络。

@nachifur
Copy link
Owner

nachifur commented Mar 12, 2024

train.py中,其他任务类似于42行(阴影去除,有mask输入)和49行(低光照增强,无mask输入)。

你好,请问ISTD数据集的GT mask在推理的时候会作为condition一起输入到网络中吗?

根据以下代码,我的理解是作为condition输入的,请问您在测试是是直接用测试集GT的mask作为condition吗?还是有其他的网络生成一个mask。

RDDM/datasets/base.py

Lines 114 to 147 in 46ffd50

elif self.condition == 2:
# condition
img0 = Image.open(self.gt[index])
img1 = Image.open(self.input[index])
img2 = Image.open(self.input_condition[index])
img0 = convert_image_to_fn(
self.convert_image_to, img0) if self.convert_image_to else img0
img1 = convert_image_to_fn(
self.convert_image_to, img1) if self.convert_image_to else img1
img2 = convert_image_to_fn(
self.convert_image_to, img2) if self.convert_image_to else img2
img0, img1, img2 = self.pad_img(
[img0, img1, img2], self.image_size)
if self.crop_patch and not self.sample:
img0, img1, img2 = self.get_patch(
[img0, img1, img2], self.image_size)
img1 = self.cv2equalizeHist(img1) if self.equalizeHist else img1
images = [[img0, img1, img2]]
p = Augmentor.DataPipeline(images)
if self.augment_flip:
p.flip_left_right(1)
if not self.crop_patch:
p.resize(1, self.image_size, self.image_size)
g = p.generator(batch_size=1)
augmented_images = next(g)
img0 = cv2.cvtColor(augmented_images[0][0], cv2.COLOR_BGR2RGB)
img1 = cv2.cvtColor(augmented_images[0][1], cv2.COLOR_BGR2RGB)
img2 = cv2.cvtColor(augmented_images[0][2], cv2.COLOR_BGR2RGB)
return [self.to_tensor(img0), self.to_tensor(img1), self.to_tensor(img2)]

def p_losses(self, imgs, t, noise=None):
if isinstance(imgs, list): # Condition
if self.input_condition:
x_input_condition = imgs[2]
else:
x_input_condition = 0
x_input = imgs[1]
x_start = imgs[0] # gt = imgs[0], input = imgs[1]
else: # Generation
x_input = 0
x_start = imgs
noise = default(noise, lambda: torch.randn_like(x_start))
x_res = x_input - x_start
b, c, h, w = x_start.shape
# noise sample
x = self.q_sample(x_start, x_res, t, noise=noise)
# if doing self-conditioning, 50% of the time, predict x_start from current set of times
# and condition with unet with that
# this technique will slow down training by 25%, but seems to lower FID significantly
x_self_cond = None
if self.self_condition and random.random() < 0.5:
with torch.no_grad():
x_self_cond = self.model_predictions(
x_input, x, t, x_input_condition if self.input_condition else 0).pred_x_start
x_self_cond.detach_()

def model_predictions(self, x_input, x, t, x_input_condition=0, x_self_cond=None, clip_denoised=True):
if not self.condition:
x_in = x
else:
if self.input_condition:
x_in = torch.cat((x, x_input, x_input_condition), dim=1)
else:
x_in = torch.cat((x, x_input), dim=1)

根据以下代码,我的理解是作为condition输入的,请问您在测试是是直接用测试集GT的mask作为condition吗?还是有其他的网络生成一个mask。

根据我对以下代码的理解,测试是是直接用测试集GT的mask作为condition:

elif len(folder) == 6:
self.condition_type = 3
# test_gt+test_input
ds = dataset(folder[3:6], self.image_size,
augment_flip=False, convert_image_to=convert_image_to, condition=2, equalizeHist=equalizeHist, crop_patch=crop_patch, sample=True, generation=generation)
trian_folder = folder[0:3]
self.sample_dataset = ds
self.sample_loader = cycle(self.accelerator.prepare(DataLoader(self.sample_dataset, batch_size=num_samples, shuffle=True,
pin_memory=True, num_workers=4))) # cpu_count()
ds = dataset(trian_folder, self.image_size, augment_flip=augment_flip,
convert_image_to=convert_image_to, condition=2, equalizeHist=equalizeHist, crop_patch=crop_patch, generation=generation)
self.dl = cycle(self.accelerator.prepare(DataLoader(ds, batch_size=train_batch_size,
shuffle=True, pin_memory=True, num_workers=4)))

类似于之前的方法(两阶段阴影去除范式:先检测再去除),阴影去除任务直接使用mask的gt。也可以尝试评估采用其他的阴影检测网络得到的mask。具体可参见ICCV2019: Shadow removal via shadow image decomposition,以及appendix。

@TuTusong
Copy link

作者您好,在复现过程中想替换成自己的数据集进行尝试,也将路径存成了文件列表,但是读取时还是出现了这个错误,想问下.flist中是存在什么结构吗?
image

@nachifur
Copy link
Owner

作者您好,在复现过程中想替换成自己的数据集进行尝试,也将路径存成了文件列表,但是读取时还是出现了这个错误,想问下.flist中是存在什么结构吗? image

没有特殊格式,每一行是图片的绝对路径。可以先一行一行debug看看哪里的问题。

@TuTusong
Copy link

作者您好,在复现过程中想替换成自己的数据集进行尝试,也将路径存成了文件列表,但是读取时还是出现了这个错误,想问下.flist中是存在什么结构吗? image

没有特殊格式,每一行是图片的绝对路径。可以先一行一行debug看看哪里的问题。

感谢您的回答,已经可以运行了

@nachifur
Copy link
Owner

作者您好,在复现过程中想替换成自己的数据集进行尝试,也将路径存成了文件列表,但是读取时还是出现了这个错误,想问下.flist中是存在什么结构吗? image

没有特殊格式,每一行是图片的绝对路径。可以先一行一行debug看看哪里的问题。

感谢您的回答,已经可以运行了

好的。

如果方便,您可以贴出来如何解决的这个问题,以及注意事项,方便大家修改和运行。

非常抱歉目前不完善的代码给大家带来不便。代码正在整理,随时更新完善。

@JunningSu
Copy link

您好,我是深度学习的初学者,我今天 在运行程序的时候出现这个报错,我不太清楚这个报错是什么意思RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase.

    This probably means that you are not using fork to start your
    child processes and you have forgotten to use the proper idiom
    in the main module:

        if __name__ == '__main__':
            freeze_support()
            ...

    The "freeze_support()" line can be omitted if the program
    is not going to be frozen to produce an executable.请问能解释一下这个assertion吗

您好,我也遇到了这个问题,请问这个问题是怎么解决的,谢谢!

@miraclerepuduce
Copy link

您好,我是深度学习的初学者,我今天 在运行程序的时候出现这个报错,我不太清楚这个报错是什么意思RuntimeError: 已尝试在当前进程完成其引导阶段之前启动新进程。

    This probably means that you are not using fork to start your
    child processes and you have forgotten to use the proper idiom
    in the main module:

        if __name__ == '__main__':
            freeze_support()
            ...

    The "freeze_support()" line can be omitted if the program
    is not going to be frozen to produce an executable.请问能解释一下这个assertion吗

您好,我也遇到了这个问题,请问这个问题是怎么解决的,谢谢!

这个问题你现在是怎么解决的,我也遇到了,难受

@nachifur
Copy link
Owner

nachifur commented Apr 17, 2024

您好我是一个小白,请问有单独的real_img去噪模块吗,我可以直接用我的数据集跑去噪任务吗,谢谢

没太明白real_img去噪模块是什么意思?

@miraclerepuduce
Copy link

  1. 修改train.py
    image

train.py中,其他任务类似于42行(阴影去除,有mask输入)和49行(低光照增强,无mask输入)。

train.py中,35行-37行 阴影去除: condition = True input_condition = True input_condition_mask = True

低光照: condition = True input_condition = False input_condition_mask = False

  1. 修改src/residual_denoising_diffusion_pytorch.py

a. [self.alphas_cumsum[t]*self.num_timesteps, self.betas_cumsum[t]*self.num_timesteps]] -> [t,t] (in L852 and L1292). b. modify the corresponding experimental settings (see Table 4 in the Appendix), e.g., Loss, Optimizer

作者你好,你们的工作看起来非常新颖!但是你的回复中的2.a部分具体是怎么更改的,我好像卡住了,可以具体示范一下吗,谢谢!

@lwtgithublwt
Copy link

lkl
AttributeError: 'int' object has no attribute 'size'作者您好,这个该如何解决,感觉应该是数据的相关问题。

@miraclerepuduce
Copy link

lkl AttributeError: 'int' object has no attribute 'size'作者您好,这个该如何解决,感觉应该是数据的相关问题。

me too ,我查看了数据格式,有一个是元组中多了一个int元素,而计算loss的另一个元组中没有这个int

@laboratory616
Copy link

lkl AttributeError: 'int' object has no attribute 'size'作者您好,这个该如何解决,感觉应该是数据的相关问题。

me too ,我查看了数据格式,有一个是元组中多了一个int元素,而计算loss的另一个元组中没有这个int

如果只预测res,需要在train.py中修改参数num_unet = 1,objective = 'pred_res'

@RongjinGuo
Copy link

lkl AttributeError: 'int' object has no attribute 'size'作者您好,这个该如何解决,感觉应该是数据的相关问题。

me too ,我查看了数据格式,有一个是元组中多了一个int元素,而计算loss的另一个元组中没有这个int

如果只预测res,需要在train.py中修改参数num_unet = 1,objective = 'pred_res'

那如果是同时预测res和noise应该怎么办呀

@Ying-debug
Copy link

为什么我训练的损失函数一直振荡不收敛?

@nachifur
Copy link
Owner

lkl AttributeError: 'int' object has no attribute 'size'作者您好,这个该如何解决,感觉应该是数据的相关问题。

me too ,我查看了数据格式,有一个是元组中多了一个int元素,而计算loss的另一个元组中没有这个int

如果只预测res,需要在train.py中修改参数num_unet = 1,objective = 'pred_res'

那如果是同时预测res和noise应该怎么办呀

默认的代码是:res和noise都预测,两个网络,两个优化器。

如果想改成L_{res}+L_{\epsilon},可以简单改一下loss,采用一个adam优化器就行(具体的设置见appendix table4)。

@nachifur
Copy link
Owner

nachifur commented Apr 29, 2024

为什么我训练的损失函数一直振荡不收敛?

暂时没有遇到这个问题,可以输出一下中间结果看一下。建议每次修改一处代码,然后简单训练看一下结果,以验证修改是否正确。

@ZYNuo
Copy link

ZYNuo commented May 15, 2024

lkl AttributeError: 'int' object has no attribute 'size'作者您好,这个该如何解决,感觉应该是数据的相关问题。

image
试试把train.py 72行test_res_or_noise改成=“res_noise”

@nachifur
Copy link
Owner

nachifur commented May 18, 2024 via email

@zh994
Copy link

zh994 commented May 28, 2024

微信截图_20240528170740
微信截图_20240528171016
image
你好,我想问一下,我训练去除阴影得到的结果是这样的正常吗?我是训练了两个unet,但是我看你表4写的损失是残差损失加上噪声损失,代码中却是两个损失各自对应自己的模型。还有表4中的Schedules在哪里设置?

@panpanGod1
Copy link

作者你好,我想试着用模型进行图像去噪任务,是否采用低光照实验的模板,然后将input设置为带噪声图像,gt设置为无噪声图像就可以了?

@nachifur
Copy link
Owner

nachifur commented May 29, 2024

作者你好,我想试着用模型进行图像去噪任务,是否采用低光照实验的模板,然后将input设置为带噪声图像,gt设置为无噪声图像就可以了?

对于低光照,I_T=I_{in}+\bar{\beta}_T \epsilon$I_{in}是低光照图像,I_0是正常光照图像(GT)。

经验来说:换成图像去噪任务(需要你自己尝试一下),类似低光照,可以仅考虑估计残差(SM-Res)的。

@nachifur
Copy link
Owner

微信截图_20240528170740 微信截图_20240528171016 image 你好,我想问一下,我训练去除阴影得到的结果是这样的正常吗?我是训练了两个unet,但是我看你表4写的损失是残差损失加上噪声损失,代码中却是两个损失各自对应自己的模型。还有表4中的Schedules在哪里设置?

可以参考readme的内容,图像恢复需要自己修改设置(ps:我们也正在抓紧整理代码):

image

@nil0330
Copy link

nil0330 commented Jun 3, 2024

你好作者我在做实验的时候发现测试的过程分为两个阶段,第一个阶段是残差过程中的图片质量还很好,第二阶段加噪去噪过程却导致图片效果很差。以下是效果展示图:
image
请问作者出现过这个问题嘛

@nachifur
Copy link
Owner

nachifur commented Jun 3, 2024 via email

@ZYNuo
Copy link

ZYNuo commented Jun 17, 2024

作者您好,我用RDDM模型跑了一下RainDrop数据集,我尝试对齐了您Table4中的参数,但得到的结果有一些问题,希望您有空的时候能解答一下:
1.我看到RainDrop数据集的test部分分了test-a和test-b,请问您的文章中的实验结果是将这两部分合并起来测试的吗?
2.请问train.py中的sum_scale对应的是βt方的值吗?
3.我没有找到一个Adam优化Lres+Lsigma的代码实现,我对loss做了如下修改,然后使用了之前代码中只使用一个Adam优化器的代码,请问这样修改有问题吗?
d6ae2c82eec2c6868e9c3540ceb5cf0
b7d50cb3d5ef870937463a4776a2fec
25c0126f5532b3da497a12cdc049f16
4.参照您之前在issue中的回答,采样方法的设置对应的是test_res_ro_noise,但是我设置为test_res_ro_noise=res时得到的效果要好于test=res_noise,似乎与文中的结果不太一致,请问是我的设置有问题吗
3d4813640e263a40478a1f22c0327aatest_res_or_noise=res_noise
e2a3b4a8193a4a5a300faf27287c9d8test_res_or_noise=res
38823478b081d6688e393902b354e25

@nachifur
Copy link
Owner

nachifur commented Jun 18, 2024

  1. use test-a for test->https://github.com/rui1996/DeRaindrop
  2. sum_scale->图像恢复任务的训练 #2 (comment)
  3. try cannot find the part  #19 (comment)
  4. For L_{res}+L_{\epsilon }, you should use test_res_or_noise = "res_noise". For test_res_or_noise = "res" or test_res_or_noise = "noise", you should retrain model by L_{res} or L_{\epsilon }.

When num_unet=2, objective = 'pred_res_noise' and L_{res}, L_{\epsilon }, you can select test_res_or_noise = "noise", test_res_or_noise = "noise" or test_res_or_noise = "res_noise".

In order to train RDDM on Raindrop, we temporarily provide a very imperfect early version of the RDDM code. The final version of the code is still being organized.

res_diffusion_tempalte_deraing_raindrop_noise1_github.zip

作者您好,我用RDDM模型跑了一下RainDrop数据集,我尝试对齐了您Table4中的参数,但得到的结果有一些问题,希望您有空的时候能解答一下: 1.我看到RainDrop数据集的test部分分了test-a和test-b,请问您的文章中的实验结果是将这两部分合并起来测试的吗? 2.请问train.py中的sum_scale对应的是βt方的值吗? 3.我没有找到一个Adam优化Lres+Lsigma的代码实现,我对loss做了如下修改,然后使用了之前代码中只使用一个Adam优化器的代码,请问这样修改有问题吗? d6ae2c82eec2c6868e9c3540ceb5cf0 b7d50cb3d5ef870937463a4776a2fec 25c0126f5532b3da497a12cdc049f16 4.参照您之前在issue中的回答,采样方法的设置对应的是test_res_ro_noise,但是我设置为test_res_ro_noise=res时得到的效果要好于test=res_noise,似乎与文中的结果不太一致,请问是我的设置有问题吗 3d4813640e263a40478a1f22c0327aatest_res_or_noise=res_noise e2a3b4a8193a4a5a300faf27287c9d8test_res_or_noise=res 38823478b081d6688e393902b354e25

@ZYNuo
Copy link

ZYNuo commented Jun 18, 2024

  1. use test-a for test->https://github.com/rui1996/DeRaindrop
  2. sum_scale->图像恢复任务的训练 #2 (comment)
  3. try cannot find the part  #19 (comment)
  4. For L_{res}+L_{\epsilon }, you should use test_res_or_noise = "res_noise". For test_res_or_noise = "res" or test_res_or_noise = "noise", you should retrain model by L_{res} or L_{\epsilon }.

When num_unet=2, objective = 'pred_res_noise' and L_{res}, L_{\epsilon }, you can select test_res_or_noise = "noise", test_res_or_noise = "noise" or test_res_or_noise = "res_noise".

In order to train RDDM on Raindrop, we temporarily provide a very imperfect early version of the RDDM code. The final version of the code is still being organized.

res_diffusion_tempalte_deraing_raindrop_noise1_github.zip

Thanks for your reply,I will run the code you posted and try to find where I made mistakes during coding.

@dezle13
Copy link

dezle13 commented Jun 24, 2024

作者你好,进行ISTD的阴影去除项目时,主要的问题是输出的结果x_start和原图基本一致,没有实现阴影的消除。
1.进行Lnoise+Lres的back时是否是下图1,造成的LOSS特别大。
2.结果图中的显示是图2的设置,输出图像3是x_start,输出图像4是res和x_start.
请问此种情况到底应该如何解决。
backward
backward2
结果1
结果2

@nachifur
Copy link
Owner

  1. use test-a for test->https://github.com/rui1996/DeRaindrop
  2. sum_scale->图像恢复任务的训练 #2 (comment)
  3. try cannot find the part  #19 (comment)
  4. For L_{res}+L_{\epsilon }, you should use test_res_or_noise = "res_noise". For test_res_or_noise = "res" or test_res_or_noise = "noise", you should retrain model by L_{res} or L_{\epsilon }.

When num_unet=2, objective = 'pred_res_noise' and L_{res}, L_{\epsilon }, you can select test_res_or_noise = "noise", test_res_or_noise = "noise" or test_res_or_noise = "res_noise".
In order to train RDDM on Raindrop, we temporarily provide a very imperfect early version of the RDDM code. The final version of the code is still being organized.
res_diffusion_tempalte_deraing_raindrop_noise1_github.zip

Thanks for your reply,I will run the code you posted and try to find where I made mistakes during coding.

@dezle13 你可以试一下这个去雨的临时代码,修改的内容应该很少(sum_scale=0.01(i.e., \bar{\beta}_T)和Training iterations)。

The final version of the code is still being organized.

@nil0330
Copy link

nil0330 commented Aug 14, 2024

你好作者我在做实验的时候发现测试的过程分为两个阶段,第一个阶段是残差过程中的图片质量还很好,第二阶段加噪去噪过程却导致图片效果很差。以下是效果展示图 请问作者出现过这个问题嘛
无论是图像生成和恢复,在测试时都是同步去除,建议使用条件t。目前的代码是仅为了验证部分路径独立生成的存在性,建议使用条件:[self.alphas_cumsum[t]*self.num_timesteps, self.betas_cumsum[t]*self.num_timesteps]。

我这里是这么思考的
model_output = self.model(x_in,
[t,t],
x_self_cond)
模型只关心当前时间步的信息,相当于传统去噪模型,但是如果参数这么设置
model_output = self.model(x_in,
[self.alphas_cumsum[t]*self.num_timesteps,
self.betas_cumsum[t]*self.num_timesteps],
x_self_cond)
才是论文中的提到的通过两个参数分别控制残差和噪声强度是吧
最后跟您确认一下如果想实现好的图片生成效果应该设置成[self.alphas_cumsum[t]*self.num_timesteps,self.betas_cumsum[t]*self.num_timesteps]是吧

@nachifur
Copy link
Owner

[self.alphas_cumsum[t]*self.num_timesteps, self.betas_cumsum[t]*self.num_timesteps] for partially path-independent generation process are to verify the explanatory nature of the diffusion model.

Other tasks recommend [t,t].

你好作者我在做实验的时候发现测试的过程分为两个阶段,第一个阶段是残差过程中的图片质量还很好,第二阶段加噪去噪过程却导致图片效果很差。以下是效果展示图 请问作者出现过这个问题嘛
无论是图像生成和恢复,在测试时都是同步去除,建议使用条件t。目前的代码是仅为了验证部分路径独立生成的存在性,建议使用条件:[self.alphas_cumsum[t]*self.num_timesteps, self.betas_cumsum[t]*self.num_timesteps]。

我这里是这么思考的 model_output = self.model(x_in, [t,t], x_self_cond) 模型只关心当前时间步的信息,相当于传统去噪模型,但是如果参数这么设置 model_output = self.model(x_in, [self.alphas_cumsum[t]*self.num_timesteps, self.betas_cumsum[t]*self.num_timesteps], x_self_cond) 才是论文中的提到的通过两个参数分别控制残差和噪声强度是吧 最后跟您确认一下如果想实现好的图片生成效果应该设置成[self.alphas_cumsum[t]*self.num_timesteps,self.betas_cumsum[t]*self.num_timesteps]是吧

@nachifur
Copy link
Owner

nachifur commented Sep 6, 2024

  1. use test-a for test->https://github.com/rui1996/DeRaindrop
  2. sum_scale->图像恢复任务的训练 #2 (comment)
  3. try cannot find the part  #19 (comment)
  4. For L_{res}+L_{\epsilon }, you should use test_res_or_noise = "res_noise". For test_res_or_noise = "res" or test_res_or_noise = "noise", you should retrain model by L_{res} or L_{\epsilon }.

When num_unet=2, objective = 'pred_res_noise' and L_{res}, L_{\epsilon }, you can select test_res_or_noise = "noise", test_res_or_noise = "noise" or test_res_or_noise = "res_noise".

In order to train RDDM on Raindrop, we temporarily provide a very imperfect early version of the RDDM code. The final version of the code is still being organized.

res_diffusion_tempalte_deraing_raindrop_noise1_github.zip

Repository owner locked as resolved and limited conversation to collaborators Sep 6, 2024
@nachifur nachifur pinned this issue Sep 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests