PyTorch-YOLOv3
PyTorch-YOLOv3 copied to clipboard
There is some problems when read network structures with torchsummary.
Summary is not a problem, because other networks can be read, and it is possible that a problem with this network code caused an error.
AttributeError Traceback (most recent call last)
E:\Program Files\anaconda\lib\site-packages\torchsummary\torchsummary.py in summary(model, input_size, batch_size, device) 70 # make a forward pass 71 # print(x.shape) ---> 72 model(*x) 73 74 # remove these hooks
E:\Program Files\anaconda\lib\site-packages\torch\nn\modules\module.py in call(self, *input, **kwargs) 491 result = self._slow_forward(*input, **kwargs) 492 else: --> 493 result = self.forward(*input, **kwargs) 494 for hook in self._forward_hooks.values(): 495 hook_result = hook(self, input, result)
F:\Pytorch\nut检测\eriklindernoren-PyTorch-YOLOv3\models.py in forward(self, x, targets) 258 x = layer_outputs[-1] + layer_outputs[layer_i] 259 elif module_def["type"] == "yolo": --> 260 x, layer_loss = module[0](x, targets, img_dim) 261 loss += layer_loss 262 yolo_outputs.append(x)
E:\Program Files\anaconda\lib\site-packages\torch\nn\modules\module.py in call(self, *input, **kwargs) 493 result = self.forward(*input, **kwargs) 494 for hook in self._forward_hooks.values(): --> 495 hook_result = hook(self, input, result) 496 if hook_result is not None: 497 raise RuntimeError(
E:\Program Files\anaconda\lib\site-packages\torchsummary\torchsummary.py in hook(module, input, output) 21 if isinstance(output, (list, tuple)): 22 summary[m_key]["output_shape"] = [ ---> 23 [-1] + list(o.size())[1:] for o in output 24 ] 25 else:
E:\Program Files\anaconda\lib\site-packages\torchsummary\torchsummary.py in
AttributeError: 'int' object has no attribute 'size'
Can you give me a hand?
Hello, have you solved this issue? I have the same problem with you!
The problem comes from the YOLOLayer.forward returning both an output tensor and a loss value
You should modify YOLOLayer.forward to return only the output tensor, not the loss value. I added a YOLOLayer.get_current_loss function to support this