コード例 #1
0
    print('  Removing initializer from inputs in ONNX model...')
    remove_initializer_from_input(onnx_path, onnx_path)

    print('  Removing intermediate *.symbol and *.params')
    os.remove(intermediate_symbol)
    os.remove(intermediate_params)


if __name__ == '__main__':

    config = Configs(models_dir='/models')

    models_to_convert = [
        name for name in config.mxnet_models
        if config.in_official_package(name)
    ]
    custom_shape = (1, 3, 480, 640)

    for model in models_to_convert:
        print(f"Downloading model: {model}...")
        get_model_file(model, root=config.mxnet_models_dir)

    for model in models_to_convert:
        mxnet_symbol, mxnet_params = config.get_mxnet_model_paths(model)
        reshape = config.mxnet_models[model].get('reshape')
        shape = config.mxnet_models[model].get('shape', (1, 3, 112, 112))
        if custom_shape and reshape == True:
            shape = custom_shape
        output_onnx_dir, output_onnx_model = config.build_model_paths(
            model, "onnx")