cl2227619761 / AttFPN-Ovarian-Cancer

MIT License
8 stars 3 forks source link

ERROR when using Model `densenet169` #2

Open Chrisa142857 opened 3 years ago

Chrisa142857 commented 3 years ago

Hi! I got an ERROR when I using the MODEL_NAME=densenet169. It looks like that there are some BUGs in the backbone codes. I can train, however, with MODEL_NAME=densenet121, and I didn't try other models.

My Environment:

Input: An RGB image [1, 3, 1024, 1024]

Output:

Traceback (most recent call last):
  File "run.py", line 327, in <module>
    main()
  File "run.py", line 314, in main
    engine.train_process(model=model, optimizer=optimizer,
  File "D:\WSI_analysis\det_train\AttFPN-Ovarian-Cancer-master\tools\engine.py", line 82, in train_process
    loss_dict = model(images, targets)
  File "E:\envs\yolov5\lib\site-packages\torch\nn\modules\module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "D:\WSI_analysis\det_train\AttFPN-Ovarian-Cancer-master\utils\generalized_rcnn.py", line 40, in forward
    features = self.backbone(images.tensors)
  File "E:\envs\yolov5\lib\site-packages\torch\nn\modules\module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "D:\WSI_analysis\det_train\AttFPN-Ovarian-Cancer-master\utils\backbone_utils.py", line 62, in forward
    x = self.afpn(x)
  File "E:\envs\yolov5\lib\site-packages\torch\nn\modules\module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "D:\WSI_analysis\det_train\AttFPN-Ovarian-Cancer-master\utils\fpn.py", line 77, in forward
    last_out = self.get_result_from_inner_blocks(x[-1], -1)
  File "D:\WSI_analysis\det_train\AttFPN-Ovarian-Cancer-master\utils\fpn.py", line 50, in get_result_from_inner_blocks
    out = module(x)
  File "E:\envs\yolov5\lib\site-packages\torch\nn\modules\module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "E:\envs\yolov5\lib\site-packages\torch\nn\modules\container.py", line 139, in forward
    input = module(input)
  File "E:\envs\yolov5\lib\site-packages\torch\nn\modules\module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "E:\envs\yolov5\lib\site-packages\torch\nn\modules\conv.py", line 443, in forward
    return self._conv_forward(input, self.weight, self.bias)
  File "E:\envs\yolov5\lib\site-packages\torch\nn\modules\conv.py", line 439, in _conv_forward
    return F.conv2d(input, weight, bias, self.stride,
RuntimeError: Given groups=1, weight of size [256, 1024, 1, 1], expected input[1, 1664, 25, 25] to have 1024 channels, but got 1664 channels instead
Chrisa142857 commented 3 years ago

Hi there~ I found that the commented codes for densenet161 is correct, but others still cannot work

So, I can only use the densenet161 for your model in our comparison.

Looking forward to your rely !

cl2227619761 commented 3 years ago

Thank you for pointing out the bug. You need to ensure that the code in line 124 to line 126 matchs the backbone network structure. For example, if you use the densenet121, you need to use the line 124; if you use the densenet161, you need to use the line 125. In fact, you need to make the number of channel correct.

I will update and write a more detailed instruction in the near future.

cl2227619761 commented 3 years ago

Hi there~ I found that the commented codes for densenet161 is correct, but others still cannot work

So, I can only use the densenet161 for your model in our comparison.

Looking forward to your rely !

Thank you for pointing out the bug. You need to ensure that the code in line 124 to line 126 matchs the backbone network structure. For example, if you use the densenet121, you need to use the line 124; if you use the densenet161, you need to use the line 125. In fact, you need to make the number of channel correct.

I will update and write a more detailed instruction in the near future.

cl2227619761 commented 3 years ago

Hi there~ I found that the commented codes for densenet161 is correct, but others still cannot work

So, I can only use the densenet161 for your model in our comparison.

Looking forward to your rely !

Line 124 to line 126 in utils backbone_utils.py