因为转onnx后模型的输入无法转rknn,所以要对onnx进行节点修改成左边
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.!")