Because the input of the model cannot be transferred to rknn after transferring to onnx, it is necessary to modify the node of onnx to the left
import onnx
import onnx.helper as helper
from onnx.helper import TensorProto
import numpy as np
model = onnx.load('demo.change.onnx')
#自己创建新的节点
###########################################
reshape_node = helper.make_node(
'Reshape', # 节点类型
inputs=['input'], # 输入张量列表
outputs=['conv2d_input'] # 输出张量列表
)
###########################################
#改变输入的input
input = helper.make_tensor_value_info('input', TensorProto.FLOAT, [1, 3, 48, 48])
model.graph.node[0].CopyFrom(reshape_node)
# 修改权重后储存成新的onnx,不然不生效
onnx.save_model(model, "demo.change1.onnx")
print("Done.!")