对yolov5进行了asff和cbam添加,然后对模型进行剪枝,剪枝后,总是出现:
TypeError: init() missing 1 required positional argument: 'c2'
Traceback (most recent call last):
File "pruned.py", line 809, in <module>
main(opt)
File "pruned.py", line 782, in main
run_prune(**vars(opt))
File "A:\anaconda3\envs\yolov5-6.0_gpu\lib\site-packages\torch\autograd\grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "pruned.py", line 496, in run_prune
pruned_model = ModelPruned(maskbndict=maskbndict, cfg=pruned_yaml, ch=3).cuda()
File "A:\yolov5-asff+cbam-p\models\yolo.py", line 294, in __init__
self.model, self.save, self.from_to_map = parse_pruned_model(self.maskbndict, deepcopy(self.yaml), ch=[ch]) # model, savelist
File "A:\yolov5-asff+cbam-p\models\yolo.py", line 601, in parse_pruned_model
m_ = nn.Sequential(*(m(*args) for _ in range(n))) if n > 1 else m(*args) # module
TypeError: __init__() missing 1 required positional argument: 'c2'
总是缺少c2这个通道,但在未剪枝前,添加了asff和cbam都可以正常运行,所以,剪枝出现了这样的问题,该如何解决?