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

Unable to reproduce the data in the paper #1

Open
CrownOfStars opened this issue Jun 7, 2024 · 7 comments
Open

Unable to reproduce the data in the paper #1

CrownOfStars opened this issue Jun 7, 2024 · 7 comments

Comments

@CrownOfStars
Copy link

File ".../DFormer-SOD/Code/models/decoders/decode_head.py", line 177, in
inputs = [inputs[i] for i in self.in_index]
IndexError: tuple index out of range

I'm # trying to run the code for DFormer-SOD using the large architecture, but I get this error, Dformer's backbone seems to output two sets of four-level features, while the decoder only receives a single set of four-level features, so I'm only taking the first set of features as the input to the decoder, so please tell me how I can modify it to reproduce the The data is in the paper

@caojiaolong
Copy link
Collaborator

Thanks for your attention to our work!

We tested our latest code and found that it was able to train correctly as follows. Perhaps you need to check that the code you clone is up to date, or that some modifications of the code may affect the output of the model. If you can provide more information, we may be able to better localize the problem.

image

image

@CrownOfStars
Copy link
Author

Thanks for your attention to our work!

We tested our latest code and found that it was able to train correctly as follows. Perhaps you need to check that the code you clone is up to date, or that some modifications of the code may affect the output of the model. If you can provide more information, we may be able to better localize the problem.

image

image

我直接从网盘下载Dformer_large_sod.pth文件,然后运行test_produce_map.py让模型加载这个权重,但是得到了上面这个错误,encoder输出的是一个长度为2的元组,而根据默认设置,decoder需要encoder输出的四层特征而不是包含了四层特征的元组,所以我该如何修改代码
f835acaddcc04b85a353543fbb4ea0be
{44F3598C-7F3D-4384-89C6-0B81840E07FB}
{F50EB2B1-C400-4ab2-85E1-A69C0AD4DBBB}
6d7c88761b5896cf4c36cb456a39afa7

@caojiaolong
Copy link
Collaborator

您好,我们认为问题可能是在您第二张截图的158行上,因为encoder实际上只输出了RGB的feature送入decoder,因此不需要再手动地将encoder的输出拆开了,因此我们建议将158行修改回x = self.backbone(rgb, modal_x)。您第三张截图是block的结构图,实际上论文中的整体结构图描述了我们只将encoder的RGB特征送入decoder。

image

从encoder的代码可以看出输出只包含RGB的feature:

outs = []
for i in range(4):
x = self.downsample_layers[i](x)
x_e = self.downsample_layers_e[i](x_e)
x = x.permute(0, 2, 3, 1)
x_e = x_e.permute(0, 2, 3, 1)
for blk in self.stages[i]:
x,x_e = blk(x,x_e)
x = x.permute(0, 3, 1, 2)
x_e = x_e.permute(0, 3, 1, 2)
outs.append(x)
return outs

当前仓库最新版代码经过我们的测试,发现能够正常训练与测试,因此如果上述还未解决您的问题,我们建议您与当前仓库最新版的代码进行对比,确保Code/models/encoders/DFormer.py文件与仓库的最新版本一致。如果仍不能解决,您可以留下更多信息以便我们更好地定位问题。

@CrownOfStars
Copy link
Author

您好,我们认为问题可能是在您第二张截图的158行上,因为encoder实际上只输出了RGB的feature送入decoder,因此不需要再手动地将encoder的输出拆开了,因此我们建议将158行修改回x = self.backbone(rgb, modal_x)。您第三张截图是block的结构图,实际上论文中的整体结构图描述了我们只将encoder的RGB特征送入decoder。

image

从encoder的代码可以看出输出只包含RGB的feature:

outs = []
for i in range(4):
x = self.downsample_layers[i](x)
x_e = self.downsample_layers_e[i](x_e)
x = x.permute(0, 2, 3, 1)
x_e = x_e.permute(0, 2, 3, 1)
for blk in self.stages[i]:
x,x_e = blk(x,x_e)
x = x.permute(0, 3, 1, 2)
x_e = x_e.permute(0, 3, 1, 2)
outs.append(x)
return outs

当前仓库最新版代码经过我们的测试,发现能够正常训练与测试,因此如果上述还未解决您的问题,我们建议您与当前仓库最新版的代码进行对比,确保Code/models/encoders/DFormer.py文件与仓库的最新版本一致。如果仍不能解决,您可以留下更多信息以便我们更好地定位问题。

好了,我现在换成最新的代码可以直接运行了,但还是没法得到论文的结果,我直接从网盘下载Dformer_large_sod.pth文件,然后运行test_produce_map.py让模型加载这个权重,这么做不对吗

@caojiaolong
Copy link
Collaborator

caojiaolong commented Jun 13, 2024

你好,在运行完python test_produce_maps.py后还需要运行python test_evaluation_maps.py才能得到测试的结果,test_produce_map.py的作用只是生成map,而test_evaluation_maps才是计算论文指标的代码。

如果您运行test_evaluation_maps后仍有问题欢迎提供进一步的信息以便我们一起解决。

@CrownOfStars
Copy link
Author

你好,在运行完python test_produce_maps.py后还需要运行python test_evaluation_maps.py才能得到测试的结果,test_produce_map.py的作用只是生成map,而test_evaluation_maps才是计算论文指标的代码。

如果您运行test_evaluation_maps后仍有问题欢迎提供进一步的信息以便我们一起解决。

我当然看得懂英文和代码,知道运行什么会出什么结果,现在的问题是运行python test_produce_maps.py得到的图片在我的评估代码上效果不行,而下载提供的Predicted Saliency Maps效果就和论文一样,这说明运行python test_produce_maps.py得到的图片不能达到论文里面的效果
4ce560745e182e609b32f3e5c28836ad

@caojiaolong
Copy link
Collaborator

您好,我们重新测试了一遍仓库的最新版代码,完整步骤包括:

  1. 首先从README.md中提供的百度网盘链接下载训练好的权重,将其放在了Checkpoint/trained/文件夹中,请注意需要将权重重命名为DFormer_SOD_epoch_best.pth,或者您可以在运行python test_produce_maps.py时需要增加参数--checkpoint指定您放置pth文件的路径。
  2. 我们按照README.md的步骤在项目根目录下运行了如下两行命令。
python test_produce_maps.py
python test_evaluation_maps.py

随后得到完整输出如下图所示。
image
image
image

可以看出与论文中的表二是一致的。
image

关于您提出的效果不佳,我们认为首先需要确保所有代码与当前仓库一致,且确保测试时使用的pth文件为网盘中下载的pth。此外,还有可能是环境不一致导致的复现问题,您可以与README.md中的Requirement进行对比,确保您运行时的环境与我们一致。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants