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

FAQ 解答 #3

Open
Linwei-Chen opened this issue Sep 20, 2024 · 24 comments
Open

FAQ 解答 #3

Linwei-Chen opened this issue Sep 20, 2024 · 24 comments

Comments

@Linwei-Chen
Copy link
Owner

No description provided.

@Linwei-Chen
Copy link
Owner Author

Q: hr和lr 的channel不同时,汇总不同层次特征时是对低channel特征进行卷积升维再与高channel特征拼接吗?
A:通道不同的情况可以参考SegNeXt+FreqFusion的实现,可以不用升维,直接拼接即可。升维也可以尝试,但会增加更多额外参数,并且作者个人尝试结果并没有更好。

@u1nderdog
Copy link

Q: hr和lr 的channel不同时,汇总不同层次特征时是对低channel特征进行卷积升维再与高channel特征拼接吗? A:通道不同的情况可以参考SegNeXt+FreqFusion的实现,可以不用升维,直接拼接即可。升维也可以尝试,但会增加更多额外参数,并且作者个人尝试结果并没有更好。

Q: hr和lr 的channel不同时,汇总不同层次特征时是对低channel特征进行卷积升维再与高channel特征拼接吗? A:通道不同的情况可以参考SegNeXt+FreqFusion的实现,可以不用升维,直接拼接即可。升维也可以尝试,但会增加更多额外参数,并且作者个人尝试结果并没有更好。

你好,我想问一下 A:通道不同的情况可以参考SegNeXt+FreqFusion的实现,可以不用升维,直接拼接即可。这一块具体的实现是在文档的哪个位置,我没有找到。您能否告诉我文档具体的实现位置呢?

@Linwei-Chen
Copy link
Owner Author

Linwei-Chen commented Sep 23, 2024

可以参考LightHamHeadFreqAware的实现。

@Xy-unu
Copy link

Xy-unu commented Sep 23, 2024

我在 unet 中尝试使用了FreqFusion 替换了部分上采样,最后结果也没变高。

@Linwei-Chen
Copy link
Owner Author

Linwei-Chen commented Sep 23, 2024

有同学在医疗图像上改UNet遇到了同样的问题,是因为位置不对导致的,修改正确后初步试验涨了1个多点。
可以参考文档https://github.com/Linwei-Chen/FreqFusion 首页新更新的示例。建议把所有涉及上采样的部分都换成FreqFusion。

@Xy-unu
Copy link

Xy-unu commented Sep 24, 2024

有同学在医疗图像上改UNet遇到了同样的问题,是因为位置不对导致的,修改正确后初步试验涨了1个多点。 可以参考文档https://github.com/Linwei-Chen/FreqFusion 首页新更新的示例。建议把所有涉及上采样的部分都换成FreqFusion。

感谢您的回复,我在 unet 中修改了所有涉及上采样部分,结果依旧是降低的,但和之前的结果相比降低的不多。

@Linwei-Chen
Copy link
Owner Author

同学做的是什么任务呢?可否提供修改前后的代码供大家讨论

@wkaiha
Copy link

wkaiha commented Sep 24, 2024

有同学在医疗图像上改UNet遇到了同样的问题,是因为位置不对导致的,修改正确后初步试验涨了1个多点。 可以参考文档https://github.com/Linwei-Chen/FreqFusion 首页新更新的示例。建议把所有涉及上采样的部分都换成FreqFusion。

感谢您的回复,我在 unet 中修改了所有涉及上采样部分,结果依旧是降低的,但和之前的结果相比降低的不多。

我在unet中上采样使用了freqfusion,提了大概1.个多点,加的位置和方式很重要

@Xy-unu
Copy link

Xy-unu commented Sep 24, 2024

同学做的是什么任务呢?可否提供修改前后的代码供大家讨论

做的是参考图像分割,只在decoder里把 skip 的上采样修改成了freq_fusion模块
def forward(self, x, skip=None): x = F.interpolate(x, scale_factor=2, mode="nearest") if skip is not None: # skip = F.interpolate(skip, size=x.shape[2:], mode='bilinear') _,x_l, skip = self.freq_fusion(hr_feat=x, lr_feat=skip) x = torch.cat([x, skip], dim=1) x = self.attention1(x) x = self.conv1(x) x = self.conv2(x) x = self.attention2(x)

@wkaiha
Copy link

wkaiha commented Sep 24, 2024

同学做的是什么任务呢?可否提供修改前后的代码供大家讨论

做的是参考图像分割,只在decoder里把 skip 的上采样修改成了freq_fusion模块 def forward(self, x, skip=None): x = F.interpolate(x, scale_factor=2, mode="nearest") if skip is not None: # skip = F.interpolate(skip, size=x.shape[2:], mode='bilinear') _,x_l, skip = self.freq_fusion(hr_feat=x, lr_feat=skip) x = torch.cat([x, skip], dim=1) x = self.attention1(x) x = self.conv1(x) x = self.conv2(x) x = self.attention2(x)

这种方式确实不对,要不你留个v吧

@omnipotenttom
Copy link

File "/home/shuow/models/FreqFusion.py", line 189, in _forward
compressed_hr_feat = compressed_hr_feat + compressed_hr_feat - carafe(compressed_hr_feat,
File "/home/shuow/anaconda3/envs/pymvsnet/lib/python3.10/site-packages/torch/autograd/function.py", line 574, in apply return super().apply(*args, **kwargs) # type: ignore[misc]
File "/home/shuow/anaconda3/envs/pymvsnet/lib/python3.10/site-packages/mmcv/ops/carafe.py", line 141, in forward
ext_module.carafe_forward(
RuntimeError: expected scalar type Half but found Float 模型以及设置了混合精度训练,但模块仍然报错

@Linwei-Chen
Copy link
Owner Author

禁用混合精度试试?你看看中间哪个过程出现了数据格式不一致的情况,有点类似这个问题:#6

File "/home/shuow/models/FreqFusion.py", line 189, in _forward compressed_hr_feat = compressed_hr_feat + compressed_hr_feat - carafe(compressed_hr_feat, File "/home/shuow/anaconda3/envs/pymvsnet/lib/python3.10/site-packages/torch/autograd/function.py", line 574, in apply return super().apply(*args, **kwargs) # type: ignore[misc] File "/home/shuow/anaconda3/envs/pymvsnet/lib/python3.10/site-packages/mmcv/ops/carafe.py", line 141, in forward ext_module.carafe_forward( RuntimeError: expected scalar type Half but found Float 模型以及设置了混合精度训练,但模块仍然报错

@omnipotenttom
Copy link

感谢您的回复!禁用混合精度是可以的,但是我现在需要混和精度来减少显存占用。这个报错感觉是混合精度设置没对mmcv包起作用,您说的类似问题我参考下。感谢!

@Linwei-Chen
Copy link
Owner Author

还有一种减少显存占用的方式是使用torch里的checkpoint.checkpoint机制,也可以显著减少显存,供您参考。

@omnipotenttom
Copy link

谢谢!

还有一种减少显存占用的方式是使用torch里的checkpoint.checkpoint机制,也可以显著减少显存,供您参考。

@AutoTonner
Copy link

您好,祝贺你们的工作被Tpami接收。当我将freqsusion用于yolact算法的FPN中时(代码如下),map与dice和iou都没有明显变化,请问是否是我这边使用错误?
class FPN(nn.Module):
def init(self, in_channels, out_channels = 256):
super().init()
self.in_channels = in_channels
self.lat_layers = nn.ModuleList([nn.Conv2d(x, out_channels, kernel_size=1) for x in self.in_channels])
self.pred_layers = nn.ModuleList([nn.Sequential(nn.Conv2d(out_channels, out_channels, kernel_size=3, padding=1),
nn.ReLU(inplace=True)) for _ in self.in_channels])
self.downsample_layers = nn.ModuleList([nn.Sequential(nn.Conv2d(out_channels, out_channels, kernel_size=3, padding=1, stride=2),nn.ReLU(inplace=True)),nn.Sequential(nn.Conv2d(out_channels, out_channels, kernel_size=3, padding=1, stride=2),nn.ReLU(inplace=True))])
self.upsample_module = nn.ModuleList([
nn.Upsample(scale_factor=2, mode='bilinear', align_corners=False),
nn.Upsample(scale_factor=2, mode='bilinear', align_corners=False),
])
self.freqfusion_1 = FFs.FreqFusion(256,256)
self.freqfusion_2 = FFs.FreqFusion(256,256)

def forward(self, backbone_outs):
    p5_1 = self.lat_layers[2](backbone_outs[2])
    _, hr_feat_4, lr_feat_5 = self.freqfusion_1(self.lat_layers[1](backbone_outs[1]),p5_1)
    p4_1 = hr_feat_4 + lr_feat_5
    _, hr_feat_3, lr_feat_4 = self.freqfusion_2(self.lat_layers[0](backbone_outs[0]),p4_1)
    p3_1 = hr_feat_3 + lr_feat_4
    p5 = self.pred_layers[2](p5_1)
    p4 = self.pred_layers[1](p4_1)
    p3 = self.pred_layers[0](p3_1)
    p6 = self.downsample_layers[0](p5)
    p7 = self.downsample_layers[1](p6)
    return p3, p4, p5, p6, p7

@Linwei-Chen
Copy link
Owner Author

@monologuesmw
Copy link

您好,祝贺你们的工作被Tpami接收。
请教一下,模型支持转换onnx或者TensorRT吗?
open-mmlab/mmdeploy#172 mmdeploy在22年 还不支持carefe op 。

@Linwei-Chen
Copy link
Owner Author

Linwei-Chen commented Sep 26, 2024

您好,祝贺你们的工作被Tpami接收。 请教一下,模型支持转换onnx或者TensorRT吗? open-mmlab/mmdeploy#172 mmdeploy在22年 还不支持carefe op 。

这个op可以通过torch.nn.unfold替代,您可以尝试一下

@monologuesmw
Copy link

您好,祝贺你们的工作被Tpami接收。 请教一下,模型支持转换onnx或者TensorRT吗? open-mmlab/mmdeploy#172 mmdeploy在22年 还不支持carefe op 。

这个op可以通过torch.nn.unfold替代,您可以尝试一下

感谢回复 具体的替换方式可以给个示例吗?

@Linwei-Chen
Copy link
Owner Author

https://github.com/Linwei-Chen/LIS/blob/main/mmdetection/mmdet/models/backbones/CustomConv.py#L89

可以参考这个AdaD的实现,改动成功了记得回来分享一下hhh

@liangzw599
Copy link

有同学在医疗图像上改UNet遇到了同样的问题,是因为位置不对导致的,修改正确后初步试验涨了1个多点。 可以参考文档https://github.com/Linwei-Chen/FreqFusion 首页新更新的示例。建议把所有涉及上采样的部分都换成FreqFusion。

感谢您的回复,我在 unet 中修改了所有涉及上采样部分,结果依旧是降低的,但和之前的结果相比降低的不多。

我在unet中上采样使用了freqfusion,提了大概1.个多点,加的位置和方式很重要
我尝试在医疗图像上改nnunet出现了一些问题,可否加您个V交流一下

@Linwei-Chen
Copy link
Owner Author

您好,祝贺你们的工作被Tpami接收。 请教一下,模型支持转换onnx或者TensorRT吗? open-mmlab/mmdeploy#172 mmdeploy在22年 还不支持carefe op 。

这个op可以通过torch.nn.unfold替代,您可以尝试一下

感谢回复 具体的替换方式可以给个示例吗?

感谢您对我们工作的关注和使用!目前尝试更新了一版不依赖其它库的算子,您可以尝试使用,注意它可能会导致显存需求变多,以及现有的PT模型权重不兼容,需要重新训练以达到最好的效果。
https://github.com/Linwei-Chen/FreqFusion/blob/main/FreqFusion.py)](https://github.com/Linwei-Chen/FreqFusion/blob/main/FreqFusion.py

@MrWan001
Copy link

有同学在医疗图像上改UNet遇到了同样的问题,是因为位置不对导致的,修改正确后初步试验涨了1个多点。 可以参考文档https://github.com/Linwei-Chen/FreqFusion 首页新更新的示例。建议把所有涉及上采样的部分都换成FreqFusion。

感谢您的回复,我在 unet 中修改了所有涉及上采样部分,结果依旧是降低的,但和之前的结果相比降低的不多。

我在unet中上采样使用了freqfusion,提了大概1.个多点,加的位置和方式很重要

你好,想问一下在U-Net中是怎么加的,因为U-Net需要融合的两个特征通道应该是不一致的,
比如lr_feat=(B,512,32,32)和hr_feat(B,256,64,64),
如果对lr_feat使用FreqFusion上采样得到的结果是(B,512,64,64),这里请问你是怎么处理的,是把上采样后的(512,64,64)的lr_feat和(256,64,64)的hr_feat直接concat吗,还是在上采样之前就用卷积把两个特征通道数调整一致

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

9 participants