Open Amadeus-AI opened 3 years ago
I got password error when decompressing your model.zip
Your onnx file seems to be converted from tensorflow graph, while onnx2ncnn supports onnx exported from pytorch. Try keras2ncnn or mlir2ncnn for tensorflow model conversion
@nihui My onnx is exported from pytorch
I found that maybe the following operation is the cause:
class Conv2d_cd(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size=3, stride=1, padding=1, dilation=1, groups=1, bias=False, theta=0.5):
super(Conv2d_cd, self).__init__()
self.conv = nn.Conv2d(in_channels, out_channels, kernel_size=kernel_size, stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)
self.theta = theta
def forward(self, x):
out_normal = self.conv(x)
kernel_diff = self.conv.weight.sum(2).sum(2)
out_diff = torch.matmul(x.permute(0,2,3,1), kernel_diff.permute(1,0)).permute(0,3,1,2)
return out_normal - self.theta * out_diff
You can test this module
Is there any update on this issue? @nihui
针对onnx模型转换的各种问题,推荐使用最新的pnnx工具转换到ncnn In view of various problems in onnx model conversion, it is recommended to use the latest pnnx tool to convert your model to ncnn
pip install pnnx
pnnx model.onnx inputshape=[1,3,224,224]
详细参考文档 Detailed reference documentation https://github.com/pnnx/pnnx https://github.com/Tencent/ncnn/wiki/use-ncnn-with-pytorch-or-onnx#how-to-use-pnnx
I got different result between onnx and ncnn model even if input is a zeros mat. (Already checked the FAQ) model.zip Password:0000 Here's the onnx and ncnn model. (You can also try to regenerate ncnn model from onnx) @nihui
A simple test:
NCNN output: 0.43, -0.66
ONNX(and other transform like tflite): -0.05 , -0.09
on win10 x64, tested every version from 2020.12 till latest version of ncnn