MPolaris / onnx2tflite

Tool for onnx->keras or onnx->tflite. Hope this tool can help you.
Apache License 2.0
519 stars 41 forks source link

更新github代码后,以前能转换的模型现在无法转换了 #37

Closed PaulX1029 closed 1 year ago

PaulX1029 commented 1 year ago

Traceback (most recent call last): File "/mnt/sda/AI/onnx2tflite-main/converter.py", line 70, in run() File "/mnt/sda/AI/onnx2tflite-main/converter.py", line 66, in run image_root=opt.imgroot File "/mnt/sda/AI/onnx2tflite-main/converter.py", line 18, in onnx_converter keras_model = keras_builder(model_proto, input_node_names, output_node_names) File "/mnt/sda/AI/onnx2tflite-main/utils/builder.py", line 81, in keras_builder raise KeyError(f"{op_name} not implemented yet") KeyError: 'Shape not implemented yet'

PaulX1029 commented 1 year ago

链接: https://pan.baidu.com/s/1Eg2DX0VDThLOBygOV8k_KQ?pwd=vijp 提取码: vijp

PaulX1029 commented 1 year ago

链接: https://pan.baidu.com/s/1Eg2DX0VDThLOBygOV8k_KQ?pwd=vijp 提取码: vijp

这是之前能正常转为tflite的onnx模型文件,转换参数如下: image

MPolaris commented 1 year ago

看样子,你是没有打开simplify,以至于没有优化掉shape这个算子。


onnx_converter(
    onnx_model_path = "./mymodel.onnx",
    need_simplify = True, #这里打开。
    output_path = "./",
    target_formats = ['tflite'], #or ['keras'], ['keras', 'tflite']
    weight_quant = False,
    int8_model = True, # do quantification
    int8_mean = [123.675, 116.28, 103.53], # give mean of image preprocessing 
    int8_std = [58.395, 57.12, 57.375], # give std of image preprocessing 
    image_root = "./dataset/train" # give image folder of train
)