xiuqhou / Salience-DETR

[CVPR 2024] Official implementation of the paper "Salience DETR: Enhancing Detection Transformer with Hierarchical Salience Filtering Refinement"
https://arxiv.org/abs/2403.16131
Apache License 2.0
142 stars 8 forks source link

使用swin_l 和 focalnet backbone 报错参数不匹配问题 #51

Open autoencoder-zz opened 4 days ago

autoencoder-zz commented 4 days ago

Question

我在salience_detr.py中的 class SalienceDETR(DNDETRDetector): 类 加入了 self.Re_Weight = WeightRefactor(sample_num),使用resnet50 backbone可以训练,但是swin_l 会报错:

`[2024-11-11 20:07:56 det.models.backbones.base_backbone]: Backbone architecture: swin_l WARNING [2024-11-11 20:08:04 det.util.utils]: The model and loaded state dict do not match exactly WARNING [2024-11-11 20:08:04 det.util.utils]: Size mismatch keys: head.weight, head.bias +-------------+----------------+---------------------+ | key name | shape in model | shape in state dict | +-------------+----------------+---------------------+ | head.weight | (1000, 1536) | (21841, 1536) | +-------------+----------------+---------------------+ | head.bias | (1000,) | (21841,) | +-------------+----------------+---------------------+

Traceback (most recent call last): File "/data/lost+found/python project/Salience-DETR/main.py", line 206, in train() File "/data/lost+found/python project/Salience-DETR/main.py", line 123, in train model = Config(cfg.model_path).model File "/data/lost+found/python project/Salience-DETR/util/lazy_load.py", line 24, in init exec(code, name_space) File "", line 97, in File "/data/lost+found/python project/Salience-DETR/models/detectors/salience_detr.py", line 355, in init self.Re_Weight = WeightRefactor(sample_num) File "/data/lost+found/python project/Salience-DETR/models/detectors/salience_detr.py", line 52, in init self.layer1 = nn.Linear(sample_num sample_num, 1, bias=False) TypeError: unsupported operand type(s) for : 'NoneType' and 'NoneType'`

同样的,focalnet也在同样的部分出现报错

[2024-11-11 21:16:25 det.models.backbones.base_backbone]: Backbone architecture: focalnet_large_lrf_fl4 WARNING [2024-11-11 21:16:31 det.util.utils]: The model and loaded state dict do not match exactly WARNING [2024-11-11 21:16:31 det.util.utils]: Unexpected keys: norm.weight, norm.bias, head.weight, head.bias 。 。 。 TypeError: unsupported operand type(s) for *: 'NoneType' and 'NoneType'

请问这个问题是什么原因?

Additional

No response

xiuqhou commented 4 days ago

看起来是sample_num参数没有正确传递进去,导致这个参数变成了None。可能是参数名和实际传的参数没对上,或者少写了个参数

autoencoder-zz commented 3 days ago

看起来是sample_num参数没有正确传递进去,导致这个参数变成了None。可能是参数名和实际传的参数没对上,或者少写了个参数

好的谢谢