Closed hoangkhoiLE closed 4 years ago
Detail of error:
Hi @hoangkhoiLE,
Unfortunately I'm not familiar with onnx
and this script is here as we forked from original mmdetection. In this particular place the problem is that we overwrite forward_train method, but not forward_dummy. Looks like it also need a one line modification to use history
argument.
Thank you for your answer. I try to overwrite "forward_dummy" by the way you do with "foward_train". But it is not working, i'm looking forward to your suggestion to modify it. Thank a lot.
Here is how i tried:
def forward_dummy(self, img, history=None):
"""Used for computing network flops.
See `mmdetection/tools/get_flops.py`
"""
outs = ()
# backbone
x = self.extract_feat(img,history)
# rpn
if self.with_rpn:
rpn_outs = self.rpn_head(x)
outs = outs + (rpn_outs, )
proposals = torch.randn(1000, 4).to(img.device)
# roi_head
roi_outs = self.roi_head.forward_dummy(x, proposals)
outs = outs + (roi_outs, )
return outs
Best regard.
Looks like here input_data
should be a tuple ((1, 3, w, h), (1, 1, w, h)). Now it contains only image and the history is None
, so you are getting this NoneType
exception.
Thank for your response. I will try to fix it.
Dear @filaPro @hoangkhoiLE ,
I was able to generate an .onnx model file by overwriting forward_dummy
as follows, inspired by your discussion:
def forward_dummy(self, img, history=None):
"""Used for onnx model file.
See `mmdetection/tools/pytorch2onnx.py`
"""
if not history:
height, width = img.shape[2:]
history = torch.zeros((1, 1, height, width), device=img.device)
x = self.extract_feat(img, history)
outs = self.bbox_head(x)
return outs
Which I wrote in mmdet/models/detectors/iterdet_retinanet.py
.
KR
Hi,
Thank for your excellent work. I saw that you have a file pytorch2onnx.py in ./tools. But when i used it, i got an error:
File "/mmdet/models/detectors/two_stage.py", line 88, in forward_dummy
x = self.extract_feat(img)
TypeError: extract_feat() missing 1 required positional argument: 'history'
Please help me in this case how to find and add "history".
Best regard