I’ve converted an east model into ONNX,but when checking model by onnx.checker.check_model()
, I got the following error:
Traceback (most recent call last):
File "east_onnx_demo.py", line 223, in <module>
onnx.checker.check_model(net)
File "/home/dai/py36env/lib/python3.6/site-packages/onnx/checker.py", line 86, in check_model
C.check_model(model.SerializeToString())
onnx.onnx_cpp2py_export.checker.ValidationError: Node () has input size 4 not in range [min=2, max=2].
==> Context: Bad node spec: input: "901" input: "924" input: "924" input: "923" output: "925" op_type: "Resize" attribute { name: "coordinate_transformation_mode" s: "pytorch_half_pixel" type: STRING } attribute { name: "cubic_coeff_a" f: -0.75 type: FLOAT } attribute { name: "mode" s: "linear" type: STRING } attribute { name: "nearest_mode" s: "floor" type: STRING }
The problem could come from the following code:
def forward(self, x1,x2,x3,x4):
y = F.interpolate(
x4, scale_factor=2.0, mode="bilinear", align_corners=False
)
y = torch.cat((y, x3), 1)
y = self.relu1(self.bn1(self.conv1(y)))
y = self.relu2(self.bn2(self.conv2(y)))
y = F.interpolate(
y, scale_factor=2.0, mode="bilinear", align_corners=False
)
y = torch.cat((y, x2), 1)
y = self.relu3(self.bn3(self.conv3(y)))
y = self.relu4(self.bn4(self.conv4(y)))
y = F.interpolate(
y, scale_factor=2.0, mode="bilinear", align_corners=False
)
y = torch.cat((y, x1), 1)
y = self.relu5(self.bn5(self.conv5(y)))
y = self.relu6(self.bn6(self.conv6(y)))
y = self.relu7(self.bn7(self.conv7(y)))
return y
Environment: Pytorch1.3.1, ONNX1.5.0
How can I solve this problem?