rockchip-linux / rknn-toolkit

BSD 3-Clause "New" or "Revised" License
817 stars 174 forks source link

does rknn support conv3d? #56

Open microaisystems opened 3 years ago

microaisystems commented 3 years ago

Hi

I made a single layer network:

def export_pytorch_model():
    net = Conv3d(3, 64, kernel_size=[2,3,3], stride=[1,2,2])
    net.eval()
    trace_model = torch.jit.trace(net, torch.Tensor(1,3,2,180,360))
    trace_model.save('./sqnet.pt')

Then follow the rknn api as below:

input_size_list = [[3,2,180,360]] #stacked 3D images
# Create RKNN object
rknn = RKNN()
# pre-process config
print('--> config model')
rknn.config(channel_mean_value='123.675 116.28 103.53 58.395', reorder_channel='0 1 2') 
print('done')

if not os.path.exists('./sqnet.rknn'):
    export_pytorch_model()
    model = './sqnet.pt'
    # Load pytorch model
    print('--> Loading model')
    ret = rknn.load_pytorch(model=model, input_size_list=input_size_list)
    if ret != 0:
        print('Load pytorch model failed!')
        exit(ret)
    print('done')

When run the above code, I got following error message: --> config model done --> Loading model ./sqnet.pt **** W Channels(360) of input node: input.1 > 128, mean/std values will be set to default 0/1. W Please do pre-processing manually before inference. E convolution output_padding only suport [0,0] for now, but meet [0,0] W ----------------Warning(2)---------------- E Catch exception when loading pytorch model: ./sqnet.pt! E Traceback (most recent call last): E File "rknn/api/rknn_bI made a single layer network:

def export_pytorch_model():
    net = Conv3d(3, 64, kernel_size=[2,3,3], stride=[1,2,2])
    net.eval()
    trace_model = torch.jit.trace(net, torch.Tensor(1,3,2,180,360))
    trace_model.save('./sase.py", line 339, in rknn.api.rknn_base.RKNNBase.load_pytorch
E   File "rknn/base/RKNNlib/RK_nn.py", line 146, in rknn.base.RKNNlib.RK_nn.RKnn.load_pytorch
E   File "rknn/base/RKNNlib/app/importer/import_pytorch.py", line 128, in rknn.base.RKNNlib.app.importer.import_pytorch.ImportPytorch.run
E   File "rknn/base/RKNNlib/converter/convert_pytorch_new.py", line 2255, in rknn.base.RKNNlib.converter.convert_pytorch_new.convert_pytorch.load
E   File "rknn/base/RKNNlib/converter/convert_pytorch_new.py", line 2370, in rknn.base.RKNNlib.converter.convert_pytorch_new.convert_pytorch.parse_nets
E   File "rknn/base/RKNNlib/converter/convert_pytorch_new.py", line 2059, in rknn.base.RKNNlib.converter.convert_pytorch_new.PyTorchOpConverter.convert_operators
E   File "rknn/base/RKNNlib/converter/convert_pytorch_new.py", line 648, in rknn.base.RKNNlib.converter.convert_pytorch_new.PyTorchOpConverter.convolution
E   File "rknn/api/rknn_log.py", line 312, in rknn.api.rknn_log.RKNNLog.e
E ValueError: convolution output_padding only suport [0,0] for now, but meet [0,0]
Load pytorch model failed!

Question: what can I do to fix this [0,0] padding issue? Thanks for your help.

cuiyong127 commented 6 months ago

I also encountered the same problem, but I don't know how to handle it