./MNNConvert -f TF/ONNX/TFLITE --modelFile XXX.pb/XXX.onnx/XXX.tflite --MNNModel XXX.XX --bizCode XXX
三个选项是必须的!
./MNNConvert -f TF --modelFile path/to/mobilenetv1.pb --MNNModel model.mnn --bizCode MNN
./MNNConvert -f CAFFE --modelFile XXX.caffemodel --prototxt XXX.prototxt --MNNModel XXX.XX --bizCode XXX
四个选项是必须的!
./MNNConvert -f CAFFE --modelFile path/to/mobilenetv1.caffemodel --prototxt path/to/mobilenetv1.prototxt --MNNModel model.mnn --bizCode MNN
./MNNConvert -f MNN --modelFile XXX.mnn --MNNModel XXX.XX --bizCode XXX
./MNNConvert --version
将MNN模型bin文件 dump 成可读的类json格式文件,以方便对比原始模型参数
import torchimport torchvisiondummy_input = torch.randn(10, 3, 224, 224, device='cuda')model = torchvision.models.alexnet(pretrained=True).cuda()# Providing input and output names sets the display names for values# within the model's graph. Setting these does not change the semantics# of the graph; it is only for readability.## The inputs to the network consist of the flat list of inputs (i.e.# the values you would pass to the forward() method) followed by the# flat list of parameters. You can partially specify names, i.e. provide# a list here shorter than the number of inputs to the model, and we will# only set that subset of names, starting from the beginning.input_names = [ "actual_input_1" ] + [ "learned_%d" % i for i in range(16) ]output_names = [ "output1" ]torch.onnx.export(model, dummy_input, "alexnet.onnx", verbose=True, input_names=input_names, output_names=output_names)
./MNNConvert -f ONNX --modelFile alexnet.onnx --MNNModel alexnet.mnn --bizCode MNN